summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:13:23 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:13:23 +0000
commit6d0e93c68d3aeaeb4bb6d96ac0460eec40ef786e (patch)
treea956ed510e14a5509b8ef49fae42cfd439629825 /sca-java-1.x/branches
parent3ac2d800d840f03618fc364090d786effde84b1f (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835143 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches')
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/LICENSE.txt323
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/NOTICE.txt18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/STATUS.txt78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/pom.xml177
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java279
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java400
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java106
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java98
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java465
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java216
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java228
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java153
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/DasAccountConfiguration.xml80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/AccountService.wsdl467
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/default.scdl80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/web.xml66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/Show.Image.html40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountfiles.pngbin0 -> 15889 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountmodule.pngbin0 -> 33300 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/modualoverview.pngbin0 -> 6074 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientfiles.pngbin0 -> 17123 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientmodule.pngbin0 -> 10748 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/pom.xml36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/readme.html894
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/pom.xml167
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java117
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java120
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java85
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java161
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java96
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl466
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/CustomerProfile.jsp100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld127
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/web.xml83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountLog.jsp99
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountTransaction.jsp50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/login.html60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/purchaseStock.jsp59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/stockSale.jsp56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/summary.jsp144
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/css/base.css52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/pom.xml148
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/readme.html339
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/pom.xml94
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/readme.html293
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorService.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorServiceImpl.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideServiceImpl.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/client/CalculatorClient.java84
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorService.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorServiceImpl.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SqrtService.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/default.scdl78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/sci_calc.scdl42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.componentType27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.js21
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.componentType24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.rb22
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/wsdl/calculator.wsdl255
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/test/java/calculator/CalculatorTestClient.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/pom.xml60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/readme.html103
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorService.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorServiceImpl.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/test/java/calculator/CalculatorTestCase.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/pom.xml91
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/readme.html248
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorService.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorServiceImpl.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathService.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyServiceImpl.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/server/CalculatorRMIServer.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/sca/default.scdl59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/test/java/calculator/server/CalculatorRMITestServer.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/pom.xml123
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/readme.html129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/pom.xml68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/readme.html104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldClient.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.componentType27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.js21
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/sca/default.scdl28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/test/java/helloworld/HelloWorldTestCase.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/pom.xml65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/readme.html215
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldImpl.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldRmiClient.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/HelloWorldImpl.componentType29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/sca/default.scdl34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/pom.xml66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/readme.html206
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldImpl.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldRmiServer.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/HelloWorldImpl.componentType26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/sca/default.scdl34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/pom.xml68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/readme.html104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldClient.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.componentType27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.rb24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/NOTICE15
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/sca/default.scdl28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/test/java/helloworld/HelloWorldTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/pom.xml124
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/readme.html131
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/sca/default.scdl53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/logging.properties29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/wsdl/helloworld.wsdl152
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/java/helloworld/HelloWorldWSAsyncClient.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/resources/META-INF/tuscany/test-extensions.scdl28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/pom.xml107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/readme.html105
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldClient.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldService.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldServiceComponent.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/sca/default.scdl39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/wsdl/helloworld.wsdl124
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/test/java/helloworld/HelloWorldWSClient.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/pom.xml58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/readme.html112
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/InnerCompositeClient.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Source.java24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceCallback.java24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceImpl.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Target.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/TargetImpl.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite2.scdl33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/default.scdl37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/test/java/innercomposite/InnerCompositeTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/pom.xml60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/readme.html106
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClient.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClientImpl.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyService.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceCallback.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceImpl.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/SimpleCallbackClient.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/resources/META-INF/sca/default.scdl31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/test/java/simplecallback/SimpleCallbackTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/pom.xml60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/readme.html107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Customer.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/CustomerComponentImpl.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Retailer.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/RetailerComponentImpl.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Shipper.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/ShipperComponentImpl.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/SupplyChainClient.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Warehouse.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/sca/default.scdl42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/pom.xml139
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/readme.html153
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorService.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathService.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractService.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractServiceImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/wsdl/calculator.wsdl255
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/default.scdl59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/web.xml42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/pom.xml104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/readme.html111
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterImpl.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterService.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/resources/wsdl/greeter.wsdl64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/default.scdl40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/web.xml42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/pom.xml133
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/readme.html113
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldCallback.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldService.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/wsdl/helloworld.wsdl180
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/sca/default.scdl48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/binding.axis2.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/webapp.scdl138
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/default.scdl48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/web.xml42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/pom.xml135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/readme.html108
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldImpl.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldService.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/wsdl/helloworld.wsdl126
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/default.scdl35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/web.xml42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/LICENSE.txt416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/NOTICE.txt32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/pom.xml63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/readme.html118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/default.scdl26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/web.xml44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/calc.jsp43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/BUILDING.txt29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/LICENSE.txt323
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/NOTICE.txt18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/STATUS.txt78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/pom.xml77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/InvalidMainException.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/LaunchException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java195
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl133
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/org/apache/tuscany/launcher/MainLauncher.properties24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/commands/pom.xml37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/distribution/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/distribution/NOTICE.txt306
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/distribution/build.xml195
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/distribution/extensions.scdl30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/distribution/pom.xml159
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/distribution/src/main/assembly/standalone.xml145
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.checkstyle24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/pom.xml50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/pom.xml92
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java88
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java247
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java484
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ComponentInitException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java143
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java137
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java146
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java163
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactory.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java132
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java116
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java153
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java65
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java357
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java216
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java175
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java195
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java60
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java83
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java1410
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java66
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java244
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java67
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java256
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java820
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java57
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java59
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java55
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java73
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java120
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java145
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java222
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java184
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java170
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBindlessBuilder.java83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java111
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java130
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/DependencyLoader.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java133
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java127
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java98
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncMonitor.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java140
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java111
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java95
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java521
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java339
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java155
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java161
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java85
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java174
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java108
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReference.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReferenceImpl.java115
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemService.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemServiceImpl.java102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java131
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemWireObjectFactory.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemBindingLoader.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java97
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemBinding.java29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWire.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java159
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java152
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWire.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java146
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java109
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/WireObjectFactory.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/InvalidMainException.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java230
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java251
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java108
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java184
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java99
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java159
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java191
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java218
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java197
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java96
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java139
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java113
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java206
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java217
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java166
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java220
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java93
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java439
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java160
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java171
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundAutowire.java29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java170
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/PojoTargetInvoker.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/StaticPojoTargetInvoker.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java139
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java155
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java341
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl153
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java75
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java416
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java99
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java187
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java183
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java141
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java116
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicModuleScopeTestCase.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java172
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java165
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeInstanceLifecycleTestCase.java165
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactoryTestCase.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeRestartTestCase.java102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java155
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java99
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java88
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java142
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java86
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java231
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java221
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java106
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java89
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java99
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java163
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java124
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java231
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java235
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java223
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java168
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java174
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java167
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java124
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java120
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java97
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java113
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java192
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java86
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvokerTestCase.java101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java128
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java121
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java111
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java266
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java88
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java229
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/ScopeReferenceTestCase.java746
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java381
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/AsyncTarget.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTarget.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTargetImpl.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Source.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/SourceImpl.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Target.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/TargetImpl.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java154
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java148
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java171
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java173
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java330
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java367
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java98
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java180
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java156
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java173
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java116
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java166
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java137
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderTestCase.java303
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java103
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/AtomicComponentWireInvocationTestCase.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundtoOutboundTestCase.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundToInboundTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemServiceComponentWireTestCase.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/WireObjectFactoryTestCase.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java122
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/java/builder/JavaBuilderPropertyTestCase.java100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java88
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java183
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java137
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java164
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java103
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java112
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java128
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponent.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponentImpl.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeDestroyOnlyComponent.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitComponent.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitDestroyComponent.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitDestroyComponent.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitOnlyComponent.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockComponentFactory.java180
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockFactory.java184
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java97
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java165
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java132
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java180
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java150
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java94
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java95
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java95
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/MediationTestCase.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java135
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java133
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/StaticPojoInvokerTestCase.java157
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java139
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java138
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml22
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl132
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl22
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.checkstyle24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/pom.xml58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java146
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/util/LaunchHelperTestCase.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/pom.xml97
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.checkstyle24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/pom.xml68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/doc/Context Model.emx673
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java84
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindlessBuilder.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/PostProcessingException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessor.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorExtension.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorRegistry.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java122
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AutowireResolutionException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java98
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentNotFoundException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java184
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidComponentTypeException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ObjectRegistrationException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceNotFoundException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeNotFoundException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRuntimeException.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java97
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SystemAtomicComponent.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java67
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java44
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java44
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java72
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java46
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java49
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java75
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java391
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java940
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java84
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java149
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java93
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java524
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java98
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/WrapperInfo.java117
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java96
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java163
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java128
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java91
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java91
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java98
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnexpectedElementException.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Binding.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindlessServiceDefinition.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java154
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java143
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java146
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java223
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java351
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java105
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java128
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java246
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java197
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java106
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java95
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java88
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/RuntimeWire.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java156
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireServiceExtension.java109
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java124
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java114
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java86
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java71
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java93
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java177
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java176
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java126
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java384
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/pom.xml46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/plugin/Java2WSDLGeneratorMojo.java153
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/LICENSE.txt1277
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/README.txt35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/pom.xml48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java122
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java473
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/pom.xml46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java152
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDLFileOption.java92
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/LICENSE.txt1277
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/README.txt35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/plugins/pom.xml64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/pom.xml364
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/pom.xml61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/src/test/java/org/apache/tuscany/equinox/EquinoxStartTestCase.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.ruleset190
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/README.txt35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/pom.xml90
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/LauncherActivator.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGILauncherInitException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGiHost.java32
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteMethodException.java36
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteServiceException.java41
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBinding.java47
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingBuilder.java73
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingException.java41
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingLoader.java64
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiInvoker.java81
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiReference.java62
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiService.java109
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/BundleContextUtil.java93
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/ClassloaderHook.java82
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/MANIFEST.MF14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/sca/osgibinding.scdl41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/pom.xml41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/pom.xml46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java125
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/pom.xml40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/pom.xml70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/InvalidCompositePath.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java142
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherInitException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/UnSupportedRuntimeException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java235
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/binding.axis2.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/databinding.sdo.scdl34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl139
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/resources/testapp.scdl26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/pom.xml60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherMonitor.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyInitException.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyRequestListener.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanySessionListener.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfoImpl.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java127
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyFilterTestCase.java118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanySessionListenerTestCase.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/WebappUtilTestCase.java131
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml163
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java84
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java208
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java71
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java187
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java100
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java290
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java114
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java95
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java207
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java136
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java78
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java143
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java44
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java491
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java377
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl49
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml302
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java105
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java150
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java24
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl169
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd23
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml96
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java245
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java270
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java195
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java205
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java322
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java134
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl181
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl154
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl181
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml288
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java71
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js484
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset190
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java78
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java160
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java84
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt1277
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java169
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java157
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java113
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java85
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java166
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java151
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java169
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java94
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java75
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java125
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java174
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER6
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE203
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE11
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java93
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/pom.xml63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/build.xml56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java92
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java120
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java119
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java150
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java189
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy1
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/pom.xml105
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponent.java120
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentBuilder.java152
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentType.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentTypeLoader.java113
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementation.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoader.java111
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptIntrospector.java173
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptInvoker.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptRefInvocInterceptor.java132
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptReferenceProxy.java132
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvoker.java123
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfig.java157
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScript.java210
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstance.java109
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsHandler.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsProcessor.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/TuscanySampleXmlUtil.java1097
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XBbasedXMLGenerator.java253
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGenerator.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGeneratorFactory.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDConfiguration.java246
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGenerator.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceCreationException.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistry.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistryImpl.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/default.scdl51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/js.system.scdl45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java107
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java114
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java161
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java174
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java116
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java83
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl242
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl180
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js21
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js21
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js1
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd100
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/pom.xml81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponent.java134
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentBuilder.java94
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentType.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentTypeLoader.java118
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementation.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java123
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyIntrospector.java173
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInvoker.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyRefInvocInterceptor.java92
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyReferenceProxy.java127
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubySCAConfig.java159
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScript.java160
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScriptInstance.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyUtils.java71
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/default.scdl46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/ruby.system.scdl40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldService.java24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldServiceImpl.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyImplementationLoaderTestCase.java109
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptIntrospectorTestCase.java130
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptInvokeTestCase.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/WireTestCase.java186
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/function/HelloWorldTestCase.java75
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Greeting.java26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.componentType28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.rb33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/IntrospectableHelloWorld.rb30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/helloworld.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.componentType26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.rb24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/jruby/helloworld.wsdl78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/mock/test.rb1
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/.ruleset190
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/README.txt35
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/pom.xml81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java109
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java88
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java252
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java196
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInterceptor.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java104
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringRuntimeInfo.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringImplementation.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringServiceContract.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/ScaWebApplicationContext.java130
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/SpringWebappRuntimeInfo.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java147
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java123
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java105
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java144
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/intercept/OneWayAdvisor.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/AnnotationServiceMetadata.java95
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/BeanFactoryDeploymentMetadata.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/DeploymentMetadata.java28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/FieldInjection.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/Injection.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/MethodInjection.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/NoSuchServiceException.java24
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/ServiceMetadata.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/sca/spring.system.scdl40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.handlers3
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.schemas1
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/org/springframework/sca/xml/spring-sca.xsd101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java137
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/integration/BootstrapTestCase.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java31
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/application-context.xml32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/default.scdl37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/ExplicitSpring.xml32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/SpringConfigSchemaTest.xml35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/test.xml29
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/pom.xml84
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/pom.xml76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java40
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java62
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java54
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java88
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl56
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/java/org/apache/tuscany/databinding/axiom/OMElementTestCase.java68
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xml51
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xsd136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/order.wsdl76
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/pom.xml114
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java64
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/java/org/apache/tuscany/databinding/castor/Castor2NodeTestCase.java46
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/binding.xml27
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/ipo.xsd136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/org/exolab/castor/builder/castorbuilder.properties81
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/pom.xml133
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXB2Node.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java109
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandler.java102
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Node2JAXB.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Reader2JAXB.java72
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/XMLStreamReader2JAXB.java68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/resources/META-INF/sca/default.scdl43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java83
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java105
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/resources/ipo.xsd136
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/pom.xml119
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2String.java69
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReader.java72
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java87
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java146
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ModelDataObject.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataTypeHelper.java52
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOSimpleTypeMapper.java69
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java83
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/String2DataObject.java58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2String.java63
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReader.java65
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2DataObject.java66
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2XMLDocument.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/databinding.sdo.scdl68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/default.scdl66
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2StringTestCase.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReaderTestCase.java56
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObjectLoaderTestCase.java73
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java86
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDODataBindingTestCase.java61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOTransformerTestCaseBase.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/META-INF/tuscany/databinding.sdo.scdl34
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/ipo.xsd136
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-core.xsd233
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-implementation-mock.xsd43
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/pom.xml217
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/JAXBTestCase.java119
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/TransformationTestCase.java250
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/XmlObjectTestCase.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Client.java26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/ClientImpl.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/DataBindingBootStrapTest.java115
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Echo.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/EchoImpl.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/sca/default.scdl34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.axiom.scdl52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.jaxb.scdl43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.sdo.scdl58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.xmlbeans.scdl43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/interface.wsdl.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/test-extensions.scdl30
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xml51
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsd136
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsdconfig21
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/NOTICE.txt14
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/pom.xml98
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/Node2XmlObject.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLBeansDataBinding.java35
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLStreamReader2XmlObject.java56
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2Node.java52
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2XMLStreamReader.java47
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/resources/META-INF/sca/default.scdl43
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/java/org/apache/tuscany/databinding/xmlbeans/XmlObjectTestCase.java99
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsd136
-rwxr-xr-xsca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsdconfig21
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/databinding/pom.xml60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/pom.xml61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/pom.xml57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java48
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java103
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java155
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java204
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java143
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java500
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java129
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl52
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java82
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java101
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java72
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java105
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl26
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd136
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl58
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl76
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/pom.xml59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenArtifactRepository.java99
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java291
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyDependencyException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/WarRepositoryHelper.java116
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTestCase.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/WarRepositoryHelperTestCase.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/resources/webapp.warbin0 -> 443672 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/pom.xml70
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/src/main/java/org/apache/tuscany/service/persistence/common/PersistenceUnitProcessor.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/pom.xml62
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/Constants.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerFactoryImplementation.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerObjectFactory.java54
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerProcessor.java78
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/InvalidInjectionSite.java41
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAAtomicComponent.java73
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAComponentBuilder.java57
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAImportLoader.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/test/java/org/apache/tuscany/service/openjpa/EntityManagerProcessorTestCase.java128
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/persistence/pom.xml61
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/pom.xml68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/pom.xml68
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyLogger.java106
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyService.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java314
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/TransportMonitor.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java173
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/pom.xml46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java147
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/Bootstrapper.java105
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/SCATestCase.java137
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/TestLauncher.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBinding.java32
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingBuilder.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingLoader.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingRuntimeException.java42
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingService.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestInvoker.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBinding.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingBuilder.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingLoader.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingReference.java50
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingService.java143
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketInvoker.java141
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/system.scdl130
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/test.binding.system.scdl44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/test/src/test/java/org/apache/tuscany/test/SCATestCaseTestCase.java35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/pom.xml134
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/GenerationParameters.java435
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDL.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGenerator.java46
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorFactory.java89
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorImpl.java239
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java524
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java521
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLBuilder.java81
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLConstants.java51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLOptionsValidator.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanySchemaGenerator.java410
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyTypeTable.java225
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java373
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenEvent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenListener.java39
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/util/XMLNameUtil.java143
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceEmitter.java222
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java230
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/RemotableInterfaceWritter.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java63
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingTypeMappingEntry.java51
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java349
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/LICENSE.txt1277
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/NOTICE18
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/README.txt35
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/RemotableInterfaceTemplate.xsl116
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerValue.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerWithAccount.java49
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java108
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/account/Account.java53
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/customer/Customer.java30
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/extra/GoldCustomer.java36
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGeneratorTestCase.java44
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/CreditReport.java189
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/Customer.java315
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitFactory.java159
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitPackage.java808
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/soapinterop/CreditScoreDocLit.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/AccountService.wsdl242
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/helloworld.wsdl121
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/interopdoc.wsdl180
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/sequences.xsd100
1747 files changed, 171782 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/LICENSE.txt
new file mode 100644
index 0000000000..9ee90786ef
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/LICENSE.txt
@@ -0,0 +1,323 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/NOTICE.txt
new file mode 100644
index 0000000000..5b5354fd50
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/NOTICE.txt
@@ -0,0 +1,18 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/STATUS.txt b/sca-java-1.x/branches/sca-java-M2/samples/STATUS.txt
new file mode 100644
index 0000000000..7514d9eb05
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/STATUS.txt
@@ -0,0 +1,78 @@
+Apache Tuscany Status
+
+Tuscany provides multiple language implementations of the Service Component Architecture (SCA) specifications and related technologies such as SDO.
+
+PROJECT STATUS
+==============
+
+ Tuscany is being incubated at the request of the Apache Web Services PMC.
+ For information on incubation please visit the project page at
+ http://incubator.apache.org/projects/tuscany.html
+
+
+Pending Issues
+==============
+none
+
+RESOLVED ISSUES SINCE LAST STATUS
+=================================
+2005-12-28 CCLA received for IBM's contribution of a C++ implementation
+2005-12-28 CCLA received for BEA and IBM joint contribution of a Java implementation
+
+OTHER NEWS
+==========
+
+2006-11-07 Vote to add Rajith Attapattu
+2006-11-03 C++ Milestone 2 release
+2006-10-19 Voted to release pom and buildtools for Java M2 release
+2006-09-29 Vote to add Ignacio Silva-Lepe as a new committer
+2006-09-18 Vote to add Venkata Krishnan as a new committer
+2006-08-10 Vote to add Andrew Borley as a new committer
+2006-08-07 Vote to add Meeraj Kunnumpurath as a new committer
+2006-08-07 Vote to add Kelvin Goodson as a new committer
+2006-08-06 Vote to add Brent Daniel as a new committer
+2006-08-04 Vote to add Raymond Feng as a new committer
+2006-08-01 C++ Milestone 1 release
+2006-06-07 Java Milestone 1 release
+2006-05-02 Vote to add Dan Kulp as a new committer
+
+2006-01-05 Contribution of Java implementation by BEA and IBM committed
+2006-01-05 Contribution of C+ implementation by IBM committed
+
+RELEASE STATUS
+==============
+None
+
+REFERENCES
+==========
+Status file http://svn.apache.org/repos/asf/incubator/tuscany/STATUS
+User List tuscany-user@ws.apache.org
+Developer List tuscany-dev@ws.apache.org
+Commits List tuscany-commits@ws.apache.org
+Source Code http://svn.apache.org/repos/asf/incubator/tuscany/
+Issue Tracking http://issues.apache.org/jira/browse/TUSCANY
+
+Committers
+ ajborley Andrew Borley
+ antelder Ant Elder
+ bdaniel Brent Daniel
+ dkulp Dan Kulp
+ dims Davanum Srinivas
+ edslattery Ed Slattery
+ ekoneil Eddie O'Neil
+ frankb Frank Budinsky
+ geirm Geir Magnusson Jr
+ isilval Ignacio Silva-Lepe
+ jsdelfino Jean-Sebastien Delfino
+ jboynes Jeremy Boynes
+ jmarino Jim Marino
+ kelvingoodson Kelvin Goodson
+ kentam Ken Tam
+ kwilliams Kevin Williams
+ edwardsmj Mike Edwards
+ meerajk Meeraj Kunnumpurath
+ rajith Rajith Attapattu
+ rfeng Raymond Feng
+ robbinspg Pete Robbins
+ rineholt Rick Rineholt
+ svkrish Venkata Krishnan
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.pmd b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.pmd
new file mode 100644
index 0000000000..ffc4fe2bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.ruleset b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.ruleset
new file mode 100644
index 0000000000..ba9b5ce886
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/pom.xml
new file mode 100644
index 0000000000..b42e49baa6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/pom.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples.bigbank</groupId>
+ <artifactId>bigbank-scenario</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-bigbank-account</artifactId>
+ <packaging>war</packaging>
+ <name>Tuscany BigBank Account Module</name>
+ <description>BigBank Scenario - Account Management Module</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- java.xml.stream API -->
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- StAX implementation -->
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.das</groupId>
+ <artifactId>tuscany-das-rdb</artifactId>
+ <version>${dasVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.1.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>${sdoVersion}</version>
+ <executions>
+ <execution>
+ <configuration>
+ <!-- schemaFile>${basedir}/src/main/resources/wsdl/AccountService.wsdl</schemaFile -->
+ <schemaDir>${basedir}/src/main/resources/wsdl</schemaDir>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-plugin-wsdl2java</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <configuration>
+ <wsdlFiles>
+ <wsdlFile>
+ <fileName>${basedir}/src/main/resources/wsdl/stockquotes.webservicex.wsdl</fileName>
+ <ports>
+ <port>StockQuoteSoap</port>
+ </ports>
+ </wsdlFile>
+ <wsdlFile>
+ <fileName>${basedir}/src/main/resources/wsdl/AccountService.wsdl</fileName>
+ </wsdlFile>
+ </wsdlFiles>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Set to true to embed external jars for extensions in the WAR -->
+ <!-- Set to false to leave external jars for extensions to be resolved from maven repository -->
+ <loadExtensionDependencies>false</loadExtensionDependencies>
+
+ <extensions>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ </extensions>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..74baa636f5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package bigbank.account.services.account;
+
+import java.rmi.RemoteException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import bigbank.account.services.accountdata.AccountDataService;
+import bigbank.account.services.stockquote.StockQuote;
+import bigbank.account.services.stockquote.StockQuoteService;
+
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountService;
+import com.bigbank.account.AccountSummary;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+
+@Service(interfaces = AccountService.class)
+public class AccountServiceImpl implements AccountService {
+
+ public static final String CHECKING_ACCOUNT_PREFIX = "134-43-394";
+
+ public static final String SAVINGS_ACCOUNT_PREFIX = "134-42-623";
+
+ public static final String ACCOUNT_TYPE_SAVINGS = "savings";
+
+ public static final String ACCOUNT_TYPE_CHECKINGS = "checkings";
+
+ public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
+ static {
+ AccountServiceImpl.tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+ private float currencyConversion = 0.0f;
+
+ private String currency = "USD";
+
+ @Property
+ public void setCurrency(final String currency) {
+ this.currency = currency;
+ }
+
+ float getCurrencyConversion() {
+ if (currencyConversion == 0.0F) {
+ if ("USD".equals(currency)) {
+ currencyConversion = 1.0f;
+ } else if ("EURO".equals(currency)) {
+ currencyConversion = 0.8f;
+ } else {
+ try {
+ currencyConversion = Float.parseFloat(currency);
+ } catch (Exception e) {
+ currencyConversion = 1.0f;
+ }
+
+ }
+
+ }
+ return currencyConversion;
+
+ }
+
+ private AccountDataService accountDataService;
+
+ @Reference
+ public void setAccountDataService(AccountDataService accountDataService) {
+ this.accountDataService = accountDataService;
+ }
+
+ private StockQuoteService stockQuoteService;
+
+ @Reference
+ public void setStockQuoteService(StockQuoteService stockQuoteService) {
+ this.stockQuoteService = stockQuoteService;
+ }
+
+ public AccountServiceImpl() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public AccountReport getAccountReport(int customerID) throws RemoteException {
+
+ try {
+ AccountReport accountReport = accountDataService.getAccountReport(customerID);
+ // convert to local currency.
+ List<AccountSummary> accounts = accountReport.getAccountSummaries();
+ for (AccountSummary accountSummary : accounts) {
+ accountSummary.setBalance(fromUSDollarToCurrency(accountSummary.getBalance()));
+
+ }
+ return updateStockInformation(accountReport);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ } else {
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+ }
+
+ private AccountReport updateStockInformation(AccountReport accountReport) throws RemoteException {
+ List<StockSummary> stocks = accountReport.getStockSummaries();
+ if (stocks.size() < 1) {
+ return accountReport; // nothing todo
+ }
+ HashSet<String> owned = new HashSet<String>(stocks.size());
+ for (StockSummary stock : stocks) {
+ owned.add(stock.getSymbol());
+ }
+ ArrayList<String> ownedStr = new ArrayList<String>(owned.size() * 5);
+ for (String s : owned) {
+
+ ownedStr.add(s);
+ }
+
+ Map<String, StockQuote> stockInfo = stockQuoteService.getQuotes(ownedStr.toArray(new String[owned.size()]));
+
+ for (StockSummary stock : stocks) {
+ String symbol = stock.getSymbol();
+ StockQuote stockquote = stockInfo.get(symbol);
+ if (stockquote == null) {
+ stock.setCurrentPrice(Float.NaN);
+ stock.setCompany("*not found*");
+ stock.setHighPrice(Float.NaN);
+ stock.setLowPrice(Float.NaN);
+
+ } else {
+ stock.setCurrentPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getStockQuote())));
+ stock.setCompany(stockquote.getCompanyName());
+ stock.setHighPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getDayHighPrice())));
+ stock.setLowPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getDayLowPrice())));
+ }
+ }
+
+ return accountReport;
+ }
+
+ float convertToFloat(final String s) {
+
+ try {
+ return Float.parseFloat(s);
+ } catch (Exception e) {
+ return Float.NaN;
+ }
+
+ }
+
+ private float fromUSDollarToCurrency(float value) {
+ return value * getCurrencyConversion();
+
+ }
+
+ private float toUSDollarfromCurrency(float value) {
+
+ return value / getCurrencyConversion();
+ }
+
+ public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
+
+ try {
+ return accountDataService.getCustomerProfile(logonID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ } else {
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ }
+
+ public float deposit(String account, float ammount) throws RemoteException {
+ try {
+ return accountDataService.deposit(account, toUSDollarfromCurrency(ammount));
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException {
+ try {
+ String symbol = stock.getSymbol();
+ Map<String, StockQuote> stockInfo = stockQuoteService.getQuotes(new String[] { symbol });
+
+ StockQuote stockQuote = stockInfo.get(symbol);
+ stock.setPurchasePrice(Float.parseFloat(stockQuote.getStockQuote()));
+ String purchaseDate = tsformatXSDDateTime.format(new Date());
+ if (purchaseDate.endsWith("UTC")) {
+ purchaseDate = purchaseDate.substring(0, purchaseDate.length() - 3) + "Z";
+ }
+ stock.setPurchaseDate(purchaseDate);
+
+ return accountDataService.purchaseStock(id, stock);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
+ try {
+ return accountDataService.sellStock(purchaseLotNumber, quantity);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public float withdraw(String account, float ammount) throws RemoteException {
+ try {
+ return accountDataService.withdraw(account, toUSDollarfromCurrency(ammount));
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+ try {
+ return accountDataService.createAccount(customerProfile, createSavings, createCheckings);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public AccountLog getAccountLog(final int customerID) throws RemoteException {
+ return accountDataService.getAccountLog(customerID);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..884127cd9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param0*
+ * @param param1*
+ * @param param2
+ */
+ public com.bigbank.account.StockSummary purchaseStock(int param0, com.bigbank.account.StockSummary parm1) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param4
+ */
+ public com.bigbank.account.CustomerProfileData getCustomerProfile(java.lang.String param4) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param6*
+ * @param param7
+ */
+ public float deposit(java.lang.String param6, float param7) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param9*
+ * @param param10*
+ * @param param11
+ */
+ public com.bigbank.account.CustomerProfileData createAccount(com.bigbank.account.CustomerProfileData param9, boolean param10, boolean param11)
+ throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param13*
+ * @param param14
+ */
+ public com.bigbank.account.StockSummary sellStock(int param13, int param14) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param16*
+ * @param param17
+ */
+ public float withdraw(java.lang.String param16, float param17) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param19
+ */
+ public com.bigbank.account.AccountReport getAccountReport(int param19) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param0
+ */
+ public com.bigbank.account.AccountLog getAccountLog(int param0) throws java.rmi.RemoteException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
new file mode 100644
index 0000000000..c346a3221f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
@@ -0,0 +1,400 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountdata;
+
+import java.io.InputStream;
+import java.rmi.RemoteException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.Converter;
+import org.apache.tuscany.das.rdb.DAS;
+import org.osoa.sca.annotations.Service;
+
+import bigbank.account.services.account.AccountServiceImpl;
+
+import com.bigbank.account.AccountFactory;
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountSummary;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+import commonj.sdo.DataObject;
+
+@Service(CustomerIdService.class)
+public class AccountDataServiceDASImpl implements CustomerIdService { // TODO fix this!
+
+ static public String dbDirectory = null;
+
+ public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
+
+ public static final DateFormat sqlformatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSz");
+
+ static {
+ tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ }
+
+ public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
+
+ try {
+ InputStream mapping = createConfigStream();
+ Connection conn = getConnection();
+ DAS das = DAS.FACTORY.createDAS(mapping, conn);
+
+ Command select = das.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = ?");
+
+ select.setParameter(1, logonID);
+
+ DataObject root = select.executeQuery();
+ conn.close();
+
+ Collection customers = root.getList("CustomerProfileData");
+ CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next();
+
+ return customerProfileData;
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ RemoteException re = new RemoteException("Failed to get customer profile'" + logonID + "' ", e);
+ re.printStackTrace();
+ throw re;
+ }
+ }
+
+ protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+
+ protected static final String protocol = "jdbc:derby:";
+
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+
+ try {
+ DAS das = DAS.FACTORY.createDAS(getConnection());
+ Command insert = das.createCommand("insert into customers (firstName,lastName,address,email, loginID, password ) values ('"
+ + customerProfile.getFirstName() + "', '" + customerProfile.getLastName() + "', '" + customerProfile.getAddress() + "', '"
+ + customerProfile.getEmail() + "', '" + customerProfile.getLoginID() + "', '" + customerProfile.getPassword() + "')");
+
+ insert.execute();
+ CustomerProfileData ret = getCustomerProfile(customerProfile.getLoginID());
+ String cid = ret.getId() + "";
+ if (createSavings) {
+ insert = das.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '"
+ + AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_SAVINGS + "', " + 1.0F + ")");
+ insert.execute();
+
+ }
+ if (createCheckings) {
+ insert = das.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '"
+ + AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS + "', " + 1.0F + ")");
+ insert.execute();
+
+ }
+
+ return ret;
+ } catch (Exception e) {
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ }
+ throw new RemoteException("createAccount " + e.getClass().getName() + "'. " + e.getMessage(), e);
+ }
+ }
+
+ public CustomerProfileData createAccountNOTWORKING(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+ try {
+ DAS das = DAS.FACTORY.createDAS(createConfigStream(), getConnection());
+ Command read = das.getCommand("all customers");
+
+ // select.setDataObjectModel();
+ DataObject root = read.executeQuery();
+
+ // Create a new stockPurchase
+ DataObject customer = root.createDataObject("customerProfileData");
+
+ // THIS SEEMS TO BE THE ONLY WAY TO DO THIS .. NO WAY TO JUST ADD AN EXISTING CUSTOMER.
+ customer.set("firstName", customerProfile.getFirstName());
+ customer.set("lastName", customerProfile.getLastName());
+ customer.set("address", customerProfile.getAddress());
+ customer.set("email", customerProfile.getEmail());
+ customer.set("loginID", customerProfile.getLoginID());
+ customer.set("password", customerProfile.getPassword());
+
+ das.applyChanges(root);
+ return getCustomerProfile(customerProfile.getLoginID());
+
+ } catch (Exception e) {
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ }
+ throw new RemoteException("createAccount " + e.getClass().getName() + "'. " + e.getMessage(), e);
+ }
+
+ }
+
+ public AccountReport getAccountReport(final int customerID) throws RemoteException {
+ try {
+ final AccountFactory accountFactory = AccountFactory.INSTANCE;
+ final AccountReport accountReport = accountFactory.createAccountReport();
+ InputStream mapping = createConfigStream();
+
+ Connection conn = getConnection();
+ DAS das = DAS.FACTORY.createDAS(mapping, conn);
+
+ Command select = das.createCommand("SELECT accountNumber, accountType, balance FROM accounts where id = ?");
+ select.setParameter(1, customerID);
+
+ DataObject root = select.executeQuery();
+ accountReport.getAccountSummaries().addAll(root.getList("AccountSummary"));
+
+ // Get Stocks
+
+ select = das.createCommand("SELECT Symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id = ?");
+ select.setParameter(1, customerID);
+
+ // select.addConverter("STOCKS.PURCHASEDATE", DateConverter.class.getName());
+
+ root = select.executeQuery();
+ accountReport.getStockSummaries().addAll(root.getList("StockSummary"));
+
+ conn.close();
+
+ return accountReport;
+ } catch (Exception e) {
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ }
+ throw new RemoteException("getAccountReport failed. customerID ('" + customerID + "')" + e.getClass().getName() + "'. " + e.getMessage(),
+ e);
+ }
+ }
+
+ public float withdraw(String account, float ammount) throws RemoteException {
+
+ return deposit(account, -ammount);
+ }
+
+ public float deposit(String account, float ammount) throws RemoteException {
+
+ try {
+ Connection conn = getConnection();
+ DAS das = DAS.FACTORY.createDAS(createConfigStream(), conn);
+
+ Command select = das.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = ?");
+ select.setParameter(1, account);
+
+ DataObject root = select.executeQuery();
+ Collection accounts = root.getList("AccountSummary");
+ AccountSummary accountData = (AccountSummary) accounts.iterator().next();
+ float newbalance = accountData.getBalance() + ammount;
+ accountData.setBalance(newbalance);
+ // update department set companyid = ? where department.name = ?
+
+ Command update = das.getCommand("update balance");
+ update.setParameter(1, new Float(newbalance));
+ update.setParameter(2, account);
+ update.execute();
+ conn.close();
+ return newbalance;
+ } catch (Exception e) {
+ throw new RemoteException(e.getClass().getName(), e);
+ }
+
+ }
+
+ public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
+ try {
+ DAS das = DAS.FACTORY.createDAS(createConfigStream(), getConnection());
+
+ Command read = das.getCommand("stockbylotSelect");
+ read.setParameter(1, purchaseLotNumber);// autoboxing :-)
+ DataObject root = read.executeQuery();
+ List stocks = root.getList("StockSummary");
+ if (null != stocks && !stocks.isEmpty()) {
+ StockSummary stock = (StockSummary) stocks.get(0);
+ int newQuatity = Math.max(stock.getQuantity() - quantity, 0);
+ if (newQuatity < 1) {
+
+ Command delete = das.createCommand("DELETE FROM STOCKS WHERE PURCHASELOTNUMBER = ?");
+ delete.setParameter(1, purchaseLotNumber);
+ delete.execute();
+
+ } else {
+
+ Command update = das.getCommand("stockbylot");
+
+ update.setParameter(1, newQuatity);
+ update.setParameter(2, purchaseLotNumber);
+ update.execute();
+
+ stock.setQuantity(newQuatity);
+ }
+ return stock;
+ }
+
+ return null;
+ } catch (Exception e) {
+ throw new RemoteException("sellStock", e);
+ }
+ }
+
+ public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException {
+
+ try {
+ DAS das = DAS.FACTORY.createDAS(getConnection());
+ Command insert = das.createCommand("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate) values (?,?,?,?,?)");
+ insert.setParameter(1, new Integer(id));
+ insert.setParameter(2, stock.getSymbol());
+ insert.setParameter(3, stock.getQuantity());
+ insert.setParameter(4, stock.getPurchasePrice());
+ insert.setParameter(5, DateConverter.INSTANCE.getColumnValue(stock.getPurchaseDate()));
+
+ insert.execute();
+
+ return stock;
+ } catch (Exception e) {
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ }
+ throw new RemoteException("purchaseStock " + e.getClass().getName() + "'. " + e.getMessage(), e);
+ }
+ }
+
+ protected Connection getConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
+ Connection conn;
+ Class.forName(driver).newInstance();
+ Properties props = new Properties();
+ // props.put("user", "tuscany");
+ // props.put("password", "tuscany");
+ conn = DriverManager.getConnection(protocol + dbDirectory + ";create=true", props);
+
+ conn.setAutoCommit(false);
+ return conn;
+ }
+
+ protected InputStream createConfigStream() {
+ InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml");
+ return mapping;
+ }
+
+ public static class DateConverter implements Converter {
+ public final static DateConverter INSTANCE = new DateConverter();
+
+ public DateConverter() { // public empty constructor
+ }
+
+ public Object getPropertyValue(Object columnData) {
+
+ try {
+
+ String ret = tsformatXSDDateTime.format(columnData);
+ if (ret.endsWith("UTC")) {
+ ret = ret.substring(0, ret.length() - 3) + "Z";
+ }
+ return ret;
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ throw new IllegalArgumentException(e);
+ }
+
+ }
+
+ public Object getColumnValue(Object propertyData) {
+
+ if (propertyData instanceof java.util.Date) {
+ // Need to convert back to local time for DB and remove timezone notation at the end..
+ String ret = sqlformatDateTime.format(propertyData);
+ char lc = ret.charAt(ret.length() - 1);
+ while (!Character.isDigit(lc)) {
+ ret = ret.substring(0, ret.length() - 1);
+ lc = ret.charAt(ret.length() - 1);
+ }
+ return ret;
+ } else if (propertyData instanceof String) {
+
+ try {
+ String time = (String) propertyData;
+ char last = time.charAt(time.length() - 1);
+ if (last == 'z' || last == 'Z') {
+ time = time.substring(0, time.length() - 1);
+ }
+ if (!time.endsWith("UTC")) {
+ time = time + "UTC";
+ }
+ return getColumnValue(tsformatXSDDateTime.parse(time));
+ } catch (ParseException e) {
+ throw new IllegalArgumentException("'" + propertyData + "' does not parse to date.");
+ }
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ }
+
+ }
+
+ public int getCustomerIdByPurchaseLotNumber(int purchaseLotNumber) throws RemoteException {
+
+ return queryCustomerId("select id from stocks where purchaseLotNumber = " + purchaseLotNumber);
+ }
+
+ public int getCustomerIdByAccount(String account) throws RemoteException {
+
+ return queryCustomerId("select id from accounts where accountNumber = '" + account + "'");
+ }
+
+ private int queryCustomerId(String query) throws RemoteException {
+
+ try {
+ Connection conn = getConnection();
+
+ Statement s = conn.createStatement();
+
+ ResultSet rs = s.executeQuery(query);
+ int id = -1;
+ if (rs.next()) {
+ id = rs.getInt("id");
+ }
+
+ conn.commit();
+
+ rs.close();
+ s.close();
+ conn.close();
+
+ return id;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass().getName(), e);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..5e08cf634f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountdata;
+
+import java.rmi.RemoteException;
+import java.util.List;
+
+import org.osoa.sca.annotations.Service;
+
+import com.bigbank.account.AccountFactory;
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountSummary;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+
+@Service(AccountDataService.class)
+public class AccountDataServiceImpl implements AccountDataService {
+
+ public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public AccountReport getAccountReport(int customerID) {
+ final AccountFactory accountFactory = AccountFactory.INSTANCE;
+ AccountReport accountReport = accountFactory.createAccountReport();
+ List accounts = accountReport.getAccountSummaries();
+
+ AccountSummary account = accountFactory.createAccountSummary();
+ account.setAccountType("1111");
+ account.setAccountNumber("22-22-22");
+ account.setBalance(123.45F);
+ accounts.add(account);
+
+ account = accountFactory.createAccountSummary();
+ account.setAccountType("04-11-19");
+ account.setAccountNumber("11-23");
+ account.setBalance(543.21F);
+ accounts.add(account);
+
+ List stocks = accountReport.getStockSummaries();
+ StockSummary stock = accountFactory.createStockSummary();
+ stock.setSymbol("IBM");
+ stock.setPurchaseDate("1999-11-23");
+ stock.setPurchaseLotNumber(101);
+ stock.setPurchasePrice(33.33F);
+ stock.setQuantity(10);
+ stocks.add(stock);
+
+ stock = accountFactory.createStockSummary();
+ stock.setSymbol("TUSK");
+ stock.setPurchaseDate("2005-01-05");
+ stock.setPurchaseLotNumber(102);
+ stock.setPurchasePrice(11.11F);
+ stock.setQuantity(4);
+ stocks.add(stock);
+ return accountReport;
+ }
+
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public float deposit(String param6, float param7) throws RemoteException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public StockSummary purchaseStock(int param0, StockSummary stock) throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public StockSummary sellStock(int param13, int param14) throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public float withdraw(String param16, float param17) throws RemoteException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public AccountLog getAccountLog(final int customerID) throws RemoteException {
+ throw new RemoteException("This method should not be called");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java
new file mode 100644
index 0000000000..b355a09008
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountdata;
+
+import java.rmi.RemoteException;
+
+/**
+ * This interface allows access to a customer's id from the data service.
+ */
+public interface CustomerIdService {
+
+ /*
+ * Return -1 if purchaseLotNumber not found
+ */
+ public int getCustomerIdByPurchaseLotNumber(int purchaseLotNumber) throws RemoteException;
+
+ /*
+ * Return -1 if account not found
+ */
+ public int getCustomerIdByAccount(String account) throws RemoteException;
+
+ // TODO (isilval) Fix this !!!
+ // Apparently, configuration can't deal with extends so I am adding the contents of AccountDataService here
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param0*
+ * @param param1*
+ * @param param2
+ */
+ public com.bigbank.account.StockSummary purchaseStock(int param0, com.bigbank.account.StockSummary parm1) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param4
+ */
+ public com.bigbank.account.CustomerProfileData getCustomerProfile(java.lang.String param4) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param6*
+ * @param param7
+ */
+ public float deposit(java.lang.String param6, float param7) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param9*
+ * @param param10*
+ * @param param11
+ */
+ public com.bigbank.account.CustomerProfileData createAccount(com.bigbank.account.CustomerProfileData param9, boolean param10, boolean param11)
+ throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param13*
+ * @param param14
+ */
+ public com.bigbank.account.StockSummary sellStock(int param13, int param14) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param16*
+ * @param param17
+ */
+ public float withdraw(java.lang.String param16, float param17) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ *
+ * @param param19
+ */
+ public com.bigbank.account.AccountReport getAccountReport(int param19) throws java.rmi.RemoteException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
new file mode 100644
index 0000000000..1225c95f84
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
@@ -0,0 +1,465 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountdb;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.Converter;
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.das.rdb.config.ConfigFactory;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import bigbank.account.services.account.AccountServiceImpl;
+import bigbank.account.services.accountdata.AccountDataServiceDASImpl;
+import bigbank.account.services.accountlogger.AccountLoggerServiceImpl;
+
+import com.bigbank.account.AccountFactory;
+import com.bigbank.account.AccountSummary;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+import commonj.sdo.DataObject;
+import com.bigbank.account.purchaseStock;
+import com.bigbank.account.withdraw;
+
+public class AccountDBInit extends HttpServlet {
+
+ private static final long serialVersionUID = -4795999792460944805L;
+
+ protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+
+ protected static final String protocol = "jdbc:derby:";
+
+ protected String dbDirectory = null;
+
+ protected String dasConfigFile = null;
+
+ boolean deleteExisting = false;
+
+ @Override
+ public void init() throws ServletException {
+ try {
+
+ registerTypes();
+ ServletConfig servletConfig = getServletConfig();
+ ServletContext servletContext = servletConfig.getServletContext();
+ dbDirectory = servletContext.getRealPath("WEB-INF/bigbankdb/accounts");
+ dasConfigFile = servletContext.getRealPath("WEB-INF/classes/DasAccountConfiguration.xml");
+ deleteExisting = false;
+
+ createDB(dbDirectory);
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ log(e.toString(), e);
+ throw new ServletException(e);
+ }
+ }
+
+ /*
+ * (non-Java-doc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest arg0, HttpServletResponse arg1)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/html");
+
+ PrintWriter out = response.getWriter();
+
+ out.println();
+ out.println("<center><h2>BigBank database initialization servlet !<h2></center>");
+ out.println();
+ }
+
+ public AccountDBInit() {
+ }
+
+ public AccountDBInit(String dbDirectory, String dasConfigFile, Boolean deleteExisting) {
+ this.dbDirectory = dbDirectory;
+ this.dasConfigFile = dasConfigFile;
+ this.deleteExisting = deleteExisting;
+ }
+
+ private Connection createConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
+ return createConnection(dbDirectory);
+ }
+
+ private static Connection createConnection(final String location) throws InstantiationException, IllegalAccessException, ClassNotFoundException,
+ SQLException {
+ Connection conn;
+ Class.forName(driver).newInstance();
+ Properties props = new Properties();
+ conn = DriverManager.getConnection(protocol + location + ";create=true", props);
+
+ conn.setAutoCommit(false);
+ return conn;
+ }
+
+ public static void createDB(final String location) throws Exception {
+ Connection conn = null;
+ AccountDataServiceDASImpl.dbDirectory = location;
+ AccountLoggerServiceImpl.dbDirectory = location; // TODO get rid of this (isilval)
+ Exception processessingException = null;
+ try {
+ conn = createConnection(location);
+
+ creatTables(conn);
+
+ int id = createCustomer(conn, "Test", "User", "304 Fox Trot ln, Apex, NC", "test@das.org", "test", "password");
+ createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 123.43F);
+ createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 23.12F);
+ createStockPurchase(conn, id, "IBM", 33, 66.20F, "2005-11-23 13:22:02");
+ createStockPurchase(conn, id, "DELL", 13, 12.74F, "2003-01-03 11:04:03");
+ createStockPurchase(conn, id, "LU", 7, 2.74F, "2003-01-04 16:04:03");
+ createStockPurchase(conn, id, "IBM", 22, 81.43F, "2004-02-03 13:04:33");
+
+ id = createCustomer(conn, "test2", "demo2", "Pleasant Plains Rd, ViewMount, CO", "test2@das.org", "test2", "password");
+ createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 924.40F);
+ createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 33.26F);
+ createStockPurchase(conn, id, "FOO", 3, 6.20F, "2000-09-11 09:11:01");
+
+ conn.commit();
+
+ } catch (org.apache.derby.impl.jdbc.EmbedSQLException e) {
+ if (conn != null && !conn.isClosed()) {
+ conn.rollback();
+ }
+ if (e.getErrorCode() == 20000 && "X0Y32".equalsIgnoreCase(e.getSQLState()) && -1 != e.getMessage().indexOf("already exists")) {
+ // this is ok the database is there.
+
+ } else {
+
+ e.printStackTrace();
+ processessingException = e;
+ throw e;
+ }
+ } finally {
+ try {
+ if (null != conn && !conn.isClosed()) {
+
+ conn.close();
+ }
+ conn = null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (null != processessingException) {
+ throw e;
+ }
+ }
+ }
+
+ }
+
+ protected static void creatTables(Connection conn) throws Exception {
+ Statement s = conn.createStatement();
+
+ s
+ .execute("create table customers(firstName varchar(80) NOT NULL, lastName varchar(80), address varchar(180),email varchar(40),loginID varchar(80) NOT NULL UNIQUE, password varchar(80), id int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY)");
+
+ s.execute("create table accounts(id int NOT NULL, accountNumber varchar(80) NOT NULL UNIQUE, accountType varchar(80), balance real )");
+
+ s
+ .execute("create table stocks(id int NOT NULL, Symbol varchar(8) NOT NULL, quantity int NOT NULL, purchasePrice real NOT NULL, purchaseDate TIMESTAMP, purchaseLotNumber int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY )");
+
+ s
+ .execute("create table acctLog (logSeqNo int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY, id int NOT NULL, accountNumber varchar(80) NOT NULL, actionType varchar(32) NOT NULL, amount real )");
+
+ s
+ .execute("create table stockLog (logSeqNo int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY, id int NOT NULL, Symbol varchar(8) NOT NULL, quantity int NOT NULL, actionType varchar(32) NOT NULL, purchaseLotNumber int NOT NULL )");
+
+ s.close();
+ }
+
+ protected static int createCustomer(Connection conn, final String firstName, final String lastName, final String address, final String email,
+ final String logonID, final String password) throws SQLException, Exception {
+ Statement s = conn.createStatement();
+
+ s.execute("insert into customers (firstName,lastName,address,email, loginID, password ) " + "values ('" + firstName + "', '" + lastName
+ + "', '" + address + "', '" + email + "', '" + logonID + "', '" + password + "')");
+
+ ResultSet rs = s.executeQuery("SELECT loginID, id FROM customers where loginID='" + logonID + "'");
+ if (!rs.next()) {
+ throw new Exception("Wrong number of rows");
+ }
+ int id = rs.getInt(2);
+ s.close();
+
+ return id;
+ }
+
+ protected static void createAccount(Connection conn, int customerID, final String accountNumber, final String accountType, final float balance)
+ throws SQLException, Exception {
+ Statement s = conn.createStatement();
+
+ s.execute("insert into accounts (id,accountNumber, accountType, balance ) " + "values (" + customerID + ", '" + accountNumber + "', '"
+ + accountType + "', " + balance + ")");
+
+ s.close();
+ }
+
+ protected InputStream createConfigStream() {
+ InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml");
+ return mapping;
+ }
+
+ protected static void createStockPurchase(Connection conn, int customerID, final String stockSymbol, final int quantity,
+ final float purchasePrice, String purchaseDate) throws SQLException, Exception {
+ Statement s = conn.createStatement();
+
+ s.execute("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate ) values (" + customerID + ", '" + stockSymbol + "', "
+ + quantity + ", " + purchasePrice + ", '" + purchaseDate + "')");
+
+ s.close();
+
+ }
+
+ protected static void registerTypes() {
+ SDOUtil.registerStaticTypes(AccountFactory.class);
+ // TODO remove
+ SDOUtil.registerStaticTypes(ConfigFactory.class);
+
+ }
+
+ public void testWithdrawThroughDAS(withdraw wd) throws Exception {
+
+ Connection conn = createConnection();
+ DAS das = DAS.FACTORY.createDAS(createConfigStream(), conn);
+ Command select = das.getCommand("get account");
+
+ select.setParameter(1, wd.getAccountNumber());
+
+ DataObject root = select.executeQuery();
+
+ Collection accounts = root.getList("AccountSummary");
+ AccountSummary account = (AccountSummary) accounts.iterator().next();
+ float newbalance = account.getBalance() - wd.getAmount();
+ account.setBalance(newbalance);
+ // update department set companyid = ? where department.name = ?
+
+ Command update = das.getCommand("update balance");
+ update.setParameter(1, new Float(newbalance));
+ update.setParameter(2, wd.getAccountNumber());
+
+ update.execute();
+ conn.close();
+ }
+
+ protected void testStrockPurchaseThroughDAS(purchaseStock sp) throws InstantiationException, IllegalAccessException, ClassNotFoundException,
+ SQLException {
+
+ DAS das = DAS.FACTORY.createDAS(createConfigStream(), createConnection());
+ Command read = das.getCommand("all stocks");
+
+ DataObject root = read.executeQuery();
+
+ // Create a new stockPurchase
+ DataObject stockPurchase = root.createDataObject("StockSummary");
+ stockPurchase.set("id", new Integer(sp.getId()));
+ stockPurchase.set("symbol", sp.getStock().getSymbol());
+ stockPurchase.set("quantity", new Integer(sp.getStock().getQuantity()));
+ stockPurchase.set("purchasePrice", new Float(11.00));
+ // String type = stockPurchase.getType().getProperty("purchaseDate").getType().toString();
+ stockPurchase.setDate("purchaseDate", new Date());
+
+ das.applyChanges(root);
+ }
+
+ public CustomerProfileData testgetCustomerByLoginIDThroughDASRead(final String logonID) throws Exception {
+ InputStream mapping = createConfigStream();
+ Connection conn = createConnection();
+ DAS das = DAS.FACTORY.createDAS(mapping, conn);
+ Command select = das.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = ?");
+
+ select.setParameter(1, logonID);
+
+ DataObject root = select.executeQuery();
+ conn.close();
+
+ Collection customers = root.getList("CustomerProfileData");
+ CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next();
+ System.out.println(customerProfileData);
+ System.out.flush();
+ return customerProfileData;
+
+ }
+
+ protected void readDBstdout(PrintStream stream) throws Exception {
+ Connection conn = null;
+ try {
+ conn = createConnection(dbDirectory);
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("SELECT firstName, lastName, loginID, password, id FROM customers ORDER BY lastName");
+ while (rs.next()) {
+ stream.print(rs.getString(1));
+ stream.print(" ");
+ stream.print(rs.getString(2));
+ stream.print(" ");
+ stream.print(rs.getString(3));
+ stream.print(" ");
+ stream.print(rs.getString(4));
+ stream.print(" ");
+ stream.print(rs.getString(5));
+ stream.println();
+ int id = rs.getInt(5);
+ Statement s1 = conn.createStatement();
+ ResultSet rs1 = s1.executeQuery("SELECT accountNumber, accountType, balance FROM accounts where id=" + id);
+ stream.println("====Customers accounts");
+ while (rs1.next()) {
+ stream.print("\t");
+ stream.print(rs1.getString(1));
+ stream.print(" ");
+ stream.print(rs1.getString(2));
+ stream.print(" ");
+ stream.print(rs1.getString(3));
+ stream.println();
+ }
+ rs1.close();
+ rs1 = s1.executeQuery("SELECT symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id=" + id);
+ stream.println("====Customers Stocks");
+ while (rs1.next()) {
+ stream.print("\t");
+ stream.print(rs1.getString(1));
+ stream.print(" ");
+ stream.print(rs1.getString(2));
+ stream.print(" ");
+ stream.print(rs1.getString(3));
+ stream.print(" ");
+ stream.print(rs1.getString(4));
+ stream.print(" ");
+ stream.print(rs1.getString(5));
+ stream.println();
+ }
+ s1.close();
+ stream.println();
+
+ }
+ s.close();
+ conn.commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (conn != null) {
+ conn.close();
+ }
+ conn = null;
+ }
+
+ }
+
+ public static class MyDateConverter implements Converter {
+
+ private static final DateFormat tsformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+
+ public Object getPropertyValue(Object columnData) {
+
+ try {
+ return tsformat.parse(columnData.toString());
+ } catch (ParseException e) {
+
+ e.printStackTrace();
+ throw new IllegalArgumentException(e);
+ }
+
+ }
+
+ public Object getColumnValue(Object propertyData) {
+
+ if (propertyData instanceof Date) {
+ return tsformat.format(propertyData);
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ }
+
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception {
+ registerTypes();
+ String dbDirectory = null; // "c:/derbydbtest/foo";
+ String dasConfigFile = null;
+ Boolean deleteExisting = false;
+ for (String x : args) {
+ if ("-d".equals(x)) {
+ deleteExisting = true;
+ }
+ if (x.startsWith("-db:")) {
+ dbDirectory = x.substring("-db:".length());
+ }
+ if (x.startsWith("-config:")) {
+ dasConfigFile = x.substring("-config:".length());
+ ;
+ }
+
+ }
+ AccountDBInit accountDBInit = new AccountDBInit(dbDirectory, dasConfigFile, deleteExisting);
+
+ createDB(dbDirectory);
+
+ accountDBInit.readDBstdout(System.out);
+
+ // Test withdrawl
+ withdraw wd = AccountFactory.INSTANCE.createwithdraw();
+ wd.setAccountNumber("134-43-3942");
+ wd.setAmount(1.00F);
+ accountDBInit.testWithdrawThroughDAS(wd);
+
+ accountDBInit.readDBstdout(System.out);
+
+ // test stock purchase.
+ purchaseStock sp = AccountFactory.INSTANCE.createpurchaseStock();
+ StockSummary stock = AccountFactory.INSTANCE.createStockSummary();
+ stock.setSymbol("GOOG");
+ stock.setQuantity(10);
+ stock.setPurchasePrice(25.00F);
+ sp.setId(1);
+ sp.setStock(stock);
+
+ accountDBInit.testStrockPurchaseThroughDAS(sp);
+
+ accountDBInit.readDBstdout(System.out);
+
+ System.out.flush();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java
new file mode 100644
index 0000000000..2360344cd1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountlogger;
+
+import java.rmi.RemoteException;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import bigbank.account.services.accountdata.AccountDataService;
+import bigbank.account.services.accountdata.CustomerIdService;
+
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+
+/**
+ * This class implements the Account Data Logger service component.
+ */
+@Service(AccountDataService.class)
+public class AccountLoggerDataServiceImpl implements AccountDataService {
+
+ private CustomerIdService accountDataService; // TODO fix this!
+
+ @Reference
+ public void setAccountDataService(CustomerIdService accountDataService) {
+ this.accountDataService = accountDataService;
+ }
+
+ private AccountLoggerService accountLoggerService;
+
+ @Reference
+ public void setAccountLoggerService(AccountLoggerService accountLoggerService) {
+ this.accountLoggerService = accountLoggerService;
+ }
+
+ public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException {
+ accountLoggerService.logPurchaseStock(id, stock);
+
+ return accountDataService.purchaseStock(id, stock);
+ }
+
+ public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
+
+ return accountDataService.getCustomerProfile(logonID);
+ }
+
+ public float deposit(String account, float amount) throws RemoteException {
+ try {
+ if (!(accountDataService instanceof CustomerIdService)) {
+ throw new RemoteException("Can't use data service as customer id service");
+ }
+ int id = accountDataService.getCustomerIdByAccount(account);
+ // int id = accountDataService.getCustomerIdByAccount(account);
+ accountLoggerService.logDeposit(id, account, amount);
+
+ return accountDataService.deposit(account, amount);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createChecking)
+ throws RemoteException {
+
+ return accountDataService.createAccount(customerProfile, createSavings, createChecking);
+ }
+
+ public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
+ try {
+ int id = accountDataService.getCustomerIdByPurchaseLotNumber(purchaseLotNumber);
+ StockSummary ss = accountDataService.sellStock(purchaseLotNumber, quantity);
+ if (ss != null) {
+ if (!(accountDataService instanceof CustomerIdService)) {
+ throw new RemoteException("Can't use data service as customer id service");
+ }
+ accountLoggerService.logSellStock(id, ss, quantity);
+ }
+ return ss;
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+ }
+
+ public float withdraw(String account, float amount) throws RemoteException {
+ if (!(accountDataService instanceof CustomerIdService)) {
+ throw new RemoteException("Can't use data service as customer id service");
+ }
+ int id = accountDataService.getCustomerIdByAccount(account);
+ // int id = accountDataService.getCustomerIdByAccount(account);
+ accountLoggerService.logWithdrawal(id, account, amount);
+
+ return accountDataService.withdraw(account, amount);
+ }
+
+ public AccountReport getAccountReport(final int customerID) throws RemoteException {
+
+ return accountDataService.getAccountReport(customerID);
+ }
+
+ public AccountLog getAccountLog(final int customerID) throws RemoteException {
+ return accountLoggerService.getAccountLog(customerID);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java
new file mode 100644
index 0000000000..b9b2821d38
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountlogger;
+
+import java.rmi.RemoteException;
+
+import org.osoa.sca.annotations.OneWay;
+
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.StockSummary;
+
+/**
+ * This is the business interface of the Account Logger service component.
+ */
+public interface AccountLoggerService {
+
+ @OneWay
+ public void logDeposit(int id, String account, float amount) throws RemoteException;
+
+ @OneWay
+ public void logWithdrawal(int id, String account, float amount) throws RemoteException;
+
+ @OneWay
+ public void logPurchaseStock(int id, StockSummary stock) throws RemoteException;
+
+ @OneWay
+ public void logSellStock(int id, StockSummary stock, int quantity) throws RemoteException;
+
+ public AccountLog getAccountLog(int id) throws RemoteException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java
new file mode 100644
index 0000000000..8919aad311
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.accountlogger;
+
+import java.io.InputStream;
+import java.rmi.RemoteException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.DAS;
+import org.osoa.sca.annotations.Service;
+
+import com.bigbank.account.AccountFactory;
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.StockSummary;
+import commonj.sdo.DataObject;
+
+/**
+ * This class implements the Account Logger service component.
+ */
+@Service(AccountLoggerService.class)
+public class AccountLoggerServiceImpl implements AccountLoggerService {
+
+ public static final String ACCT_ACTION_TYPE_DEPOSIT = "deposit";
+
+ public static final String ACCT_ACTION_TYPE_WITHDRAW = "withdraw";
+
+ public static final String STOCK_ACTION_TYPE_PURCHASE = "purchase";
+
+ public static final String STOCK_ACTION_TYPE_SELL = "sell";
+
+ static public String dbDirectory = null;
+
+ protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+
+ protected static final String protocol = "jdbc:derby:";
+
+ public void logDeposit(int id, String account, float amount) throws RemoteException {
+ DAS das = DAS.FACTORY.createDAS(getConnection());
+ Command insert = das.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)");
+ insert.setParameter(1, new Integer(id));
+ insert.setParameter(2, account);
+ insert.setParameter(3, ACCT_ACTION_TYPE_DEPOSIT);
+ insert.setParameter(4, new Float(amount));
+
+ insert.execute();
+ /*
+ * performLog("insert into acctLog (id, accountNumber, actionType, amount) values (" + id + ", '" + account + "', '" +
+ * ACCT_ACTION_TYPE_DEPOSIT + "', " + amount + ")");
+ */
+ }
+
+ public void logWithdrawal(int id, String account, float amount) throws RemoteException {
+ DAS das = DAS.FACTORY.createDAS(getConnection());
+ Command insert = das.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)");
+ insert.setParameter(1, new Integer(id));
+ insert.setParameter(2, account);
+ insert.setParameter(3, ACCT_ACTION_TYPE_WITHDRAW);
+ insert.setParameter(4, new Float(amount));
+
+ insert.execute();
+ /*
+ * performLog("insert into acctLog (id ,accountNumber, actionType, amount) values (" + id + ", '" + account + "', '" +
+ * ACCT_ACTION_TYPE_WITHDRAW + "', " + amount + ")");
+ */
+ }
+
+ public void logPurchaseStock(int id, StockSummary stock) throws RemoteException {
+ DAS das = DAS.FACTORY.createDAS(getConnection());
+ Command insert = das.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)");
+ insert.setParameter(1, new Integer(id));
+ insert.setParameter(2, stock.getSymbol());
+ insert.setParameter(3, new Integer(stock.getQuantity()));
+ insert.setParameter(4, STOCK_ACTION_TYPE_PURCHASE);
+ insert.setParameter(5, new Integer(stock.getPurchaseLotNumber()));
+
+ insert.execute();
+ /*
+ * performLog("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (" + id + ", '" + stock.getSymbol() + "', " +
+ * stock.getQuantity() + ", '" + STOCK_ACTION_TYPE_PURCHASE + ", " + stock.getPurchaseLotNumber() + ")");
+ */
+ }
+
+ public void logSellStock(int id, StockSummary stock, int quantity) throws RemoteException {
+
+ String symbol = ((stock.getSymbol() != null) ? stock.getSymbol() : "null");
+ DAS das = DAS.FACTORY.createDAS(getConnection());
+ Command insert = das.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)");
+ insert.setParameter(1, new Integer(id));
+ insert.setParameter(2, symbol);
+ insert.setParameter(3, new Integer(quantity));
+ insert.setParameter(4, STOCK_ACTION_TYPE_SELL);
+ insert.setParameter(5, new Integer(stock.getPurchaseLotNumber()));
+
+ insert.execute();
+ /*
+ * performLog("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (" + id + ", '" + stock.getSymbol() + "', " +
+ * quantity + ", '" + STOCK_ACTION_TYPE_SELL + ", " + stock.getPurchaseLotNumber() + ")");
+ */
+ }
+
+ private void performLog(String toLog) throws RemoteException {
+
+ try {
+ Connection conn = getConnection();
+
+ Statement s = conn.createStatement();
+
+ s.execute(toLog);
+
+ conn.commit();
+
+ System.out.println("SN id acctNo action amount");
+ ResultSet rs = s.executeQuery("select * from acctLog");
+ while (rs.next()) {
+ System.out.println(rs.getInt("logSeqNo") + " " + rs.getInt("id") + " " + rs.getString("accountNumber") + " "
+ + rs.getString("actionType") + " " + rs.getFloat("amount"));
+ }
+
+ conn.commit();
+
+ System.out.println("SN Symbol qty action plot#");
+ rs = s.executeQuery("select * from stockLog");
+ while (rs.next()) {
+ System.out.println(rs.getInt("logSeqNo") + " " + rs.getString("Symbol") + " " + rs.getInt("quantity") + " "
+ + rs.getString("actionType") + " " + rs.getInt("purchaseLotNumber"));
+ }
+
+ conn.commit();
+
+ s.close();
+
+ conn.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass().getName(), e);
+ }
+
+ System.out.println("Logged " + toLog);
+ }
+
+ protected Connection getConnection() throws RemoteException {
+ try {
+ Connection conn;
+ Class.forName(driver).newInstance();
+ Properties props = new Properties();
+ // props.put("user", "tuscany");
+ // props.put("password", "tuscany");
+ conn = DriverManager.getConnection(protocol + dbDirectory + ";create=true", props);
+
+ conn.setAutoCommit(false);
+ return conn;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass().getName(), e);
+ }
+ }
+
+ public AccountLog getAccountLog(final int customerID) throws RemoteException {
+
+ try {
+ final AccountFactory accountFactory = AccountFactory.INSTANCE;
+ final AccountLog accountLog = accountFactory.createAccountLog();
+ InputStream mapping = createConfigStream();
+
+ Connection conn = getConnection();
+ DAS das = DAS.FACTORY.createDAS(mapping, conn);
+ Command select = das.createCommand("SELECT logSeqNo, accountNumber, actionType, amount FROM acctLog where id = ?");
+
+ select.setParameter(1, customerID);
+
+ DataObject root = select.executeQuery();
+ accountLog.getAccountLogEntries().addAll(root.getList("AccountLogEntry"));
+
+ select = das.createCommand("SELECT logSeqNo, Symbol, quantity, actionType, purchaseLotNumber FROM stockLog where id = ?");
+ select.setParameter(1, customerID);
+ root = select.executeQuery();
+ accountLog.getStockLogEntries().addAll(root.getList("StockLogEntry"));
+
+ conn.close();
+
+ return accountLog;
+ } catch (Exception e) {
+ if (e instanceof RemoteException) {
+ throw (RemoteException) e;
+ }
+ throw new RemoteException("getAccountLog failed. customerID ('" + customerID + "')" + e.getClass().getName() + "'. " + e.getMessage(), e);
+ }
+ }
+
+ protected InputStream createConfigStream() {
+ InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml");
+ return mapping;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java
new file mode 100644
index 0000000000..c7498f093d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.stockquote;
+
+public class StockQuote {
+
+ private String companyName;
+
+ private String symbol;
+
+ private String stockQuote;
+
+ private String lastUpdated;
+
+ private String change;
+
+ private String openPrice;
+
+ private String dayHighPrice;
+
+ private String dayLowPrice;
+
+ private String volume;
+
+ private String marketCap;
+
+ private String yearRange;
+
+ private String exDividendDate;
+
+ private String dividendYield;
+
+ private String dividendPerShare;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected StockQuote() {
+ super();
+ }
+
+ public String getCompanyName() {
+ return companyName;
+ }
+
+ public void setCompanyName(String newCompanyName) {
+ companyName = newCompanyName;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String newStockTicker) {
+ symbol = newStockTicker;
+ }
+
+ public String getStockQuote() {
+ return stockQuote;
+ }
+
+ public void setStockQuote(String newStockQuote) {
+ stockQuote = newStockQuote;
+ }
+
+ public String getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(String newLastUpdated) {
+ lastUpdated = newLastUpdated;
+ }
+
+ public String getChange() {
+ return change;
+ }
+
+ public void setChange(String newChange) {
+ change = newChange;
+ }
+
+ public String getOpenPrice() {
+ return openPrice;
+ }
+
+ public void setOpenPrice(String newOpenPrice) {
+ openPrice = newOpenPrice;
+ }
+
+ public String getDayHighPrice() {
+ return dayHighPrice;
+ }
+
+ public void setDayHighPrice(String newDayHighPrice) {
+ dayHighPrice = newDayHighPrice;
+ }
+
+ public String getDayLowPrice() {
+ return dayLowPrice;
+ }
+
+ public void setDayLowPrice(String newDayLowPrice) {
+ dayLowPrice = newDayLowPrice;
+ }
+
+ public String getVolume() {
+ return volume;
+ }
+
+ public void setVolume(String newVolume) {
+ volume = newVolume;
+ }
+
+ public String getMarketCap() {
+ return marketCap;
+ }
+
+ public void setMarketCap(String newMarketCap) {
+ marketCap = newMarketCap;
+ }
+
+ public String getYearRange() {
+ return yearRange;
+ }
+
+ public void setYearRange(String newYearRange) {
+ yearRange = newYearRange;
+ }
+
+ public String getExDividendDate() {
+ return exDividendDate;
+ }
+
+ public void setExDividendDate(String newExDividendDate) {
+ exDividendDate = newExDividendDate;
+ }
+
+ public String getDividendYield() {
+ return dividendYield;
+ }
+
+ public void setDividendYield(String newDividendYield) {
+ dividendYield = newDividendYield;
+ }
+
+ public String getDividendPerShare() {
+ return dividendPerShare;
+ }
+
+ public void setDividendPerShare(String newDividendPerShare) {
+ dividendPerShare = newDividendPerShare;
+ }
+
+ @Override
+ public String toString() {
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (companyName: ");
+ result.append(companyName);
+ result.append(", symbol: ");
+ result.append(symbol);
+ result.append(", stockQuote: ");
+ result.append(stockQuote);
+ result.append(", lastUpdated: ");
+ result.append(lastUpdated);
+ result.append(", change: ");
+ result.append(change);
+ result.append(", openPrice: ");
+ result.append(openPrice);
+ result.append(", dayHighPrice: ");
+ result.append(dayHighPrice);
+ result.append(", dayLowPrice: ");
+ result.append(dayLowPrice);
+ result.append(", volume: ");
+ result.append(volume);
+ result.append(", marketCap: ");
+ result.append(marketCap);
+ result.append(", yearRange: ");
+ result.append(yearRange);
+ result.append(", exDividendDate: ");
+ result.append(exDividendDate);
+ result.append(", dividendYield: ");
+ result.append(dividendYield);
+ result.append(", dividendPerShare: ");
+ result.append(dividendPerShare);
+ result.append(')');
+ return result.toString();
+ }
+
+ @Override
+ public StockQuote clone() {
+ StockQuote ret = new StockQuote();
+ ret.companyName = companyName;
+ ret.symbol = symbol;
+ ret.stockQuote = stockQuote;
+ ret.lastUpdated = lastUpdated;
+ ret.change = change;
+ ret.openPrice = openPrice;
+ ret.dayHighPrice = dayHighPrice;
+ ret.dayLowPrice = dayLowPrice;
+ ret.volume = volume;
+ ret.marketCap = marketCap;
+ ret.yearRange = yearRange;
+ ret.exDividendDate = exDividendDate;
+ ret.dividendYield = dividendYield;
+ ret.dividendPerShare = dividendPerShare;
+ return ret;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..9d5c243f9a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.stockquote;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+
+/**
+ * This is the business interface of the HelloWorld service component.
+ */
+public interface StockQuoteService {
+
+ public Map getQuotes(String[] symbols) throws RemoteException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
new file mode 100644
index 0000000000..b0c31d4d81
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.stockquote;
+
+import java.rmi.RemoteException;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Random;
+
+/* Mock StockQuoteService */
+
+public class StockQuoteServiceImpl implements StockQuoteService {
+
+ static Random rn = new Random();
+
+ static Hashtable<String, StockQuote> stocks = new Hashtable<String, StockQuote>();
+
+ public synchronized Map getQuotes(String[] symbols) throws RemoteException {
+ Map<String, StockQuote> ret = new Hashtable<String, StockQuote>();
+ for (String sym : symbols) {
+ sym = sym.toUpperCase();
+ if (!ret.containsKey(sym)) {
+ StockQuote sq = stocks.get(sym);
+ if (sq == null) {
+ sq = new StockQuote();
+ stocks.put(sym, sq);
+ sq.setSymbol(sym);
+ sq.setCompanyName(sym + " INC");
+ float val = rn.nextFloat() * 97.0F + 3.0F;
+ sq.setStockQuote(val + "");
+ sq.setDayHighPrice(val + "");
+ sq.setDayLowPrice(val + "");
+ sq.setOpenPrice(val + "");
+ } else {
+ float diff = (rn.nextFloat() * 2.0F) - 1;
+ float newval = new Float(sq.getStockQuote()) + diff; // auto boxing cool.
+ sq.setStockQuote(newval + "");
+ float dh = Math.max(newval, new Float(sq.getDayHighPrice()));
+ sq.setDayHighPrice(dh + "");
+ float dl = Math.min(newval, new Float(sq.getDayLowPrice()));
+ sq.setDayLowPrice(dl + "");
+
+ }
+ ret.put(sym, sq.clone());
+ }
+
+ }
+
+ return ret;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java
new file mode 100644
index 0000000000..9e103f3738
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.services.stockquote;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import net.x.webservice.StockQuoteSoap;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the Stock quote service component.
+ */
+@Service(StockQuoteService.class)
+@Scope("MODULE")
+public class StockQuoteWebservicexServiceImpl implements StockQuoteService {
+
+ @Reference
+ public StockQuoteSoap stockQuoteService = null; // Injected by the SCA container.
+
+ /**
+ * @throws RemoteException
+ * @see bigbank.account.services.stockquote.StockQuoteService#getQuotes(String[])
+ */
+ public Map getQuotes(final String[] symbols) throws RemoteException {
+ try {
+ assert null != stockQuoteService : "stockQuoteService was not set by the SCA runtime!";
+ StringBuilder sb = new StringBuilder(5 * symbols.length);
+ for (String sym : symbols) {
+ if (sb.length() != 0) {
+ sb.append(' ');
+ }
+ sb.append(sym);
+ }
+ String stockdata = stockQuoteService.GetQuote(sb.toString());
+
+ InputStream in = new ByteArrayInputStream(stockdata.getBytes());
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ XMLStreamReader parser = factory.createXMLStreamReader(in);
+ ArrayList<StockQuote> listQuotes = new ArrayList<StockQuote>();
+ Hashtable<String, StockQuote> listQuoteHT = new Hashtable<String, StockQuote>();
+ MapStock currentStock = null;
+ StringBuilder currentText = new StringBuilder(100);
+ for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
+ String lname;
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ if (parser.getLocalName() == "Stock") {
+
+ currentStock = new MapStock();
+ listQuotes.add(currentStock);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ lname = parser.getLocalName();
+ String mname = "set" + lname;
+ try {
+ Method setter = MapStock.class.getMethod(mname, new Class[] { String.class });
+ if (setter != null) {
+ setter.invoke(currentStock, currentText.toString());
+ if (lname.equals("Symbol")) {
+ listQuoteHT.put(currentText.toString(), currentStock);
+
+ }
+ }
+ } catch (NoSuchMethodException e) {
+
+ }
+ // System.err.println(parser.getLocalName() + ":" + currentText.toString());
+ currentText.setLength(0);
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ // System.out.print(parser.getText());
+ currentText.append(parser.getText());
+ break;
+ case XMLStreamConstants.CDATA:
+ // System.out.print(parser.getText());
+ currentText.append(parser.getText());
+ break;
+ } // end switch
+ } // end while
+ parser.close();
+
+ return listQuoteHT;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass().getName() + e.getMessage(), e);
+ }
+ }
+
+ public static class MapStock extends StockQuote {
+
+ public void setLast(String val) {
+ super.setStockQuote(val);
+ }
+
+ public void setDate(String val) {
+ };
+
+ public void setTime(String val) {
+ };
+
+ public void setHigh(String val) {
+ super.setDayHighPrice(val);
+ }
+
+ public void setLow(String val) {
+ super.setDayLowPrice(val);
+ }
+
+ public void setOpen(String val) {
+ super.setOpenPrice(val);
+ }
+
+ public void setMktCap(String val) {
+ super.setMarketCap(val);
+ }
+
+ public void setName(String val) {
+ super.setCompanyName(val);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/DasAccountConfiguration.xml b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/DasAccountConfiguration.xml
new file mode 100644
index 0000000000..dba87e91d0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/DasAccountConfiguration.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ dataObjectModel="http://www.bigbank.com/account">
+
+ <Table tableName="CUSTOMERS" typeName="CustomerProfileData">
+ <!-- Column name="firstName" primaryKey="true"/ -->
+ <Column columnName="FIRSTNAME"/>
+ <Column columnName="LASTNAME"/>
+ <Column columnName="ADDRESS"/>
+ <Column columnName="EMAIL"/>
+ <Column columnName="LOGINID"/>
+ <Column columnName="PASSWORD"/>
+ <Column columnName="ID"/>
+ </Table>
+
+ <Table tableName="ACCOUNTS" typeName="AccountSummary">
+ <!-- Column name="firstName" primaryKey="true"/ -->
+ <Column columnName="ACCOUNTNUMBER"/>
+ <Column columnName="BALANCE"/>
+ </Table>
+
+
+
+ <Table tableName="STOCKS" typeName="StockSummary" >
+ <Column columnName="ID" propertyName="id"/>
+ <Column columnName="Symbol" propertyName="symbol"/>
+ <Column columnName="quantity" propertyName="quantity"/>
+ <Column columnName="purchasePrice" propertyName="purchasePrice"/>
+ <Column columnName="PURCHASEDATE" propertyName="purchaseDate" converterClassName="bigbank.account.services.accountdata.AccountDataServiceDASImpl$DateConverter"/>
+ </Table>
+
+
+ <Table tableName="ACCTLOG" typeName="AccountLogEntry">
+ <Column columnName="logSeqNo"/>
+ <Column columnName="ID"/>
+ <Column columnName="ACCOUNTNUMBER"/>
+ <Column columnName="ACTIONTYPE"/>
+ <Column columnName="AMOUNT"/>
+ </Table>
+
+
+
+ <Table tableName="STOCKLOG" typeName="StockLogEntry" >
+ <Column columnName="logSeqNo"/>
+ <Column columnName="ID"/>
+ <Column columnName="Symbol"/>
+ <Column columnName="quantity"/>
+ <Column columnName="actionType"/>
+ <Column columnName="purchaseLotNumber"/>
+ </Table>
+
+
+ <Command name="get account" SQL="SELECT accountNumber, accountType, balance FROM accounts where accountNumber = ?" kind="Select" />
+ <Command name="update balance" SQL="update ACCOUNTS set BALANCE = ? where ACCOUNTNUMBER = ?" kind="Update" />
+
+ <Command name="all customers" SQL="select * from CUSTOMERS" kind="Select"/>
+
+ <Command name="all stocks" SQL="select symbol, quantity, purchaseprice, purchasedate from stocks" kind="Select"/>
+ <Command name="stockbylotSelect" SQL="select quantity from STOCKS WHERE purchaseLotNumber = ?" kind="Select" />
+ <Command name="stockbylot" SQL="update STOCKS set quantity = ? WHERE purchaseLotNumber = ?" kind="Update" />
+
+</Config>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/AccountService.wsdl
new file mode 100644
index 0000000000..9acb92664d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/AccountService.wsdl
@@ -0,0 +1,467 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/account"
+ targetNamespace="http://www.bigbank.com/account"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/account"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/account"
+
+ > <!-- xmlns:sdojava="commonj.sdo/java" sdojava:package="org.apache.tuscany.samples.bigbank.account" -->
+
+
+<!-- <xsd:complexType name="DataGraphRoot">
+ <xsd:sequence>
+ <xsd:element name="customerProfileData" type="account:CustomerProfileData" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="StockSummaries" type="account:StockSummary" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="AccountSummaries" type="account:AccountSummary" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="StockLogEntries" type="account:StockLogEntry" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="AccountLogEntries" type="account:AccountLogEntry" maxOccurs="unbounded" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>-->
+
+
+ <xsd:element name="getAccountReport">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID"
+ type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport"
+ type="account:AccountReport" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummaries"
+ type="account:AccountSummary" maxOccurs="unbounded" />
+ <xsd:element name="stockSummaries"
+ type="account:StockSummary" maxOccurs="unbounded" />
+
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:attribute name="accountNumber" type="xsd:string" />
+ <xsd:attribute name="accountType" type="xsd:string" />
+ <xsd:attribute name="balance" type="xsd:float" />
+ </xsd:complexType>
+
+ <xsd:complexType name="StockSummary">
+ <!-- xsd:attribute name="id" type="xsd:int" / -->
+ <xsd:attribute name="purchaseLotNumber" type="xsd:int" />
+ <!-- unique id for this purchase -->
+ <xsd:attribute name="symbol" type="xsd:string" />
+ <xsd:attribute name="quantity" type="xsd:int" />
+ <xsd:attribute name="purchaseDate" type="xsd:dateTime" />
+ <xsd:attribute name="purchasePrice" type="xsd:float" />
+ <xsd:attribute name="currentPrice" type="xsd:float" />
+ <xsd:attribute name="company" type="xsd:string" />
+ <xsd:attribute name="highPrice" type="xsd:float" />
+ <xsd:attribute name="lowPrice" type="xsd:float" />
+
+ </xsd:complexType>
+
+ <!-- Profile in data base -->
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="CustomerProfileData">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ <xsd:element name="address" type="xsd:string" />
+ <xsd:element name="email" type="xsd:string" />
+ <xsd:element name="loginID" type="xsd:string" />
+ <xsd:element name="password" type="xsd:string" />
+ <xsd:element name="id" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="withdraw">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountNumber"
+ type="xsd:string" />
+ <xsd:element name="amount" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="withdrawResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="balance" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="deposit">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountNumber"
+ type="xsd:string" />
+ <xsd:element name="amount" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="depositResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="balance" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="purchaseStock">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="id" type="xsd:int" />
+ <xsd:element name="stock" type="account:StockSummary" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="purchaseStockResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="purchaseSummary"
+ type="account:StockSummary" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+
+
+ <xsd:element name="sellStock">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="purchaseLotNumber"
+ type="xsd:int" /><!-- unique id for this purchase -->
+ <xsd:element name="quantity" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="createAccount">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ <xsd:element name="createSavings"
+ type="xsd:boolean" />
+ <xsd:element name="createCheckings"
+ type="xsd:boolean" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="createAccountResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:element>
+
+ <xsd:element name="getAccountLog">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID"
+ type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountLogResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountLog"
+ type="account:AccountLog" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="AccountLog">
+ <xsd:sequence>
+ <xsd:element name="accountLogEntries"
+ type="account:AccountLogEntry" maxOccurs="unbounded" />
+ <xsd:element name="stockLogEntries"
+ type="account:StockLogEntry" maxOccurs="unbounded" />
+
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="AccountLogEntry">
+ <xsd:attribute name="logSeqNo" type="xsd:int" />
+ <xsd:attribute name="id" type="xsd:int" />
+ <xsd:attribute name="accountNumber" type="xsd:string" />
+ <xsd:attribute name="actionType" type="xsd:string" />
+ <xsd:attribute name="amount" type="xsd:float" />
+ </xsd:complexType>
+
+ <xsd:complexType name="StockLogEntry">
+ <xsd:attribute name="logSeqNo" type="xsd:int" />
+ <xsd:attribute name="id" type="xsd:int" />
+ <xsd:attribute name="symbol" type="xsd:string" />
+ <xsd:attribute name="quantity" type="xsd:int" />
+ <xsd:attribute name="actionType" type="xsd:string" />
+ <xsd:attribute name="purchaseLotNumber" type="xsd:int" />
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="account:getAccountReport"
+ name="getAccountReportRequest" />
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="account:getAccountReportResponse"
+ name="getAccountReportResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="account:getCustomerProfile"
+ name="getCustomerProfile" />
+ </wsdl:message>
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="account:getCustomerProfileResponse"
+ name="getCustomerProfileResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="withdrawRequest">
+ <wsdl:part element="account:withdraw" name="withdrawRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="withdrawResponse">
+ <wsdl:part element="account:withdrawResponse"
+ name="withdrawResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="depositRequest">
+ <wsdl:part element="account:deposit" name="depositRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="depositResponse">
+ <wsdl:part element="account:depositResponse"
+ name="depositResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="purchaseStockRequest">
+ <wsdl:part element="account:purchaseStock"
+ name="purchaseStockRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="purchaseStockResponse">
+ <wsdl:part element="account:purchaseStockResponse"
+ name="purchaseStockResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="sellStockRequest">
+ <wsdl:part element="account:sellStock" name="sellStockRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="createAccountRequest">
+ <wsdl:part element="account:createAccount" name="createAccountRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="createAccountResponse">
+ <wsdl:part element="account:createAccountResponse" name="createAccountResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="getAccountLogRequest">
+ <wsdl:part element="account:getAccountLog"
+ name="getAccountLogRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="getAccountLogResponse">
+ <wsdl:part element="account:getAccountLogResponse"
+ name="getAccountLogResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="account:getAccountReportRequest" />
+ <wsdl:output message="account:getAccountReportResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="account:getCustomerProfileRequest" />
+ <wsdl:output message="account:getCustomerProfileResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="withdraw">
+ <wsdl:input message="account:withdrawRequest" />
+ <wsdl:output message="account:withdrawResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="deposit">
+ <wsdl:input message="account:depositRequest" />
+ <wsdl:output message="account:depositResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="purchaseStock">
+ <wsdl:input message="account:purchaseStockRequest" />
+ <wsdl:output message="account:purchaseStockResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="sellStock">
+ <wsdl:input message="account:sellStockRequest" />
+ <wsdl:output message="account:purchaseStockResponse" />
+ </wsdl:operation>
+
+
+ <wsdl:operation name="createAccount">
+ <wsdl:input message="account:createAccountRequest" />
+ <wsdl:output message="account:createAccountResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="getAccountLog">
+ <wsdl:input message="account:getAccountLogRequest" />
+ <wsdl:output message="account:getAccountLogResponse" />
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+
+
+ <wsdl:binding name="AccountServiceSOAP" type="account:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getAccountReport" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getCustomerProfile">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getCustomerProfile" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="withdraw">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/withdraw" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="deposit">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/deposit" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="purchaseStock">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/purchaseStock" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="sellStock">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/sellStock" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="createAccount">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/createAccount" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="getAccountLog">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getAccountLog" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="account:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address
+ location="http://localhost:8080/sample-bigbank-account/services/AccountService" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl
new file mode 100644
index 0000000000..16c980a30e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.webserviceX.NET/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <s:schema elementFormDefault="qualified"
+ targetNamespace="http://www.webserviceX.NET/" >
+ <!--
+ xmlns:sdojava="commonj.sdo/java"
+ sdojava:package="net.x.webservice"
+ -->
+
+
+ >
+ <s:element name="GetQuote">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="symbol" type="s:string"/>
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="GetQuoteResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="GetQuoteResult" type="s:string"/>
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="string" nillable="true" type="s:string"/>
+ </s:schema>
+ </wsdl:types>
+ <wsdl:message name="GetQuoteSoapIn">
+ <wsdl:part name="parameters" element="tns:GetQuote"/>
+ </wsdl:message>
+ <wsdl:message name="GetQuoteSoapOut">
+ <wsdl:part name="parameters" element="tns:GetQuoteResponse"/>
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpGetIn">
+ <wsdl:part name="symbol" type="s:string"/>
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpGetOut">
+ <wsdl:part name="Body" element="tns:string"/>
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpPostIn">
+ <wsdl:part name="symbol" type="s:string"/>
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpPostOut">
+ <wsdl:part name="Body" element="tns:string"/>
+ </wsdl:message>
+ <wsdl:portType name="StockQuoteSoap">
+ <wsdl:operation name="GetQuote">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</documentation>
+ <wsdl:input message="tns:GetQuoteSoapIn"/>
+ <wsdl:output message="tns:GetQuoteSoapOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:portType name="StockQuoteHttpGet">
+ <wsdl:operation name="GetQuote">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</documentation>
+ <wsdl:input message="tns:GetQuoteHttpGetIn"/>
+ <wsdl:output message="tns:GetQuoteHttpGetOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:portType name="StockQuoteHttpPost">
+ <wsdl:operation name="GetQuote">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</documentation>
+ <wsdl:input message="tns:GetQuoteHttpPostIn"/>
+ <wsdl:output message="tns:GetQuoteHttpPostOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="GetQuote">
+ <soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="StockQuoteHttpGet" type="tns:StockQuoteHttpGet">
+ <http:binding verb="GET"/>
+ <wsdl:operation name="GetQuote">
+ <http:operation location="/GetQuote"/>
+ <wsdl:input>
+ <http:urlEncoded/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:mimeXml part="Body"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="StockQuoteHttpPost" type="tns:StockQuoteHttpPost">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="GetQuote">
+ <http:operation location="/GetQuote"/>
+ <wsdl:input>
+ <mime:content type="application/x-www-form-urlencoded"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:mimeXml part="Body"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuote">
+ <wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap">
+ <soap:address location="http://www.webservicex.com/stockquote.asmx"/>
+ </wsdl:port>
+ <wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet">
+ <http:address location="http://www.webservicex.com/stockquote.asmx"/>
+ </wsdl:port>
+ <wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost">
+ <http:address location="http://www.webservicex.com/stockquote.asmx"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..7c83a1a648
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="bigbank.account">
+
+
+ <service name="AccountService">
+ <!-- interface.java interface="com.bigbank.account.AccountService"/-->
+ <interface.wsdl interface="http://www.bigbank.com/account#wsdl.interface(AccountService)"
+ wsdli:wsdlLocation="http://www.bigbank.com/account wsdl/AccountService.wsdl" />
+
+
+ <binding.ws endpoint="http://www.bigbank.com/account#wsdl.endpoint(AccountService/AccountServiceSOAP)"
+ conformanceURIs="http://ws-i.org/profiles/basic/1.1" location="wsdl/AccountService.wsdl" />
+
+ <reference>AccountServiceComponent</reference>
+ </service>
+
+
+ <property name="currency" type="xsd:string">USD</property>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="bigbank.account.services.account.AccountServiceImpl" />
+ <property name="currency" source="$currency" />
+ <reference name="accountDataService">AccountLoggerDataServiceComponent</reference>
+ <reference name="stockQuoteService">StockQuoteServiceComponent</reference>
+ </component>
+
+ <component name="AccountLoggerDataServiceComponent">
+ <implementation.java class="bigbank.account.services.accountlogger.AccountLoggerDataServiceImpl" />
+ <reference name="accountDataService">AccountDataServiceComponent</reference>
+ <reference name="accountLoggerService">AccountLoggerServiceComponent</reference>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="bigbank.account.services.accountdata.AccountDataServiceDASImpl" />
+ </component>
+
+ <component name="AccountLoggerServiceComponent">
+ <implementation.java class="bigbank.account.services.accountlogger.AccountLoggerServiceImpl" />
+ </component>
+
+ <!-- by default, we use the faked stock quote implemented as a POJO component -->
+ <component name="StockQuoteServiceComponent">
+ <implementation.java class="bigbank.account.services.stockquote.StockQuoteServiceImpl" />
+ </component>
+
+ <!-- Please uncomment the following to get the real stock quote -->
+ <!--
+ <component name="StockQuoteServiceComponent">
+ <implementation.java class="bigbank.account.services.stockquote.StockQuoteWebservicexServiceImpl" />
+ <reference name="stockQuoteService">StockQuoteWebService</reference>
+ </component>
+
+ <reference name="StockQuoteWebService">
+ <interface.wsdl interface="http://www.webserviceX.NET/#wsdl.interface(StockQuoteSoap)"
+ wsdli:wsdlLocation="http://www.webserviceX.NET/ wsdl/stockquotes.webservicex.wsdl" />
+ <binding.ws endpoint="http://www.webserviceX.NET/#wsdl.endpoint(StockQuote/StockQuoteSoap)"
+ location="wsdl/stockquotes.webservicex.wsdl" />
+ </reference>
+ -->
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..0f685b2581
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>Tuscany Bigbank Account sample</display-name>
+
+ <!-- context-param>
+ <param-name>tuscany.systemScdlPath</param-name>
+ <param-value>/META-INF/tuscany/webapp.scdl</param-value>
+ </context-param -->
+
+ <!-- context-param>
+ <param-name>tuscany.applicationScdlPath</param-name>
+ <param-value>/META-INF/sca/default.scdl</param-value>
+ </context-param -->
+
+ <context-param>
+ <param-name>tuscany.online</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <display-name>Tuscany Servlet</display-name>
+ <servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+
+ </servlet-mapping>
+ <servlet>
+ <!-- Initialize bigbank database -->
+ <servlet-name>AccountDBInit</servlet-name>
+ <servlet-class>bigbank.account.services.accountdb.AccountDBInit</servlet-class>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java
new file mode 100644
index 0000000000..28f9e762f0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.client;
+
+import java.util.Iterator;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountService;
+import com.bigbank.account.AccountSummary;
+
+public class AccountClient {
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+
+ AccountService accountService = context.locateService(AccountService.class, "AccountServiceComponent");
+
+ AccountReport accountReport = accountService.getAccountReport(12345);
+
+ for (Iterator i = accountReport.getAccountSummaries().iterator(); i.hasNext();) {
+ AccountSummary accountSummary = (AccountSummary) i.next();
+
+ System.out.println(accountSummary.getAccountNumber());
+ System.out.println(accountSummary.getAccountType());
+ System.out.println(accountSummary.getBalance());
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/Show.Image.html b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/Show.Image.html
new file mode 100644
index 0000000000..9b18679abf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/Show.Image.html
@@ -0,0 +1,40 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+ <head>
+ <style type="text/css">
+ #image {
+ text-align:center;
+ }
+ #close {
+ text-align:center;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="image">
+ <script language="javascript">
+ var search = document.location.search;
+ var url = search.substring(5,search.length);
+ document.write("<img src='" + url + "' alt='" + url + "'/>");
+ </script>
+ </div>
+ <div id="close"><a href="javascript:window.close()">Close Window</a></div>
+ </body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountfiles.png b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountfiles.png
new file mode 100644
index 0000000000..9fc46488a0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountfiles.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountmodule.png b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountmodule.png
new file mode 100644
index 0000000000..d4209a01e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/accountmodule.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/modualoverview.png b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/modualoverview.png
new file mode 100644
index 0000000000..7e6d7ba25e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/modualoverview.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientfiles.png b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientfiles.png
new file mode 100644
index 0000000000..b951ed2e5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientfiles.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientmodule.png b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientmodule.png
new file mode 100644
index 0000000000..dfd3a34bfb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/docs/webclientmodule.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/pom.xml
new file mode 100644
index 0000000000..2099340f77
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.samples.bigbank</groupId>
+ <artifactId>bigbank-scenario</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany BigBank Scenario Sample</name>
+
+ <modules>
+ <module>account</module>
+ <module>webclient</module>
+ </modules>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/readme.html
new file mode 100644
index 0000000000..b5e90bb08f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/readme.html
@@ -0,0 +1,894 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<script type="text/javascript">
+function expandImage(img,height,width) {
+window.open(img,"Image","menubar=no,resizable=no,status=no,toolbar=no,location=no,height=" + height + ",width=" + width);
+}
+function goURL(url) {
+window.location = url;
+}
+</script>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany BigBank Sample Application</title>
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+<style type="text/css" media="all">
+</style>
+</head>
+
+<body>
+
+ <h3>Tuscany BigBank Sample Application</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany BigBank&nbsp;sample application&nbsp; shows using
+ the Tuscany SCA runtime to build a&nbsp; financial application.
+ There are two modules: webclient provides the front-end user
+ interface and account provides the back-end business services.
+ These are deployed as separate web applications</p>
+
+ <h4>Location</h4>
+ <p>This sample is located&nbsp;in the&nbsp;
+ <a href=".">samples\applications\bigbank</a> directory. There are two
+ subdirectories in that for the two modules <a href="account"
+ target="_blank">account</a> and <a href="webclient" target=
+ "_blank">webclient.</a></p>
+
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+
+ <li><a href="http://tomcat.apache.org/download-55.cgi" target=
+ "_blank">Apache Tomcat 5.xx</a> latest version binary core
+ distribution.&nbsp;</li>
+ </ul>
+
+ <h4><a name="Building" id="Building"></a>Building</h4>
+ <p>This sample
+ can be built from the bigbank directory using Maven 2.0.4 with
+ the following command:</p>
+ <p>
+ <code>&nbsp;mvn<br></code>
+ </p>
+
+ <h4>Setup</h4>
+ <p>If you have enabled remote deployment in Tomcat by
+ adding the line:<br>
+ <code>&nbsp; &lt;user username="admin" password=""
+ roles="manager"/&gt;</code><br>
+ into&nbsp; <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\conf\tomcat-users.xml&nbsp; you can deploy the
+ WARs to Tomcat using the tomcat-maven-plugin:<br>
+ <code>mvn tomcat:deploy</code></p>
+ <p>Alternatively you can copy the WAR files to Tomcat's&nbsp;
+ webapps directory.<br>
+
+ <code>copy account\target\sample-bigbank-account.war <span style=
+ "font-style: italic;">&lt;tomcat dir&gt;</span>\webapps</code><br>
+ <code>copy&nbsp;
+ webclient\target\sample-bigbank-webclient.war&nbsp;<span style=
+ "font-style: italic;">&lt;tomcat dir&gt;</span>\webapps</code><br>
+ </p>
+
+ <h4>Running</h4>
+ <p>Once you've started your web server, use your web
+ browser to view the following URL <a href=
+ "http://localhost:8080/sample-bigbank-webclient/" target=
+ "_blank">http://localhost:8080/sample-bigbank-webclient/</a><br>
+ You can either use an already pre configured&nbsp; account with
+ <span style="font-weight: bold;">Login</span> as <span style=
+ "color: rgb(204, 0, 0); font-weight: bold;">test</span> and
+ <span style="font-weight: bold;">Password</span> as <span style=
+ "color: rgb(204, 0, 0); font-weight: bold;">password,</span> or
+ you can &nbsp;create a new account.<br>
+ The demo is first configured to use a local mock stock quote
+ service that returns random stock data. &nbsp;If you want to use
+ an actual stock quote provider follow these steps:</p>
+
+ <ul>
+ <li>Stop your server by issuing in the&nbsp; <span style=
+ "font-style: italic;">&lt;tomcat dir&gt;</span><span style=
+ "font-weight: bold;">\bin</span> directory</li>
+
+ <li>Issue <span style="font-weight: bold;">shutdown</span>
+ command to stop your web application server<span style=
+ "font-weight: bold;">.</span></li>
+
+ <li>Edit the account SCDL file <span style=
+ "font-style: italic;">&lt;tomcat dir&gt;</span><span style=
+ "font-weight: bold;">\webapps\sample-bigbank-account\WEB-INF\default.scdl</span></li>
+
+ <li>Change the SCDL wiring to remove the mock stock quote
+ service by commenting it out as follows:<br>
+ &lt;!--<br>
+ &nbsp;&nbsp;&nbsp; &lt;component
+ name="StockQuoteServiceComponent"&gt;<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;implementation.java
+ class="bigbank.account.services.stockquote.StockQuoteServiceImpl"
+ /&gt;<br>
+ &nbsp;&nbsp;&nbsp; &lt;/component&gt;<br>
+ --&gt;</li>
+
+ <li>Uncomment the real stockquote service section in lines 68
+ to 80.<br></li>
+
+ <li>Change to the directory &nbsp;<span style=
+ "font-weight: bold;">apache-tomcat-5.5.17\bin&nbsp;</span></li>
+
+ <li>issue <span style="font-weight: bold;">startup
+ &nbsp;</span> command to start up the server in the
+ <span style="font-style: italic;">&lt;tomcat dir&gt;</span>\bin
+ directory<span style="font-weight: bold;">.</span></li>
+ </ul>
+ <p>The sample should now be using the real stock quote
+ provider.&nbsp;</p>
+
+ <h4>Summary</h4><p>This example illustrates using Tuscany runtime
+ in building a financial Web application&nbsp;using SCA programing
+ model. &nbsp;The following key concepts are covered:</p>
+
+ <ul>
+ <li><b><i>Component implementations</i></b>. that provide web
+ based&nbsp; HTML&nbsp;user interface</li>
+
+ <li><b><i>Component implementations</i></b> that provide
+ <b><i>local services</i></b> in Java. Local services implement
+ internal application business logic such as tracking user state
+ and are not exposed remotely.</li>
+
+ <li><b><i>Component implementations</i></b> that have
+ <b><i>configuration properties</i></b> and <b><i>service
+ references</i></b> to other services</li>
+
+ <li><b><i>Components</i></b> that use and
+ <b><i>configure</i></b> <b><i>the properties and
+ references</i></b> of component implementations</li>
+
+ <li><b><i>SCA Services</i></b> to publish remotable services
+ via a <b><i>Web Service binding</i></b>.</li>
+
+ <li><b><i>SCA References&nbsp;</i></b> to consume remotable
+ services via a <b><i>Web Service binding</i></b></li>
+
+ <li>Assembling implementation, components, entry points and
+ external service into composite components.</li>
+
+ <li>Creating a module and all of its artifacts as part of a
+ <b><i>web application</i></b> to show a front-end access to SCA
+ services</li>
+
+ <li>The use of Data Access services to persist and retrieve
+ Service Data Objects from Apache Derby.</li>
+
+ <li style="text-align: left;">The use of &nbsp;existing Web
+ services in&nbsp; SCA.</li>
+ </ul><p>BigBank sample provides the following user services: account
+ balance,&nbsp;making deposits and withdrawals&nbsp; to purchase
+ and sell stock, and to view current stock value.<br>
+ The sample is organized into two SCA modules: webclient and
+ account. The webclient module functionality is to provide user
+ information and obtain user input. The account module is used to
+ retrieve and store user information, account information, current
+ stock information and the purchasing and selling of stock. The
+ two modules interact via web services through SCA references and
+ services.</p>
+ <br>
+
+ <div style="text-align: center;">
+ <img style="width: 381px; height: 169px;" alt=
+ "Overview of modules." title="Overview of modules." src=
+ "docs/modualoverview.png" align="middle">
+
+ <h5>Webclient</h5><br>
+ <a href=
+ "javascript:expandImage('docs/Show.Image.html?url=webclientmodule.png',1000,1100)">
+ <img style="width: 300px; height: 200px;" alt="Webclient files"
+ title="Click to expand" src="docs/webclientmodule.png"></a><br>
+
+ <p>&nbsp;</p>
+
+ <table style="text-align: left; width: 100%;" border="0"
+ cellpadding="1" cellspacing="0" width="100%">
+ <tbody>
+ <tr>
+ <td align="left" valign="top" width="*">
+ <a href=
+ "javascript:expandImage('docs/Show.Image.html?url=webclientfiles.png',850,500)">
+ <img style="width: 262px; height: 360px;" alt=
+ "Webclient files" title="Click to expand" src=
+ "docs/webclientfiles.png"></a>&nbsp;<br>
+
+ <div style="text-align: center;">
+ <small><span style="font-style: italic;">click to
+ enlarge</span></small>
+ </div>
+ </td>
+
+ <td style="text-align: left;" align="left" valign="top"
+ width="80%">
+ <table style="text-align: left; width: 100%;" border=
+ "0" cellpadding="1" cellspacing="0">
+ <tbody>
+ <tr>
+ <td style="text-align: center;" colspan="3">
+ <span style=
+ "font-weight: bold; text-decoration: underline;">Java
+ source files implementing SCA components and
+ interfaces.</span></td>
+ </tr>
+
+ <tr>
+ <td style="width: 10%;">
+ AccountServiceComponentImpl.java</td>
+
+ <td>&nbsp;</td>
+
+ <td>Implements the account service.</td>
+ </tr>
+
+ <tr>
+ <td>AccountLoginServiceImpl.java</td>
+
+ <td></td>
+
+ <td>Implements the Login service.</td>
+ </tr>
+
+ <tr>
+ <td>LoginService.java</td>
+
+ <td></td>
+
+ <td>Interface for a services provided by a
+ login&nbsp; service component.</td>
+ </tr>
+
+ <tr>
+ <td>ProfileService.java</td>
+
+ <td></td>
+
+ <td>Interface for a service provided by a profile
+ component.</td>
+ </tr>
+
+ <tr>
+ <td>ProfileServiceImpl.java</td>
+
+ <td></td>
+
+ <td>Implements the profile component.</td>
+ </tr>
+
+ <tr>
+ <td>SimpleLoginServiceImpl.java</td>
+
+ <td></td>
+
+ <td>A simple in memory login service.</td>
+ </tr>
+
+ <tr>
+ <td style="text-align: center;" colspan="3">
+ <span style=
+ "font-weight: bold; text-decoration: underline;">Java
+ source files implementing Web HTML
+ interface.</span></td>
+ </tr>
+
+ <tr>
+ <td>AccountStatusTag.java</td>
+
+ <td></td>
+
+ <td>Implements a jsp tag that&nbsp;displays the
+ account information</td>
+ </tr>
+
+ <tr>
+ <td>StockStatusTag.java</td>
+
+ <td></td>
+
+ <td>Implements a jsp tag that displays the stock
+ information.</td>
+ </tr>
+
+ <tr>
+ <td>LoginBarrierTag.java</td>
+
+ <td></td>
+
+ <td>Implements a jsp tag that ensures the user is
+ logged in.</td>
+ </tr>
+
+ <tr>
+ <td>ServiceTag.java</td>
+
+ <td></td>
+
+ <td>Places an SCA service in the JSP page
+ context.</td>
+ </tr>
+
+ <tr>
+ <td>FormServlet.java</td>
+
+ <td></td>
+
+ <td>Process user input and uses the
+ AccountService component.</td>
+ </tr>
+
+ <tr>
+ <td>LoginServlet.java</td>
+
+ <td></td>
+
+ <td>Processes logging in and logout.</td>
+ </tr>
+
+ <tr>
+ <td style="text-align: center;" colspan="3">
+ <span style=
+ "font-weight: bold; text-decoration: underline;">Files
+ that will be loaded as resources along
+ classpath.</span></td>
+ </tr>
+
+ <tr>
+ <td>AccountService.wsdl</td>
+
+ <td></td>
+
+ <td>WSDL that &nbsp;defines the account
+ service.</td>
+ </tr>
+
+ <tr>
+ <td>bigbank-tags.tld</td>
+
+ <td></td>
+
+ <td>Defines the tag libs for the user
+ interface.</td>
+ </tr>
+
+ <tr align="center">
+ <td colspan="3"><span style=
+ "font-weight: bold; text-decoration: underline;">Files
+ located in WEB-INF directory.</span></td>
+ </tr>
+
+ <tr>
+ <td><a href="#SCDL">default.scdl</a></td>
+
+ <td></td>
+
+ <td>Application's SCA SCDL file.</td>
+ </tr>
+
+ <tr>
+ <td><a href="#Web.xml">web.xml</a></td>
+
+ <td></td>
+
+ <td>Application's web.xml file.</td>
+ </tr>
+
+ <tr align="center">
+ <td colspan="3"><span style=
+ "font-weight: bold; text-decoration: underline;">Generated
+ Files.</span></td>
+ </tr>
+
+ <tr>
+ <td>sdo source</td>
+
+ <td></td>
+
+ <td>Generated SDO. Created by <a href=
+ "#tuscany-sdo-plugin"><code><span style=
+ "font-weight: bold;">tuscany-sdo-plugin</span></code></a>
+ maven plugin.</td>
+ </tr>
+
+ <tr>
+ <td>wsdl2java-source</td>
+
+ <td></td>
+
+ <td>Generated SDO interface. Created by <a href=
+ "#tuscany-plugin-wsdl2java"><code><span style=
+ "font-weight: bold;">tuscany-plugin-wsdl2java</span></code></a>
+ maven &nbsp;plugin.</td>
+ </tr>
+
+ <tr align="center">
+ <td colspan="3"><span style=
+ "font-weight: bold; text-decoration: underline;">Build
+ files.</span></td>
+ </tr>
+
+ <tr>
+ <td><a href="#pom.xml">pom.xml</a></td>
+
+ <td></td>
+
+ <td>Maven build file.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>&nbsp;</p><!-- account -->
+
+ <h5>Account</h5><br>
+ <a href=
+ "javascript:expandImage('docs/Show.Image.html?url=accountmodule.png',830,1400)">
+ <img style="width: 300px; height: 200px;" alt="Account module"
+ title="Click to expand" src="docs/accountmodule.png"></a><br>
+
+ <p>&nbsp;</p>
+
+ <table style="text-align: left; width: 100%;" border="0"
+ cellpadding="1" cellspacing="0" width="100%">
+ <tbody>
+ <tr>
+ <td align="left" valign="top" width="*">
+ <a href=
+ "javascript:expandImage('docs/Show.Image.html?url=accountfiles.png',850,500)">
+ <img style="width: 262px; height: 360px;" alt=
+ "Webclient files" title="Click to expand" src=
+ "docs/accountfiles.png"></a>&nbsp;<br>
+
+ <div style="text-align: center;">
+ <small><span style="font-style: italic;">click to
+ enlarge</span></small>
+ </div>
+ </td>
+
+ <td style="text-align: left;" align="left" valign="top"
+ width="80%">
+ <table style="text-align: left; width: 100%;" border=
+ "0" cellpadding="1" cellspacing="0">
+ <tbody>
+ <tr>
+ <td style="text-align: center;" colspan="3">
+ <span style=
+ "font-weight: bold; text-decoration: underline;">Java
+ source files implementing SCA components and
+ interfaces.</span></td>
+ </tr>
+
+ <tr>
+ <td style="width: 10%;">
+ AccountServiceImpl.java</td>
+
+ <td>&nbsp;</td>
+
+ <td>Implements the account service
+ component.</td>
+ </tr>
+
+ <tr>
+ <td>AccountDataService.java</td>
+
+ <td></td>
+
+ <td>Interface defined for component implementing
+ &nbsp;an account's data service.</td>
+ </tr>
+
+ <tr>
+ <td>AccountDataServiceDASImpl.java</td>
+
+ <td></td>
+
+ <td>A Data Access Service (DAS) implementation of
+ of the Account Data Service.</td>
+ </tr>
+
+ <tr>
+ <td>AccountDataServiceImpl.java</td>
+
+ <td></td>
+
+ <td>A Data Service implementation not using
+ DAS.</td>
+ </tr>
+
+ <tr>
+ <td>AccountDBInit.java</td>
+
+ <td></td>
+
+ <td>A utility to just create the database and it
+ table and fill in some initial data.</td>
+ </tr>
+
+ <tr>
+ <td>StockQuote.java</td>
+
+ <td></td>
+
+ <td>A class to hold the StockQuote
+ information.</td>
+ </tr>
+
+ <tr>
+ <td>StockQuoteService.java</td>
+
+ <td></td>
+
+ <td>Interface defined for a component
+ implementing a stock quote service.</td>
+ </tr>
+
+ <tr>
+ <td>StockQuoteServiceImpl.java</td>
+
+ <td></td>
+
+ <td>Implements a fake stock quote service.</td>
+ </tr>
+
+ <tr>
+ <td>StockQuoteWebservicexServiceImpl.java</td>
+
+ <td></td>
+
+ <td>Implements an actual stock quote
+ service.</td>
+ </tr>
+
+ <tr>
+ <td style="text-align: center;" colspan="3">
+ <span style=
+ "font-weight: bold; text-decoration: underline;">Files
+ that will be loaded as resources along
+ classpath.</span></td>
+ </tr>
+
+ <tr>
+ <td>AccountService.wsdl</td>
+
+ <td></td>
+
+ <td>WSDL that &nbsp;defines the account
+ service</td>
+ </tr>
+
+ <tr>
+ <td>stockquotes.webservicex.wsdl</td>
+
+ <td></td>
+
+ <td>Actual stock quote service WSDL.</td>
+ </tr>
+
+ <tr>
+ <td><a href=
+ "#DAS_">DasAccountConfiguration.xml</a></td>
+
+ <td></td>
+
+ <td>Provides any needed configuration info
+ including datasource properties, table
+ definitions,</td>
+ </tr>
+
+ <tr align="center">
+ <td colspan="3"><span style=
+ "font-weight: bold; text-decoration: underline;">Files
+ located in WEB-INF directory.</span></td>
+ </tr>
+
+ <tr>
+ <td><a href="#SCDL">default.scdl</a></td>
+
+ <td></td>
+
+ <td>Application's SCA SCDL file.</td>
+ </tr>
+
+ <tr>
+ <td><a href="#Web.xml">web.xml</a></td>
+
+ <td></td>
+
+ <td>Application's web.xml file.</td>
+ </tr>
+
+ <tr align="center">
+ <td colspan="3"><span style=
+ "font-weight: bold; text-decoration: underline;">Generated
+ Files.</span></td>
+ </tr>
+
+ <tr>
+ <td>sdo source</td>
+
+ <td></td>
+
+ <td>Generated SDO. Created by&nbsp;<a href=
+ "#tuscany-sdo-plugin"><code><span style=
+ "font-weight: bold;">tuscany-sdo-plugin</span></code></a>
+ maven plugin.</td>
+ </tr>
+
+ <tr>
+ <td>wsdl2java-source</td>
+
+ <td></td>
+
+ <td>Generated SDO interface. Created
+ by&nbsp;<a href=
+ "#tuscany-plugin-wsdl2java"><code><span style=
+ "font-weight: bold;">tuscany-plugin-wsdl2java</span></code></a>
+ maven &nbsp;plugin.</td>
+ </tr>
+
+ <tr align="center">
+ <td colspan="3"><span style=
+ "font-weight: bold; text-decoration: underline;">Build
+ files.</span></td>
+ </tr>
+
+ <tr>
+ <td><a href="#pom.xml">pom.xml</a></td>
+
+ <td></td>
+
+ <td>Maven build file.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div><br>
+ <br>
+
+
+ <h5><a name="pom.xml" id="pom.xml"></a>Pom.xml</h5>
+ <p>The directions
+ for maven&nbsp; how&nbsp; to build the each module is located in
+ each module's directory in the&nbsp;pom.xml file. &nbsp;The
+ application uses Java 1.5 and thus in the build &nbsp;plugin
+ section needs the following compiler directives:</p>
+ &nbsp;&nbsp;<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;plugin&gt;<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;configuration&gt;<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;source&gt;<span style=
+ "color: rgb(255, 0, 0); font-weight: bold;">1.5</span>&lt;/source&gt;<br>
+
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;target&gt;<span style=
+ "color: rgb(255, 0, 0); font-weight: bold;">1.5</span>&lt;/target&gt;<br>
+
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;/configuration&gt;<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+ &lt;/plugin&gt;</code><br>
+ <p>Both webclient and account uses three maven
+ plugins:&nbsp;<code style=
+ "font-weight: bold;">tuscany-sdo-plugin</code>,&nbsp;<code style=
+ "font-weight: bold;">tuscany-plugin-wsdl2java</code>,
+ and&nbsp;<code style=
+ "font-weight: bold;">tuscany-war-plugin</code>.
+ The&nbsp;tuscany-sdo-plugin is provided by Tuscany 's SDO project
+ while the other two are provided by the Tuscany SCA project.</p>
+ <p>The <code style="font-weight: bold;"><a name="tuscany-sdo-plugin"
+ id="tuscany-sdo-plugin"></a>tuscany-sdo-plugin</code>
+ &nbsp;references the WSDL's schema and generates all the files
+ located in target/sdo_source directory. &nbsp;The application
+ uses these classes as a databinding instead of having to deal
+ directly with XML that &nbsp;represents form as defined in the
+ WSDL's schema.</p>
+ <p>The <code style="font-weight: bold;"><a name=
+ "tuscany-plugin-wsdl2java" id=
+ "tuscany-plugin-wsdl2java"></a>tuscany-plugin-wsdl2java</code>
+ plugin generates a Java interface in the target/wsdl2java-source
+ directory that is used to define the inteface (prottype) in the
+ wsdl.</p>
+ <p>The <code style="font-weight: bold;">tuscany-war-plugin</code> is
+ used to add both the Tuscany runtime and any Tuscany&nbsp;
+ extensions required by the application in the war file.. Looking
+ at the pom.xml and search for &nbsp;"<code style=
+ "font-weight: bold;">tuscany-war-plugin"</code> you'll find the
+ plugin. &nbsp;Which extension you want loaded are specified in
+ the <code><span style=
+ "font-weight: bold;">extensions</span></code> section. The format
+ for this&nbsp; closely follows Maven's artifact naming. &nbsp;The
+ boolean <code><span style=
+ "font-weight: bold;">loadExtensionDependencies</span></code>
+ option if true will &nbsp;resolve all dependencies for each
+ extension listed here and also include them in the war file.
+ &nbsp;<br>
+ <br>
+
+ <h4>Application</h4>
+
+ <h5><a name="Web.xml" id="Web.xml"></a>Web.xml</h5><p>The web.xml
+ file in each module adds necessary "hooks" to initiate and
+ maintain the Tuscany SCA runtime in a web application host.<br>
+ &nbsp;</p>
+
+ <table style="text-align: left; width: 100%;" border="1"
+ cellpadding="2" cellspacing="2">
+ <tbody>
+ <tr>
+ <td>
+ <pre>
+<small>&lt;listener&gt;<br>
+&lt;listener-class&gt;org.apache.tuscany.runtime.webapp.TuscanyContextListener&lt;/listener-class&gt;<br>
+&lt;/listener&gt;</small>
+</pre>
+ </td>
+
+ <td>This class initializes the Tuscany runtime when the
+ applications is started and helps finalize the Tuscany
+ runtime when the application has ended.</td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<small>&lt;servlet&gt;<br>
+&lt;servlet-name&gt;TuscanyServlet&lt;/servlet-name&gt;<br>
+&lt;display-name&gt;Tuscany Servlet&lt;/display-name&gt;<br>
+&lt;servlet-class&gt;org.apache.tuscany.runtime.webapp.TuscanyServlet&lt;/servlet-class&gt;<br>
+&lt;/servlet&gt;</small>
+</pre>
+ </td>
+
+ <td>This class provides the web applications servlet
+ interface to SCA components. &nbsp;The Axis websevices
+ binding extension requires this.</td>
+ </tr>
+
+ <tr>
+ <td>
+ <pre>
+<small>&lt;listener&gt;<br>
+&lt;listener-class&gt;org.apache.tuscany.runtime.webapp.TuscanySessionListener&lt;/listener-class&gt;<br>
+&lt;/listener&gt;</small>
+</pre>
+ </td>
+
+ <td>This listener helps provide SCA session support .</td>
+ </tr>
+ </tbody>
+ </table><br>
+ <p>The web application can be run in offline or online when
+ resolving dependencies required by the application or it's
+ required extensions. This is configured in the web.xml with the
+ context-param element with a parameter name <code><span style=
+ "font-weight: bold;">tuscany.online</span></code>. If&nbsp; not
+ specified or set to true, dependencies are resolved by searching
+ the local war repository, the local Maven repository, and remote
+ repositories. If specified and set to false, the remote
+ repositories will not be searched.</p>
+
+ <h5><a name="SCDL" id="SCDL"></a>SCDL</h5>
+ <p>Each module's SCA
+ application SCDL is located in the web application&nbsp;
+ WEB-INF/default.scdl file. &nbsp;This is the default location,
+ but within the web.xml it is possible to override this with a
+ context-param element &nbsp;with the name <code><span style=
+ "font-weight: bold;">tuscany.applicationScdlPath</span></code>.
+ &nbsp;The Tuscany System SCDL can also be overridden with another
+ context-param element with the name <code><span style=
+ "font-weight: bold;">tuscany.systemScdlPath</span></code>.<br>
+ The SCDL&nbsp; used by the BigBank application is defined by
+ <a href=
+ "http://www.osoa.org/download/attachments/35/SCA_AssemblyModel_V096.pdf?version=1"
+ target="_blank">SCA Assembly Model V0.96</a> , <a href=
+ "http://www.osoa.org/download/attachments/35/SCA_ClientAndImplementationModelforJava_v0.95.pdf?version=3"
+ target="_blank">SCA Client and Implementation Model for Java
+ (V0.95)</a> &nbsp;and the <a href=
+ "http://www.osoa.org/download/attachments/35/SCA_WebServiceBindings_V096-draft1.pdf?version=3"
+ target="_blank">SCA Web Service bindings</a> specifications.<br>
+ There is one extension to SCDL used by BigBank that is specific
+ to Tuscany that is used by SDO databinding extension.
+ &nbsp;The&nbsp;<code>import.sdo</code> element in the SCDL
+ specifies which&nbsp; SDO factories to register the SDO types.
+ &nbsp;In the case of BigBank the factory is the class generated
+ by the&nbsp;<code style=
+ "font-weight: bold;">tuscany-sdo-plugin</code> maven plugin. An
+ example of this follows:</p>
+ <pre>
+ <code>&lt;dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2"
+factory="com.bigbank.account.AccountFactory"/&gt; <br>
+</code>
+</pre>
+
+ <h5>Code</h5><p>The Java code for the most part just implements the
+ Web interface and the SCA components necessary to implement the
+ business logic. The code uses Java 5.0 annotations as documented
+ by the <a href=
+ "http://www.osoa.org/download/attachments/35/SCA_ClientAndImplementationModelforJava_v0.95.pdf?version=3"
+ target="_blank">SCA Client and Implementation Model for Java
+ (V0.95)</a> specifications. The samples uses one annotation that
+ is an Tuscany extension that is used by the databinding framework
+ to identify that the components expect to SDO s for complex data
+ types. An example of this is seen in the AccountService interface
+ which has the <code style=
+ "font-weight: bold;">@DataType(name="commonj.sdo.DataObject")</code>
+ annotation.</p>
+
+ <h4><a name="DAS_" id="DAS_"></a><span style=
+ "font-family: monospace;">RDB DAS</span></h4>
+
+ <p>The Relational Database DAS (RDB DAS) is used in this sample to access relational data in terms
+ of SDOs. All the code pertaining to this usage is contained to two one files:
+ AccountDataServiceDASImpl.java and DasAccountConfiguration.xml. The java file provides code that
+ instantiates and invokes the DAS and the XML file provides RDB DAS configuration.</p>
+
+ <p>The sample demonstrates a few of the RDB DAS capabilities including:</p>
+
+ <ul>
+
+ <li>reading a graph of SDOs based on a select query provided inline </li>
+ <li>reading a graph of SDOs based on a named select query defined in the config file </li>
+ <li>executing a named command to manually insert data</li>
+ <li>leveraging SDO Change Summary to by utilizing the DAS "applyChanges" method to flush graph modifications </li>
+ <li>utilizing the DAS column-converter framework </li>
+ <li>using the column/property name mapping (aliasing)</li>
+
+ </ul>
+
+ <p>This sample does not currently demonstrate a few other key DAS features including Object relationships, optimistic
+ concurrency control, and the use of convention over configuration. User level documentation for the RDB DAS can
+ be found in the <a href=
+ "http://wiki.apache.org/ws/Tuscany/TuscanyJava/DAS_Java_Overview/RDBDAS_Java_User_Guide"target="_blank">RDBDAS User's Guide</a>.
+ </p>
+ <p>This sample uses the RDB DAS as a utility. A future version of this sample will access the DAS as an SCA service.
+ </p>
+
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.pmd b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.pmd
new file mode 100644
index 0000000000..ffc4fe2bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.ruleset b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.ruleset
new file mode 100644
index 0000000000..ba9b5ce886
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/pom.xml
new file mode 100644
index 0000000000..a4b5087149
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/pom.xml
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples.bigbank</groupId>
+ <artifactId>bigbank-scenario</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-bigbank-webclient</artifactId>
+ <packaging>war</packaging>
+ <name>Tuscany BigBank Web Client Module</name>
+ <description>BigBank Scenario Sample - Web Front-End Module</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.0.1</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- SDO's XMLStreamHelper requires StAX API and impl (it's not pulled by
+ tuscany-sdo-impl because the maven dependency scope is provided -->
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>${sdoVersion}</version>
+ <executions>
+ <execution>
+ <configuration>
+ <schemaFile>${basedir}/src/main/resources/wsdl/AccountService.wsdl</schemaFile>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-plugin-wsdl2java</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <configuration>
+ <wsdlFile>${basedir}/src/main/resources/wsdl/AccountService.wsdl</wsdlFile>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Set to true to embed external jars for extensions in the WAR -->
+ <!-- Set to false to leave external jars for extensions to be resolved from maven repository -->
+ <loadExtensionDependencies>false</loadExtensionDependencies>
+
+ <extensions>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+
+ </extensions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java
new file mode 100644
index 0000000000..a0f98f14f3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.services.account;
+
+import java.rmi.RemoteException;
+
+import org.osoa.sca.ServiceUnavailableException;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountService;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+
+/**
+ */
+@Service(AccountService.class)
+public class AccountServiceComponentImpl implements AccountService {
+
+ private AccountService accountService;
+
+ @Reference
+ public void setAccountService(AccountService accountService) {
+ this.accountService = accountService;
+ }
+
+ /**
+ *
+ */
+ public AccountServiceComponentImpl() {
+ super();
+ }
+
+ /**
+ * @see bigbank.account.services.account.AccountService#getAccountReport(java.lang.String)
+ */
+ public AccountReport getAccountReport(int customerID) {
+ try {
+ return accountService.getAccountReport(customerID);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public StockSummary purchaseStock(int customerID, StockSummary stockSummary) throws RemoteException {
+ try {
+ return accountService.purchaseStock(customerID, stockSummary);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public CustomerProfileData getCustomerProfile(String param2) throws RemoteException {
+ try {
+ return accountService.getCustomerProfile(param2);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public float deposit(String account, float amount) throws RemoteException {
+ try {
+ return accountService.deposit(account, amount);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
+ try {
+ return accountService.sellStock(purchaseLotNumber, quantity);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public float withdraw(String account, float amount) throws RemoteException {
+ try {
+ return accountService.withdraw(account, amount);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+
+ return accountService.createAccount(customerProfile, createSavings, createCheckings);
+ }
+
+ public AccountLog getAccountLog(int customerID) throws RemoteException {
+ try {
+ return accountService.getAccountLog(customerID);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java
new file mode 100644
index 0000000000..b03f533aba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.services.profile;
+
+import java.rmi.RemoteException;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import com.bigbank.account.AccountService;
+import com.bigbank.account.CustomerProfileData;
+
+@Service(LoginService.class)
+@Scope("MODULE")
+public class AccountLoginServiceImpl implements LoginService {
+
+ public AccountService accountService;
+
+ @Reference
+ public void setAccountService(AccountService accountService) {
+ this.accountService = accountService;
+ }
+
+ public ProfileService profileService;
+
+ @Reference
+ public void setProfileService(ProfileService profileService) {
+ this.profileService = profileService;
+ }
+
+ public int login(String userName, String password) throws RemoteException {
+
+ CustomerProfileData profileData = accountService.getCustomerProfile(userName);
+
+ if (!password.equals(profileData.getPassword())) {
+ return INVALID_PASSWORD;
+ }
+
+ profileService.setLoggedIn(true);
+ profileService.setFirstName(profileData.getFirstName());
+ profileService.setLastName(profileData.getLastName());
+ profileService.setId(profileData.getId());
+
+ return SUCCESS;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java
new file mode 100644
index 0000000000..c688df2597
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.services.profile;
+
+import java.rmi.RemoteException;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface LoginService {
+
+ static final int SUCCESS = 1;
+
+ static final int INVALID_LOGIN = -1;
+
+ static final int INVALID_PASSWORD = -2;
+
+ int login(String userName, String password) throws RemoteException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java
new file mode 100644
index 0000000000..551d80c935
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.services.profile;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface ProfileService {
+
+ String getFirstName();
+
+ void setFirstName(String pName);
+
+ String getLastName();
+
+ void setLastName(String pName);
+
+ boolean isLoggedIn();
+
+ void setLoggedIn(boolean pStatus);
+
+ int getId();
+
+ void setId(int pId);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java
new file mode 100644
index 0000000000..5385a7c3fc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.services.profile;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(ProfileService.class)
+@Scope("SESSION")
+public class ProfileServiceImpl implements ProfileService {
+
+ private String firstName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ @Property
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ private String lastName;
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ private boolean loggedIn;
+
+ public boolean isLoggedIn() {
+ return loggedIn;
+ }
+
+ public void setLoggedIn(boolean status) {
+ loggedIn = status;
+ }
+
+ private int id;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java
new file mode 100644
index 0000000000..711c6ba0b9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.services.profile;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(LoginService.class)
+public class SimpleLoginServiceImpl implements LoginService {
+
+ public ProfileService profileService;
+
+ @Reference
+ public void setProfileService(ProfileService profileService) {
+ this.profileService = profileService;
+ }
+
+ public int login(String userName, String password) {
+
+ if (!"test".equals(userName)) {
+ return INVALID_LOGIN;
+ }
+
+ if (!"password".equals(password)) {
+ return INVALID_PASSWORD;
+ }
+
+ profileService.setLoggedIn(true);
+ profileService.setFirstName("John");
+ profileService.setLastName("Doe");
+ profileService.setId(12345);
+
+ return SUCCESS;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java
new file mode 100644
index 0000000000..08751bdc3d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.tags.account;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import bigbank.webclient.services.profile.ProfileService;
+
+import com.bigbank.account.AccountLog;
+import com.bigbank.account.AccountService;
+
+public class AccountLogTag extends TagSupport {
+
+ public AccountLogTag() {
+ super();
+ }
+
+ private String mAccountService;
+
+ public String getAccountService() {
+ return mAccountService;
+ }
+
+ public void setAccountService(String pAccountService) {
+ mAccountService = pAccountService;
+ }
+
+ private String mProfileService;
+
+ public String getProfileService() {
+ return mProfileService;
+ }
+
+ public void setProfileService(String pProfileService) {
+ mProfileService = pProfileService;
+ }
+
+ private String mId;
+
+ @Override
+ public String getId() {
+ return mId;
+ }
+
+ @Override
+ public void setId(String pId) {
+ mId = pId;
+ }
+
+ private Iterator mIterator;
+
+ @Override
+ public int doStartTag() throws JspException {
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+
+ ProfileService profile = moduleContext.locateService(ProfileService.class, mProfileService);
+
+ if (profile == null) {
+ throw new JspException("Profile [" + mProfileService + "] not found in current module context");
+ }
+
+ AccountService service = (AccountService) moduleContext.locateService(AccountService.class, mAccountService);
+ if (service == null) {
+ throw new JspException("Service [" + mAccountService + "] not found in current module context");
+ }
+ List entries;
+ try {
+ AccountLog accountLog = service.getAccountLog(profile.getId());
+ pageContext.setAttribute("StockLogEntries", accountLog.getStockLogEntries());
+ entries = accountLog.getAccountLogEntries();
+ } catch (Exception e) {
+ throw new JspException(e);
+ }
+ mIterator = entries.iterator();
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_INCLUDE;
+ } else {
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public int doAfterBody() {
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_AGAIN;
+ } else {
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public void release() {
+ super.release();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java
new file mode 100644
index 0000000000..3733cc84dd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.tags.account;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import bigbank.webclient.services.profile.ProfileService;
+
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountService;
+
+/**
+ * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component
+ */
+
+public class AccountStatusTag extends TagSupport {
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public AccountStatusTag() {
+ super();
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ private String mAccountService;
+
+ public String getAccountService() {
+ return mAccountService;
+ }
+
+ public void setAccountService(String pAccountService) {
+ mAccountService = pAccountService;
+ }
+
+ private String mProfileService;
+
+ public String getProfileService() {
+ return mProfileService;
+ }
+
+ public void setProfileService(String pProfileService) {
+ mProfileService = pProfileService;
+ }
+
+ private String mId;
+
+ @Override
+ public String getId() {
+ return mId;
+ }
+
+ @Override
+ public void setId(String pId) {
+ mId = pId;
+ }
+
+ private Iterator mIterator;
+
+ @Override
+ public int doStartTag() throws JspException {
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+
+ ProfileService profile = moduleContext.locateService(ProfileService.class, mProfileService);
+
+ if (profile == null) {
+ throw new JspException("Profile [" + mProfileService + "] not found in current module context");
+ }
+
+ AccountService service = (AccountService) moduleContext.locateService(AccountService.class, mAccountService);
+
+ if (service == null) {
+ throw new JspException("Service [" + mAccountService + "] not found in current module context");
+ }
+ List summaries;
+ try {
+ AccountReport accountReport = service.getAccountReport(profile.getId());
+ pageContext.setAttribute("StockSummaries", accountReport.getStockSummaries());
+ summaries = accountReport.getAccountSummaries();
+ } catch (Exception e) {
+ throw new JspException(e);
+ }
+ mIterator = summaries.iterator();
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_INCLUDE;
+ } else {
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public int doAfterBody() {
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_AGAIN;
+ } else {
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public void release() {
+ super.release();
+ mId = null;
+ mIterator = null;
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java
new file mode 100644
index 0000000000..ea2df8aa55
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.tags.account;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+public class StockLogTag extends TagSupport {
+
+ public StockLogTag() {
+ super();
+ }
+
+ private String mId;
+
+ @Override
+ public String getId() {
+ return mId;
+ }
+
+ @Override
+ public void setId(String pId) {
+ mId = pId;
+ }
+
+ private Iterator mIterator;
+
+ @Override
+ public int doStartTag() throws JspException {
+
+ List entries = (List) pageContext.getAttribute("StockLogEntries");
+ if (null == entries) {
+ return SKIP_BODY;
+ }
+ mIterator = entries.iterator();
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_INCLUDE;
+ } else {
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public int doAfterBody() {
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_AGAIN;
+ } else {
+ pageContext.setAttribute("StockLogEntries", null);
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public void release() {
+ pageContext.setAttribute("StockLogEntries", null);
+ super.release();
+ mId = null;
+ mIterator = null;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java
new file mode 100644
index 0000000000..b2c61193e7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.tags.account;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+/**
+ * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component
+ */
+
+public class StockStatusTag extends TagSupport {
+
+ public StockStatusTag() {
+ super();
+ }
+
+ private String mId;
+
+ @Override
+ public String getId() {
+ return mId;
+ }
+
+ @Override
+ public void setId(String pId) {
+ mId = pId;
+ }
+
+ private Iterator mIterator;
+
+ @Override
+ public int doStartTag() throws JspException {
+
+ List summaries = (List) pageContext.getAttribute("StockSummaries");
+ if (null == summaries) {
+ return SKIP_BODY;
+ }
+ mIterator = summaries.iterator();
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_INCLUDE;
+ } else {
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public int doAfterBody() {
+ if (mIterator.hasNext()) {
+ pageContext.setAttribute(mId, mIterator.next());
+ return EVAL_BODY_AGAIN;
+ } else {
+ pageContext.setAttribute("StockSummaries", null);
+ return SKIP_BODY;
+ }
+ }
+
+ @Override
+ public void release() {
+ pageContext.setAttribute("StockSummaries", null);
+ super.release();
+ mId = null;
+ mIterator = null;
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java
new file mode 100644
index 0000000000..6c50595d0f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.tags.sca;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import bigbank.webclient.services.profile.ProfileService;
+
+public class LoginBarrierTag extends TagSupport {
+
+ public LoginBarrierTag() {
+ super();
+ }
+
+ private String mProfile;
+
+ public String getProfile() {
+ return mProfile;
+ }
+
+ public void setProfile(String pProfile) {
+ mProfile = pProfile;
+ }
+
+ private String mUrl;
+
+ public String getUrl() {
+ return mUrl;
+ }
+
+ public void setUrl(String pUrl) {
+ mUrl = pUrl;
+ }
+
+ int doPage = EVAL_PAGE;
+
+ @Override
+ public int doStartTag() throws JspException {
+ if (mProfile == null || mProfile.length() < 1) {
+ throw new JspException("Invalid profile location specified");
+ }
+
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+
+ ProfileService profile = moduleContext.locateService(ProfileService.class, mProfile);
+
+ if (profile == null) {
+ throw new JspException("Profile [" + mProfile + "] not found in current module context");
+ }
+
+ if (profile.isLoggedIn()) {
+ return EVAL_BODY_INCLUDE;
+ } else {
+ try {
+ doPage = SKIP_PAGE;
+ pageContext.forward(mUrl);
+ ((HttpServletResponse) (pageContext.getResponse())).sendRedirect("login.html");
+ return SKIP_BODY;
+ } catch (ServletException e) {
+ throw new JspException("Unable to forward to [" + mUrl + "]");
+ } catch (IOException e) {
+ throw new JspException("Unable to forward to [" + mUrl + "]");
+ }
+ }
+ }
+
+ @Override
+ public int doEndTag() throws JspException {
+ return doPage;
+ }
+
+ @Override
+ public void release() {
+ super.release();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java
new file mode 100644
index 0000000000..d1263377c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.tags.sca;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * Places an SCA service in the JSP page context, making it available to other tags corresponding to its id value.
+ */
+
+public class ServiceTag extends TagSupport {
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public ServiceTag() {
+ super();
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ private String mName;
+
+ /**
+ * Returns the name of the SCA service to import into the page context.
+ */
+ public String getName() {
+ return mName;
+ }
+
+ /**
+ * Sets name of the SCA service to import into the page context.
+ */
+ public void setName(String pName) {
+ mName = pName;
+ }
+
+ private String mId;
+
+ /**
+ * Returns the id of the service in the page context
+ */
+ @Override
+ public String getId() {
+ return mId;
+ }
+
+ /**
+ * Sets the id of the service for the page context
+ */
+
+ @Override
+ public void setId(String pId) {
+ mId = pId;
+ }
+
+ @Override
+ public int doStartTag() throws JspException {
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+
+ Object service = moduleContext.locateService(Object.class, mName);
+
+ if (service == null) {
+ throw new JspException("Service [" + mName + "] not found in current module context");
+ }
+ if (mId == null) {
+ // if the Id name was not specified, default to the basic name of the
+ // service
+ mId = mName;
+ }
+ pageContext.setAttribute(mId, service);
+ return EVAL_BODY_INCLUDE;
+ }
+
+ @Override
+ public int doEndTag() throws JspException {
+ return EVAL_PAGE;
+ }
+
+ @Override
+ public void release() {
+ super.release();
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java
new file mode 100644
index 0000000000..3acdbee845
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.ui;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import bigbank.webclient.services.profile.ProfileService;
+
+import com.bigbank.account.AccountFactory;
+import com.bigbank.account.AccountService;
+import com.bigbank.account.CustomerProfileData;
+import com.bigbank.account.StockSummary;
+
+public class FormServlet extends HttpServlet {
+
+ // private ServletContext mContext;
+ // public void init(ServletConfig pCfg) throws ServletException {
+ // mContext = pCfg.getServletContext();
+ // }
+
+ @Override
+ public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException {
+
+ try {
+ final String action = pReq.getParameter("action");
+
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+ AccountService accountServices = (AccountService) moduleContext.locateService(AccountService.class, "AccountServiceComponent");
+ if (accountServices == null) {
+ throw new ServletException("AccountServiceComponent");
+ }
+ ProfileService profileServices = null;
+ if (!"createAccount".equals(action)) {
+ profileServices = moduleContext.locateService(ProfileService.class, "ProfileServiceComponent");
+ if (profileServices == null) {
+ throw new ServletException("ProfileServiceComponent not found.");
+ }
+ if (!profileServices.isLoggedIn()) {
+ throw new ServletException("User id '" + profileServices.getId() + "' not logged on.");
+ }
+ }
+
+ if ("createAccount".equals(action)) {
+ createAccount(pReq, pResp, accountServices);
+ } else if ("account".equals(action)) {
+ accountTransaction(pReq, pResp, accountServices);
+ } else if ("stockPurchase".equals(action)) {
+ stockPurchase(pReq, pResp, profileServices, accountServices);
+ } else if ("stockSale".equals(action)) {
+ stockSale(pReq, pResp, profileServices, accountServices);
+ } else {
+ throw new IllegalArgumentException("Unknown action in Form servlet '" + action + "'.");
+ }
+ // mContext.getRequestDispatcher("summary.jsp").forward(pReq, pResp);
+ pResp.sendRedirect("summary.jsp");
+ } catch (ServletException e) {
+ e.printStackTrace();
+ throw e;
+
+ } catch (Exception e) {
+
+ throw new ServletException(e);
+ }
+
+ }
+
+ private void stockSale(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices)
+ throws ServletException {
+ try {
+ if (!"cancel".equals(req.getParameter("cancel"))) {
+
+ int quantity = Integer.parseInt(req.getParameter("quantity"));
+ int purchaseLotNumber = Integer.parseInt(req.getParameter("purchaseLotNumber"));
+ accountServices.sellStock(purchaseLotNumber, quantity);
+ }
+
+ } catch (Exception e) {
+
+ throw new ServletException("stockSale " + e.getMessage(), e);
+ }
+
+ }
+
+ private void stockPurchase(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices)
+ throws ServletException {
+ try {
+ if (!"cancel".equals(req.getParameter("cancel"))) {
+
+ String symbol = req.getParameter("symbol").trim().toUpperCase();
+ int quantity = Integer.parseInt(req.getParameter("quantity"));
+ StockSummary stockSummry = AccountFactory.INSTANCE.createStockSummary();
+ stockSummry.setSymbol(symbol);
+ stockSummry.setQuantity(quantity);
+ accountServices.purchaseStock(profileServices.getId(), stockSummry);
+ }
+ } catch (Exception e) {
+ throw new ServletException("stockPurchase " + e.getMessage(), e);
+ }
+ }
+
+ private void accountTransaction(HttpServletRequest req, HttpServletResponse resp, AccountService accountServices) throws ServletException {
+ try {
+ if (!"cancel".equals(req.getParameter("cancel"))) {
+ String account = req.getParameter("account");
+ String amount = req.getParameter("Amount");
+ if ("deposit".equals(req.getParameter("actionType"))) {
+ accountServices.deposit(account, Float.parseFloat(amount));
+ } else {
+ accountServices.withdraw(account, Float.parseFloat(amount));
+ }
+ }
+ } catch (Exception e) {
+ throw new ServletException("accountTransaction " + e.getMessage(), e);
+ }
+
+ }
+
+ private void createAccount(HttpServletRequest pReq, HttpServletResponse pResp, AccountService accountServices) throws ServletException {
+ try {
+ CustomerProfileData customerProfileData = AccountFactory.INSTANCE.createCustomerProfileData();
+ customerProfileData.setFirstName(pReq.getParameter("firstName"));
+ customerProfileData.setLastName(pReq.getParameter("lastName"));
+ customerProfileData.setAddress(pReq.getParameter("address"));
+ customerProfileData.setEmail(pReq.getParameter("email"));
+ customerProfileData.setLoginID(pReq.getParameter("loginID"));
+ customerProfileData.setPassword(pReq.getParameter("password"));
+
+ CustomerProfileData resp = accountServices.createAccount(customerProfileData, "savings".equals(pReq.getParameter("savings")), "checkings"
+ .equals(pReq.getParameter("checkings")));
+ LoginServlet.login(resp.getLoginID(), resp.getPassword());
+
+ } catch (IOException e) {
+ throw new ServletException(e);
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java
new file mode 100644
index 0000000000..784cc4fb40
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.ui;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import bigbank.webclient.services.profile.LoginService;
+
+public class LoginServlet extends HttpServlet {
+
+ @Override
+ public void init(ServletConfig pCfg) throws ServletException {
+
+ }
+
+ @Override
+ public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException {
+
+ if ("logout".equals(pReq.getParameter("logout")) || "logoutHIDDEN".equals(pReq.getParameter("logoutHIDDEN"))) {
+ HttpSession sess = pReq.getSession();
+ if (sess != null) {
+ sess.invalidate();
+ }
+ try {
+ pResp.sendRedirect("login.html");
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ throw new ServletException(e);
+ }
+
+ } else {
+ pReq.getSession(); // make sure session started.
+ String login = pReq.getParameter("login");
+ String password = pReq.getParameter("password");
+ try {
+ int resp = login(login, password);
+ if (resp == LoginService.SUCCESS) {
+
+ pResp.sendRedirect("summary.jsp");
+ } else {
+
+ pResp.sendRedirect("login.html");
+ }
+ } catch (IOException e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+
+ static int login(final String login, final String password) throws ServletException {
+
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+ LoginService loginMgr = moduleContext.locateService(LoginService.class, "LoginServiceComponent");
+
+ if (loginMgr == null) {
+ throw new ServletException("LoginManager not found");
+ }
+
+ try {
+ return loginMgr.login(login, password);
+ } catch (RemoteException e) {
+
+ throw new ServletException(e);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl
new file mode 100644
index 0000000000..124db9ac04
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl
@@ -0,0 +1,466 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/account"
+ targetNamespace="http://www.bigbank.com/account"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/account"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/account"
+
+ > <!-- xmlns:sdojava="commonj.sdo/java" sdojava:package="org.apache.tuscany.samples.bigbank.account" -->
+
+
+<!-- <xsd:complexType name="DataGraphRoot">
+ <xsd:sequence>
+ <xsd:element name="customerProfileData" type="account:CustomerProfileData" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="StockSummaries" type="account:StockSummary" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="AccountSummaries" type="account:AccountSummary" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="StockLogEntries" type="account:StockLogEntry" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="AccountLogEntries" type="account:AccountLogEntry" maxOccurs="unbounded" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>-->
+
+
+ <xsd:element name="getAccountReport">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID"
+ type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport"
+ type="account:AccountReport" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummaries"
+ type="account:AccountSummary" maxOccurs="unbounded" />
+ <xsd:element name="stockSummaries"
+ type="account:StockSummary" maxOccurs="unbounded" />
+
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:attribute name="accountNumber" type="xsd:string" />
+ <xsd:attribute name="accountType" type="xsd:string" />
+ <xsd:attribute name="balance" type="xsd:float" />
+ </xsd:complexType>
+
+ <xsd:complexType name="StockSummary">
+ <xsd:attribute name="purchaseLotNumber" type="xsd:int" />
+ <!-- unique id for this purchase -->
+ <xsd:attribute name="symbol" type="xsd:string" />
+ <xsd:attribute name="quantity" type="xsd:int" />
+ <xsd:attribute name="purchaseDate" type="xsd:dateTime" />
+ <xsd:attribute name="purchasePrice" type="xsd:float" />
+ <xsd:attribute name="currentPrice" type="xsd:float" />
+ <xsd:attribute name="company" type="xsd:string" />
+ <xsd:attribute name="highPrice" type="xsd:float" />
+ <xsd:attribute name="lowPrice" type="xsd:float" />
+
+ </xsd:complexType>
+
+ <!-- Profile in data base -->
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="CustomerProfileData">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ <xsd:element name="address" type="xsd:string" />
+ <xsd:element name="email" type="xsd:string" />
+ <xsd:element name="loginID" type="xsd:string" />
+ <xsd:element name="password" type="xsd:string" />
+ <xsd:element name="id" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="withdraw">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountNumber"
+ type="xsd:string" />
+ <xsd:element name="amount" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="withdrawResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="balance" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="deposit">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountNumber"
+ type="xsd:string" />
+ <xsd:element name="amount" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="depositResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="balance" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="purchaseStock">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="id" type="xsd:int" />
+ <xsd:element name="stock" type="account:StockSummary" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="purchaseStockResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="purchaseSummary"
+ type="account:StockSummary" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+
+
+ <xsd:element name="sellStock">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="purchaseLotNumber"
+ type="xsd:int" /><!-- unique id for this purchase -->
+ <xsd:element name="quantity" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="createAccount">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ <xsd:element name="createSavings"
+ type="xsd:boolean" />
+ <xsd:element name="createCheckings"
+ type="xsd:boolean" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="createAccountResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:element>
+
+ <xsd:element name="getAccountLog">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID"
+ type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountLogResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountLog"
+ type="account:AccountLog" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="AccountLog">
+ <xsd:sequence>
+ <xsd:element name="accountLogEntries"
+ type="account:AccountLogEntry" maxOccurs="unbounded" />
+ <xsd:element name="stockLogEntries"
+ type="account:StockLogEntry" maxOccurs="unbounded" />
+
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="AccountLogEntry">
+ <xsd:attribute name="logSeqNo" type="xsd:int" />
+ <xsd:attribute name="id" type="xsd:int" />
+ <xsd:attribute name="accountNumber" type="xsd:string" />
+ <xsd:attribute name="actionType" type="xsd:string" />
+ <xsd:attribute name="amount" type="xsd:float" />
+ </xsd:complexType>
+
+ <xsd:complexType name="StockLogEntry">
+ <xsd:attribute name="logSeqNo" type="xsd:int" />
+ <xsd:attribute name="id" type="xsd:int" />
+ <xsd:attribute name="symbol" type="xsd:string" />
+ <xsd:attribute name="quantity" type="xsd:int" />
+ <xsd:attribute name="actionType" type="xsd:string" />
+ <xsd:attribute name="purchaseLotNumber" type="xsd:int" />
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="account:getAccountReport"
+ name="getAccountReportRequest" />
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="account:getAccountReportResponse"
+ name="getAccountReportResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="account:getCustomerProfile"
+ name="getCustomerProfile" />
+ </wsdl:message>
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="account:getCustomerProfileResponse"
+ name="getCustomerProfileResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="withdrawRequest">
+ <wsdl:part element="account:withdraw" name="withdrawRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="withdrawResponse">
+ <wsdl:part element="account:withdrawResponse"
+ name="withdrawResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="depositRequest">
+ <wsdl:part element="account:deposit" name="depositRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="depositResponse">
+ <wsdl:part element="account:depositResponse"
+ name="depositResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="purchaseStockRequest">
+ <wsdl:part element="account:purchaseStock"
+ name="purchaseStockRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="purchaseStockResponse">
+ <wsdl:part element="account:purchaseStockResponse"
+ name="purchaseStockResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="sellStockRequest">
+ <wsdl:part element="account:sellStock" name="sellStockRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="createAccountRequest">
+ <wsdl:part element="account:createAccount" name="createAccountRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="createAccountResponse">
+ <wsdl:part element="account:createAccountResponse" name="createAccountResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="getAccountLogRequest">
+ <wsdl:part element="account:getAccountLog"
+ name="getAccountLogRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="getAccountLogResponse">
+ <wsdl:part element="account:getAccountLogResponse"
+ name="getAccountLogResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="account:getAccountReportRequest" />
+ <wsdl:output message="account:getAccountReportResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="account:getCustomerProfileRequest" />
+ <wsdl:output message="account:getCustomerProfileResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="withdraw">
+ <wsdl:input message="account:withdrawRequest" />
+ <wsdl:output message="account:withdrawResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="deposit">
+ <wsdl:input message="account:depositRequest" />
+ <wsdl:output message="account:depositResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="purchaseStock">
+ <wsdl:input message="account:purchaseStockRequest" />
+ <wsdl:output message="account:purchaseStockResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="sellStock">
+ <wsdl:input message="account:sellStockRequest" />
+ <wsdl:output message="account:purchaseStockResponse" />
+ </wsdl:operation>
+
+
+ <wsdl:operation name="createAccount">
+ <wsdl:input message="account:createAccountRequest" />
+ <wsdl:output message="account:createAccountResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="getAccountLog">
+ <wsdl:input message="account:getAccountLogRequest" />
+ <wsdl:output message="account:getAccountLogResponse" />
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+
+
+ <wsdl:binding name="AccountServiceSOAP" type="account:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getAccountReport" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getCustomerProfile">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getCustomerProfile" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="withdraw">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/withdraw" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="deposit">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/deposit" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="purchaseStock">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/purchaseStock" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="sellStock">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/sellStock" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="createAccount">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/createAccount" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="getAccountLog">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getAccountLog" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="account:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address
+ location="http://localhost:8080/sample-bigbank-account/services/AccountService" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/CustomerProfile.jsp b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/CustomerProfile.jsp
new file mode 100644
index 0000000000..2dc17a8867
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/CustomerProfile.jsp
@@ -0,0 +1,100 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+<HTML>
+<HEAD>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<META http-equiv="Content-Style-Type" content="text/css">
+<%-- LINK href="theme/Master.css" rel="stylesheet" type="text/css" --%>
+<TITLE>BigBank- Customer Account</TITLE>
+</HEAD>
+<BODY><P><FONT size="+1">Customer Account</FONT><BR>
+<BR>
+</P>
+<FORM method="post" action="FormServlet">
+<input type="hidden" name="action" value='createAccount' />
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD>First name </TD>
+ <TD width="10%"></TD>
+ <TD><INPUT type="text" name="firstName" size="20"></TD>
+ </TR>
+ <TR>
+ <TD>Last name</TD>
+ <TD></TD>
+ <TD><INPUT type="text" name="lastName" size="20"></TD>
+ </TR>
+ <TR>
+ <TD>Address</TD>
+ <TD></TD>
+ <TD><INPUT type="text" name="address" size="36" maxlength="170"></TD>
+ </TR>
+ <TR>
+ <TD>email</TD>
+ <TD></TD>
+ <TD><INPUT type="text" name="email" size="16" maxlength="39"></TD>
+ </TR>
+ <TR>
+ <TD>&nbsp;</TD>
+ <TD></TD>
+ <TD></TD>
+ </TR>
+ <TR>
+ <TD>Checkings</TD>
+ <TD></TD>
+ <TD><INPUT type="checkbox" name="checkings" value="checkings" checked></TD>
+ </TR>
+ <TR>
+ <TD>Savings</TD>
+ <TD></TD>
+ <TD><INPUT type="checkbox" name="savings" value="savings" checked></TD>
+ </TR>
+ <TR>
+ <TD>&nbsp;</TD>
+ <TD></TD>
+ <TD></TD>
+ </TR>
+ <TR>
+ <TD>Logon ID</TD>
+ <TD></TD>
+ <TD><INPUT type="text" name="loginID" size="20"></TD>
+ </TR>
+ <TR>
+ <TD>Password</TD>
+ <TD></TD>
+ <TD><INPUT type="password" name="password" size="20"></TD>
+ </TR>
+ <TR>
+ <TD></TD>
+ <TD></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<BR>
+<INPUT type="submit" name="update" value="update">&nbsp;&nbsp;
+<INPUT type="button" name="cancel" value="cancel"></FORM>
+<P><BR>
+</P>
+</BODY>
+</HTML>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld
new file mode 100644
index 0000000000..a3d92a2e46
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">
+ <tlibversion>1.0</tlibversion>
+ <jspversion>2.0</jspversion>
+ <shortname>BigBank Tags</shortname>
+ <info>Tag library containing BigBank tags</info>
+ <tag>
+ <name>service</name>
+ <tagclass>bigbank.webclient.tags.sca.ServiceTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>Places a reference to an SCA Service in the page context</info>
+ <attribute>
+ <name>id</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+ <tag>
+ <name>login</name>
+ <tagclass>bigbank.webclient.tags.sca.LoginBarrierTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>Redirects if user is not logged in</info>
+ <attribute>
+ <name>profile</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>url</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+
+ </tag>
+ <tag>
+ <name>accountStatus</name>
+ <tagclass>bigbank.webclient.tags.account.AccountStatusTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>Accesses and iterates the account service</info>
+ <attribute>
+ <name>id</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>accountService</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>profileService</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+ <tag>
+ <name>stockStatus</name>
+ <tagclass>bigbank.webclient.tags.account.StockStatusTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>Accesses and iterates the stocks</info>
+ <attribute>
+ <name>id</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <name>accountLog</name>
+ <tagclass>bigbank.webclient.tags.account.AccountLogTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>Accesses and iterates the accounts log</info>
+ <attribute>
+ <name>id</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>accountService</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>profileService</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+ <tag>
+ <name>stockLog</name>
+ <tagclass>bigbank.webclient.tags.account.StockLogTag</tagclass>
+ <bodycontent>JSP</bodycontent>
+ <info>Accesses and iterates the stocks log</info>
+ <attribute>
+ <name>id</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+
+</taglib>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..31708af810
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="bigbank.webclient">
+
+
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" factory="com.bigbank.account.AccountFactory"/>
+
+ <component name="LoginServiceComponent">
+ <implementation.java class="bigbank.webclient.services.profile.AccountLoginServiceImpl"/>
+ <reference name="accountService">AccountServiceComponent</reference>
+ <reference name="profileService">ProfileServiceComponent</reference>
+ </component>
+
+ <property name="name" type="xsd:string">Anonymous</property>
+
+ <component name="ProfileServiceComponent">
+ <implementation.java class="bigbank.webclient.services.profile.ProfileServiceImpl"/>
+ <property name="firstName" source="$name"/>
+ </component>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="bigbank.webclient.services.account.AccountServiceComponentImpl"/>
+ <reference name="accountService">AccountService</reference>
+ </component>
+
+
+ <reference name="AccountService">
+ <interface.wsdl interface="http://www.bigbank.com/account#wsdl.interface(AccountService)" wsdli:wsdlLocation="http://www.bigbank.com/account wsdl/AccountService.wsdl" />
+ <binding.ws endpoint="http://www.bigbank.com/account#wsdl.endpoint(AccountService/AccountServiceSOAP)"
+ location="wsdl/AccountService.wsdl" />
+ </reference>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a0ebdf18b0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>Tuscany Bigbank Web UI sample</display-name>
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>login.html</welcome-file>
+ </welcome-file-list>
+
+ <filter>
+ <filter-name>TuscanyFilter</filter-name>
+ <filter-class>org.apache.tuscany.runtime.webapp.TuscanyFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>TuscanyFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <context-param>
+ <param-name>tuscany.online</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanySessionListener</listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyRequestListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>LoginServlet</servlet-name>
+ <servlet-class>bigbank.webclient.ui.LoginServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>FormServlet</servlet-name>
+ <servlet-class>bigbank.webclient.ui.FormServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>LoginServlet</servlet-name>
+ <url-pattern>/loginAction/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>FormServlet</servlet-name>
+ <url-pattern>/FormServlet/*</url-pattern>
+ </servlet-mapping>
+
+
+
+
+
+
+
+
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountLog.jsp b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountLog.jsp
new file mode 100644
index 0000000000..6e91a14dcc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountLog.jsp
@@ -0,0 +1,99 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+ <%@ page import="com.bigbank.account.AccountLogEntry" %>
+ <%@ page import="com.bigbank.account.StockLogEntry" %>
+ <%@ page session="true" %>
+ <%@ page autoFlush="true" %>
+ <%@ taglib uri="/WEB-INF/bigbank-tags.tld" prefix="sca" %>
+
+ <html>
+ <title>BigBank Account and Stock Log</title>
+
+ <body>
+
+ Account Log
+
+ <table>
+ <tr>
+ <td><strong>Seq</strong></td>
+ <td><strong>Account</strong></td>
+ <td><strong>Action</strong></td>
+ <td><strong>Amount</strong></td>
+ </tr>
+ <sca:accountLog accountService="AccountServiceComponent" profileService="ProfileServiceComponent" id="accountlogentry">
+ <tr>
+ <td>
+ <jsp:getProperty name="accountlogentry" property="logSeqNo"/>
+ </td>
+ <td>
+ <jsp:getProperty name="accountlogentry" property="accountNumber"/>
+ </td>
+ <td>
+ <jsp:getProperty name="accountlogentry" property="actionType"/>
+ </td>
+ <td>
+ <jsp:getProperty name="accountlogentry" property="amount"/>
+ </td>
+ </tr>
+ </sca:accountLog>
+ </table>
+
+
+
+ <hr/>
+ Stock Log
+
+ <table>
+
+ <tr>
+ <td><strong>Seq</strong></td>
+ <td><strong>Symbol</strong></td>
+ <td><strong>Quantity</strong></td>
+ <td>&nbsp;&nbsp;</td> <%-- spacer --%>
+ <td><strong>Action</strong></td>
+ <td><strong>PurchaseLotNumber</strong></td>
+ </tr>
+ <sca:stockLog id="stocklogentry">
+ <tr>
+ <td>
+ <jsp:getProperty name="stocklogentry" property="logSeqNo"/>
+ </td>
+ <td>
+ <jsp:getProperty name="stocklogentry" property="symbol"/>
+ </td>
+ <td>
+ <jsp:getProperty name="stocklogentry" property="quantity"/>
+ </td>
+ <td>&nbsp;&nbsp;</td> <%-- spacer --%>
+ <td>
+ <jsp:getProperty name="stocklogentry" property="actionType"/>
+ </td>
+
+ <td>
+ <jsp:getProperty name="stocklogentry" property="purchaseLotNumber"/>
+ </td>
+ </tr>
+ </FORM>
+ </sca:stockLog>
+ </table>
+
+
+ </body>
+ </html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountTransaction.jsp b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountTransaction.jsp
new file mode 100644
index 0000000000..4017834867
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/accountTransaction.jsp
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+<HTML>
+<HEAD>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<META name="GENERATOR" content="IBM Software Development Platform">
+<META http-equiv="Content-Style-Type" content="text/css">
+<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
+<TITLE>BigBank - <%=request.getParameter("account") %> </TITLE>
+</HEAD>
+<BODY>
+<P>Account <%= request.getParameter("account") %><BR>
+<BR>
+<BR>
+</P>
+<FORM method="post" action="FormServlet">
+<input type="hidden" name="action" value='account' />
+<input type="hidden" name="account" value='<%= request.getParameter("account") %>' />
+<input type="hidden" name="actionType" value='<%=request.getParameter("transaction")%>' />
+Amount to <%=request.getParameter("transaction")%> <INPUT type="text" name="Amount" size="10"
+ maxlength="10"><BR>
+<BR>
+<BR>
+<BR>
+<INPUT type="submit" name="Submit"
+ value="Submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit"
+ name="cancel" value="cancel">
+</FORM>
+</BODY>
+</HTML>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/login.html b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/login.html
new file mode 100644
index 0000000000..a1a5440a4f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/login.html
@@ -0,0 +1,60 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<html>
+<title>Welcome to Big Bank</title>
+
+<body>
+
+<form action="loginAction" method="post">
+ <table>
+ <tr>
+ <td colspan="2">Please login in to access your account</td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ <td>Login</td>
+ <td><input type="text" name="login"/></td>
+ <td><I><FONT
+ size="-1" color="red">(test)</FONT></I></td>
+ </tr>
+ <tr>
+ <td>Password</td>
+ <td><input type="password" name="password"/></td>
+ <td><I><FONT size="-1" color="red">(password)</FONT></I></td>
+ </tr>
+ <tr>&nbsp;<td></td>
+ <td align="right"><input type="submit" name='login' value="login"/></td>
+ <tr>&nbsp;<td></td>
+ </tr>
+ </table>
+</form>
+<P><BR></P>
+<HR/>
+<FORM action="CustomerProfile.jsp" method="get">
+<BR>New to Big Bank? Please open a new account with us.
+<BR/>
+<P>
+<INPUT type="submit" name="createAccount" value="Create a new account">
+
+</FORM>
+
+
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/purchaseStock.jsp b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/purchaseStock.jsp
new file mode 100644
index 0000000000..90c3a813b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/purchaseStock.jsp
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+<HTML>
+<HEAD>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<META http-equiv="Content-Style-Type" content="text/css">
+<TITLE>BigBank- Stock purchase</TITLE>
+</HEAD>
+<BODY><P><FONT size="+1">Stock purchase</FONT><BR>
+<BR>
+</P>
+<FORM method="post" action="FormServlet">
+<input type="hidden" name="action" value='stockPurchase' />
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD>Symbol </TD>
+ <TD width="10%"></TD>
+ <TD><INPUT type="text" name="symbol" size="6"></TD>
+ </TR>
+ <TR>
+ <TD>Quantity</TD>
+ <TD></TD>
+ <TD><INPUT type="text" name="quantity" size="6"></TD>
+ </TR>
+ <TR>
+ <TD></TD>
+ <TD></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<BR>
+<INPUT type="submit" name="purchase" value="purchase">&nbsp;&nbsp;
+<INPUT type="submit" name="cancel" value="cancel"></FORM>
+<P><BR>
+</P>
+</BODY>
+</HTML>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/stockSale.jsp b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/stockSale.jsp
new file mode 100644
index 0000000000..a2b08f4352
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/stockSale.jsp
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+<HTML>
+<HEAD>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<META http-equiv="Content-Style-Type" content="text/css">
+<TITLE>BigBank- Stock sale</TITLE>
+</HEAD>
+<BODY><P><FONT size="+1">Stock sale</FONT><BR>
+<BR>
+</P>
+<FORM method="post" action="FormServlet">
+<input type="hidden" name="action" value='stockSale' />
+<input type="hidden" name="purchaseLotNumber" value='<%=request.getParameter("purchaseLotNumber")%>' />
+<TABLE border="0">
+ <TBODY>
+
+ <TR>
+ <TD>Quantity</TD>
+ <TD></TD>
+ <TD><INPUT type="text" name="quantity" size="6"></TD>
+ </TR>
+ <TR>
+ <TD></TD>
+ <TD></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<BR>
+<INPUT type="submit" name="stockSale" value="sell">&nbsp;&nbsp;
+<INPUT type="submit" name="cancel" value="cancel"></FORM>
+<P><BR>
+</P>
+</BODY>
+</HTML>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/summary.jsp b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/summary.jsp
new file mode 100644
index 0000000000..f31ded242f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/main/webapp/summary.jsp
@@ -0,0 +1,144 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+ <%@ page import="com.bigbank.account.AccountSummary" %>
+ <%@ page import="com.bigbank.account.StockSummary" %>
+ <%@ page session="true" %>
+ <%@ page autoFlush="true" %>
+<%@ taglib uri="/WEB-INF/bigbank-tags.tld" prefix="sca" %>
+<sca:login profile="ProfileServiceComponent" url="login.html">
+ <sca:service id="profile" name="ProfileServiceComponent"/>
+
+ <html>
+ <title>BigBank Account Summary</title>
+
+ <body>
+
+ Account Information for
+ <FORM method="post" action='loginAction'>
+ <jsp:getProperty name='profile' property='firstName'/>
+ <jsp:getProperty name='profile' property='lastName'/>
+ <input type="hidden" name="logoutHIDDEN" value='logoutHIDDEN' />
+ &nbsp;&nbsp;<INPUT type="submit" name='logout' value="logout">
+ <br>
+ </FORM>
+
+ <table>
+ <tr>
+ <td><strong>Account</strong></td>
+ <td>&nbsp;</td>
+ <td><strong>Balance</strong></td>
+ </tr>
+ <sca:accountStatus accountService="AccountServiceComponent" profileService="ProfileServiceComponent" id="account">
+ <tr>
+ <FORM method="post" action='accountTransaction.jsp'>
+ <input type="hidden" name="account" value='<%=((AccountSummary)pageContext.getAttribute("account")).getAccountNumber()%>' />
+ <td>
+ <jsp:getProperty name="account" property="accountNumber"/>
+ </td>
+
+ <td>
+ <jsp:getProperty name="account" property="accountType"/>
+ </td>
+ <td>
+ <jsp:getProperty name="account" property="balance"/>
+ </td>
+ <td>
+
+ <INPUT type="submit" name='transaction' value="deposit">
+ </td>
+ <td>
+ <INPUT type="submit" name='transaction' value="withdraw">
+ </td>
+ </FORM>
+ </tr>
+ </sca:accountStatus>
+ </table>
+
+
+
+ <hr/>
+ <FORM method="post" action='purchaseStock.jsp'>
+ Stocks: &nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" name='Purchase' value="Purchase"><br/>
+ </FORM>
+
+ <table>
+
+ <tr>
+ <td><strong>Symbol</strong></td>
+ <td><strong>Quantity</strong></td>
+ <td><strong>Purchase Date</strong></td>
+ <td>&nbsp;&nbsp;</td> <%-- spacer --%>
+ <td><strong>Purchase Price</strong></td>
+ <td><strong>Current Price</strong></td>
+ <td><strong>Company Name</strong></td>
+ <td><strong>Today High</strong></td>
+ <td><strong>Today Low</strong></td>
+ <td>&nbsp;&nbsp;</td> <%-- spacer --%>
+ <td> <%-- sell button --%></td>
+ </tr>
+ <sca:stockStatus id="stocksummary">
+ <FORM method="post" action='stockSale.jsp' >
+ <tr>
+ <td>
+ <jsp:getProperty name="stocksummary" property="symbol"/>
+ </td>
+ <td>
+ <jsp:getProperty name="stocksummary" property="quantity"/>
+ </td>
+ <td>
+ <jsp:getProperty name="stocksummary" property="purchaseDate"/>
+ </td>
+ <td>&nbsp;&nbsp;</td> <%-- spacer --%>
+ <td>
+ <jsp:getProperty name="stocksummary" property="purchasePrice"/>
+ </td>
+
+ <td>
+ <jsp:getProperty name="stocksummary" property="currentPrice"/>
+ </td>
+ <td>
+ <jsp:getProperty name="stocksummary" property="company"/>
+ </td>
+
+ <td>
+ <jsp:getProperty name="stocksummary" property="highPrice"/>
+ </td>
+ <td>
+ <jsp:getProperty name="stocksummary" property="lowPrice"/>
+ </td>
+ <td>&nbsp;&nbsp;</td> <%-- spacer --%>
+ <td>
+ <INPUT type="submit" name='stocksale' value="sell"><br/>
+ <input type="hidden" name="purchaseLotNumber" value='<%=((StockSummary)pageContext.getAttribute("stocksummary")).getPurchaseLotNumber()%>' />
+ </td>
+ </tr>
+ </FORM>
+ </sca:stockStatus>
+ </table>
+
+ <hr/>
+ <FORM method="post" action='accountLog.jsp'>
+ Account and Stock Logs: &nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" name='Logs' value="Logs"><br/>
+ </FORM>
+
+
+ </body>
+ </html>
+</sca:login>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java
new file mode 100644
index 0000000000..0f43400348
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package bigbank.webclient.client;
+
+import java.util.List;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.SCA;
+
+import com.bigbank.account.AccountReport;
+import com.bigbank.account.AccountService;
+
+public class TestAccountService extends SCA {
+
+ @Override
+ public void start() {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ public static void main(String[] args) throws Exception {
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+
+ AccountService accountService = (AccountService) moduleContext.locateService(AccountService.class, "AccountServiceComponent");
+
+ AccountReport report = accountService.getAccountReport(12345);
+ List summaries = report.getAccountSummaries();
+
+ System.out.println("retrieved " + summaries.size() + " summaries");
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java
new file mode 100644
index 0000000000..bafc1716f1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/applications/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.webclient.client;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.SCA;
+
+import bigbank.webclient.services.profile.LoginService;
+
+public class TestLoginService extends SCA {
+
+ @Override
+ public void start() {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ CompositeContext moduleContext = CurrentCompositeContext.getContext();
+ LoginService loginService = moduleContext.locateService(LoginService.class, "LoginServiceComponent");
+
+ if (loginService.login("test", "password") == LoginService.SUCCESS) {
+ System.out.println("Success");
+ } else {
+ System.out.println("Failure");
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/css/base.css b/sca-java-1.x/branches/sca-java-M2/samples/css/base.css
new file mode 100644
index 0000000000..9394b3a7be
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/css/base.css
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ body { margin: 0px;
+ padding: 3px 0px 5px 20px;
+ }
+
+ code { color: rgb(153, 51, 153);
+ font-weight: bold;
+ }
+
+ h3 { text-align: center;
+ text-decoration: underline;
+ padding-bottom: 30px;
+ font-size: 150%;
+ }
+
+ p { padding-left: 1em;
+ }
+
+ pre { padding-left: 2em;
+ }
+
+ table.extensiontable { margin-left: 10em;
+ margin-right: 10em;
+ }
+
+ h4 { font-size: 110%;
+ }
+
+ samp { border: 2px solid rgb(0, 153, 0);
+ font-weight: bold;
+ color: rgb(255, 255, 255);
+ background-color: rgb(0, 0, 0);
+ }
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/pom.xml
new file mode 100644
index 0000000000..de1f2d1070
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/pom.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>parent</artifactId>
+ <version>1-incubator</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Tuscany Samples Parent</name>
+ <description>Parent POM for SCA Samples.</description>
+
+ <properties>
+ <scaVersion>1.0-incubator-M2</scaVersion>
+ <scaImplVersion>1.0-incubator-M2-SNAPSHOT</scaImplVersion>
+ <sdoVersion>1.0-incubator-M2</sdoVersion>
+ <dasVersion>1.0-incubator-M2</dasVersion>
+ <specVersion>0.95</specVersion>
+ </properties>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache.incubator</id>
+ <name>Apache M2 Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ <modules>
+ <module>applications/bigbank</module>
+ <module>standalone/calculator</module>
+ <module>standalone/calculator-combo</module>
+ <module>standalone/calculatorRMIService</module>
+ <module>standalone/greeterwsclient-oneway</module>
+ <module>standalone/helloworldJavaScript</module>
+ <module>standalone/helloworldRMIReference</module>
+ <module>standalone/helloworldRMIService</module>
+ <module>standalone/helloworldRuby</module>
+ <module>standalone/helloworldwsclient</module>
+ <module>standalone/helloworldwsclient-async</module>
+ <module>standalone/inner.composite</module>
+ <module>standalone/simplecallback</module>
+ <module>standalone/supplychain</module>
+ <module>webapp/calculatorws</module>
+ <module>webapp/greeterws-oneway</module>
+ <module>webapp/helloworldws</module>
+ <module>webapp/helloworldws-async</module>
+ <module>webapp/webapp</module>
+ </modules>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>dependency-maven-plugin</artifactId>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>distribution</artifactId>
+ <version>${scaImplVersion}</version>
+ <classifier>bin</classifier>
+ <type>zip</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/distribution</outputDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r${specVersion}</artifactId>
+ <version>${scaVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/readme.html
new file mode 100644
index 0000000000..d0eddde525
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/readme.html
@@ -0,0 +1,339 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta name="generator" content=
+ "HTML Tidy for Windows (vers 1st July 2004), see www.w3.org">
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany SCA Samples</title>
+ <link rel="stylesheet" href="css/base.css" type="text/css">
+</head>
+
+<body>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <!-- maven --><!-- end maven -->
+
+ <h3>Apache Tuscany SCA Samples</h3>
+
+ <h4>License</h4>
+
+ <p>Please read the Apache Source Foundation License:&nbsp;
+ <a href="LICENSE.txt" target="_blank">LICENSE.txt</a> and
+ the&nbsp;<a href="http://incubator.apache.org/" target=
+ "_blank">ASF incubator</a> notice file: <a href="NOTICE.txt"
+ target="_blank">NOTICE.txt</a> .</p>
+
+ <h4>Tuscany</h4>
+
+ <p>More information on Apache Tuscany can be found on the
+ <a href="http://incubator.apache.org/tuscany/" target=
+ "_blank">Tuscany Website</a>. &nbsp;For help, review the <a href=
+ "http://incubator.apache.org/tuscany/faq.html" target=
+ "_blank">Tuscany FAQ page</a>, or subscribe and append to the
+ <a href="http://incubator.apache.org/tuscany/mail-lists.html"
+ target="_blank">mailing lists</a>. &nbsp;Issues can be submitted
+ and tracked through <a href=
+ "http://incubator.apache.org/tuscany/issue-tracking.html" target=
+ "_blank">Tuscany Jiras</a>.</p>
+
+ <p>To get involved please look at the &nbsp;<span style=
+ "text-decoration: underline;">Community</span> and <span style=
+ "text-decoration: underline;">Development</span> sections on the
+ <a href="http://incubator.apache.org/tuscany/" target=
+ "_blank">Tuscany Website</a>.</p>
+
+ <h4>What's new</h4>
+
+ <h2 id="head-12207a0c39dddea686fa800f216311aa837aed45">
+ &nbsp;<small><small>Java SCA 1.0-incubator-M2
+ release:</small></small></h2>
+
+ <p>* SCA specification compliance. Assembly (V0.96), Java Client and
+ Implementation(V0.95):</p>
+
+ <ul>
+ <li>Recursive composite model (implementation.composite and
+ include)</li>
+
+ <li>Support for component properties (simple types only)</li>
+
+ <li>Asynchronous oneway and request with callback</li>
+
+ <li>Java interface and WSDL 1.1 portType</li>
+ </ul>
+
+ <p>* Improved core for flexibility and extensibility</p>
+
+ <ul>
+ <li>Refactored to provide the default implementation of the SPI
+ contracts</li>
+
+ <li>Packaging/deployment</li>
+
+ <li>Scope management</li>
+
+ <li>IoC</li>
+
+ <li>Autowire</li>
+
+ <li>Improved classloader isolation</li>
+
+ <li>Maven-based artifact repository</li>
+
+ <li>A Data Binding Framework</li>
+ </ul>
+
+ <p>* Improved Extension model and SPI</p>
+
+ <p>* Tuscany Standalone runtime launcher</p>
+
+ <p>* Tomcat integration to host Tuscany web applications</p>
+
+ <p>* Tuscany War Plugin to build web applications</p>
+
+ <p>* New and improved bindings:</p>
+
+ <ul>
+ <li>Axis, upgraded to version 1.1</li>
+
+ <li class="gap">Celtix</li>
+
+ <li class="gap">RMI Service Binding that helps in hosting
+ component services as RMI servers without having to modify the
+ service interfaces (for example to include java.rmi.Remote
+ signatures) Reference Binding that helps SCA clients to
+ seamlessly access RMI servers.</li>
+
+ <li class="gap">Jsonrpc</li>
+ </ul>
+
+ <p>* Component implementation:</p>
+
+ <ul>
+ <li>Javascript<br>
+ Script container that enables running of components implemented
+ in <a class="nonexistent" href=
+ "http://wiki.apache.org/ws/JavaScript">JavaScript</a>. Supports
+ component services, properties and references.</li>
+
+ <li class="gap">Spring</li>
+
+ <li class="gap">Ruby
+
+ <ul>
+ <li style="list-style-type: none;">Script container that
+ enables running of components implemented in Ruby. Supports
+ component services, properties and references.</li>
+ </ul>
+ </li>
+ </ul>
+
+ <p>* DataBindings:</p>
+
+ <ul>
+ <li>AXIOM</li>
+
+ <li class="gap">SDO<br></li>
+ </ul>
+
+ <p>* More samples</p>
+
+ <ul>
+ <li>Sample that demonstrates RMI Service and RMI Reference from
+ a standalone Tuscany runtime</li>
+
+ <li>A combo sample - Calculator-Combo that demonstrates the
+ assembly of different technologies using component
+ implementations in Java, <a class="nonexistent" href=
+ "http://wiki.apache.org/ws/JavaScript">JavaScript</a>, Ruby and
+ binding of service references to <a class="nonexistent" href=
+ "http://wiki.apache.org/ws/WebService">WebService</a> and RMI
+ Service endpoints. Also included is a simple demontration of
+ property configuration and composite component
+ implementation</li>
+ </ul>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+
+ <li><a href="http://tomcat.apache.org/download-55.cgi" target=
+ "_blank">Apache Tomcat 5.xx</a> latest version binary core
+ distribution for samples requiring a web server
+ environment..&nbsp;</li>
+ </ul>
+
+ <h4>Running Samples</h4>
+
+ <p>Each sample has it's own readme.html file that gives specific
+ information for building, setup, and running the sample.
+ &nbsp;Note that each standalone sample has you unpack a separate
+ Tuscany standalone runtime environment. &nbsp;An alternative
+ approach can be to create this just once and reuse.</p>
+
+ <h4>Sample Summary</h4><br>
+
+ <table style="text-align: left; width: 100%;" border="1"
+ cellpadding="2" cellspacing="2">
+ <tbody>
+ <tr>
+ <td><a href="standalone/calculator/readme.html" target=
+ "_blank">calculator</a></td>
+
+ <td>A simple calculator sample demonstrating wiring
+ together SCA components</td>
+ </tr>
+
+ <tr>
+ <td><a href="standalone/calculator-combo/readme.html"
+ target="_blank">calculator-combo</a> with <a href=
+ "webapp/calculatorws/readme.html" target=
+ "_blank">calculatorws</a> and <a href=
+ "standalone/calculatorRMIService/readme.html" target=
+ "_blank">calculatorRMIService</a></td>
+
+ <td>A Calculator sample combining Java, JavaScript, Ruby,
+ RMI and Web services</td>
+ </tr>
+
+ <tr>
+ <td><a href="standalone/greeterwsclient-oneway/readme.html"
+ target="_blank">greeterwsclient-oneway</a> and <a href=
+ "webapp/greeterws-oneway/readme.html" target=
+ "_blank">greeterws-oneway</a></td>
+
+ <td>A sample Greeter OneWay Web Service.</td>
+ </tr>
+
+ <tr>
+ <td><a href="standalone/helloworldJavaScript/readme.html"
+ target="_blank">helloworldJavaScript</a></td>
+
+ <td>A helloworld sample using a single SCA JavaScript
+ component</td>
+ </tr>
+
+ <tr>
+ <td><a href="webapp/helloworldjsonrpc/readme.html" target=
+ "_blank">helloworldjsonrpc</a></td>
+
+ <td>A sample showing how to expose an SCA component as a
+ JSON-RPC service</td>
+ </tr>
+
+ <tr>
+ <td><a href="standalone/helloworldRMIService/readme.html"
+ target="_blank">helloworldRMIService</a> and <a href=
+ "standalone/helloworldRMIReference/readme.html" target=
+ "_blank">helloworldRMIreference</a></td>
+
+ <td>The service and reference parts of a helloworld sample
+ using RMI.</td>
+ </tr>
+
+ <tr>
+ <td><a href="standalone/helloworldRuby/readme.html" target=
+ "_blank">helloworldRuby</a></td>
+
+ <td>A helloworld sample using a single SCA Ruby
+ component</td>
+ </tr>
+
+ <tr>
+ <td><a href="webapp/helloworldws/readme.html" target=
+ "_blank">helloworldws</a> and <a href=
+ "standalone/helloworldwsclient/readme.html" target=
+ "_blank">helloworldwsclient</a></td>
+
+ <td>The client and service parts of a helloworld sample
+ using Web services.</td>
+ </tr>
+
+ <tr>
+ <td><a href="webapp/helloworldws-async/readme.html" target=
+ "_blank">helloworldws-async</a> and <a href=
+ "standalone/helloworldwsclient-async/readme.html" target=
+ "_blank">helloworldwsclient-async</a></td>
+
+ <td>The client and service parts of a helloworld sample
+ using asynchronous Web services.</td>
+ </tr>
+
+ <tr>
+ <td><a href=
+ "standalone/inner.composite/readme.html">inner.composite</a></td>
+
+ <td>A sample showing asynchronous calls within
+ composites.</td>
+ </tr>
+
+ <tr>
+ <td><a href=
+ "standalone/simplecallback/readme.html">simplecallback</a></td>
+
+ <td>A sample showing simple asynchronous callbacks.</td>
+ </tr>
+
+ <tr>
+ <td><a href=
+ "standalone/supplychain/readme.html">supplychain</a></td>
+
+ <td>A sample application demonstrating asynchronous
+ callbacks.</td>
+ </tr>
+
+ <tr>
+ <td><a href="webapp/webapp/readme.html" target=
+ "_blank">webapp</a></td>
+
+ <td>A sample Web application showing how to include a
+ Tuscany runtime in a webapp.</td>
+ </tr>
+
+ <tr>
+ <td><a href="applications/bigbank/readme.html" target=
+ "_blank">Big Bank</a></td>
+
+ <td>Sample application using SCA, SDO's and DAS.</td>
+ </tr>
+ </tbody>
+ </table><br>
+
+ <p><br></p>
+ <hr style="width: 100%; height: 4px;">
+
+ <p>Thank you for your interest in Apache Tuscany,<br>
+ &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <strong><em>-The Apache
+ Tuscany Development Team</em></strong></p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/pom.xml
new file mode 100644
index 0000000000..6bcb1e62ad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-calculator-combo</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Calculator Combo Sample</name>
+ <description>A Calculator sample combining java, javascript, ruby, rmi and ws</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>${scaVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>rmi</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>javascript</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>ruby</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>calculator.client.CalculatorClient</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/readme.html
new file mode 100644
index 0000000000..f8b33b440d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/readme.html
@@ -0,0 +1,293 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><title>Tuscany
+Calculator-Combo Sample</title><!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
+<style type="text/css" media="all">
+@import url("../../../../css/maven-base.css");
+@import url("../../../../css/maven-theme.css");
+@import url("../../../../css/site.css");
+</style><link rel="stylesheet" href="./css/print.css" type="text/css" media="print"><!-- end maven --></head>
+<body>
+<H3>Tuscany Calculator-Combo - A Simple SCA Assembly involving Java,
+JavaScript, Ruby, RMI and WebServices</H3>
+<H3>Overview</H3>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD width="100%" valign="top" align="left"> The objective of this sample is to provide simple demonstration of an SCA application assembly involving different implementation and binding technlogies. <BR>This sample is an SCA Standalone Calculator Application called &quot;Calculator Combo&quot; assembling Calculator functions implemented in Java, JavaScript and Ruby and references to the external RMI and WebService implementations of the Calculator funtions. Besides, this assembly also includes a component that is implemented as a Composite and there is also a simple demonstration of property configuration of components.
+
+ <BR>
+ <BR>This sample depends on two other samples which are :-
+ <BR>
+ i) The CalculatorRmiService SCA Standalone Assembly which assembles Calculator functions implemented in Java and exposing the Calculator as RMI Services<BR>
+ ii) The Calculator WebService that assembles Calculator functions implemented in Java and exposing them as WebServices
+ </TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H3>Location</H3>
+<P>The source for this sample is located &nbsp;in the paths - <I>samples\standalone\calculator-combo</I>
+ of the source
+distribution.<BR>
+<BR>
+If there is binary distribution available for these samples, then you may find these samples packaged as <I>sample-calculator-combo.jar.</I></P>
+<H3>Building &amp; Running the Calculator-Combo Sample Source</H3>
+<P>If you are working with a source distribution, then you must first
+build the source of this sample. <BR>
+- Ensure that you have Java 5 installed on your system.<BR>
+- Next, you must have Maven 2.0.4 installed on your system. Look up
+http://maven.apache.org/download.html for downloading and installing
+Maven.</P>
+<H4>Building the Calculator-Combo Sample</H4>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top"></TD>
+ <TD valign="top">Having installed Maven, open a command line console
+ and switch over to the directory on your local system, where you have
+ extracted the source.<BR>
+ - Now switch futher into the subdirectory <I>samples\standalone\calcualtor-combo.
+ </I>Within this directory execute the following command
+ <TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will build the <I>calculator-combo</I> sample, package a JAR
+ file for the composite and make it available in the sub-directory <I>samples\standalone\calculator-combo/target</I></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4><BR>
+Setting up Tuscany Standalone Runtime </H4>
+<P>To run these samples you need the Tuscany Standalone Runtime. This is
+available as a distribution that can be conveniently unpacked and setup
+in the samples directory itself. For this, do the following: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top" align="right">i)</TD>
+ <TD>From the directory <I>samples\standalone\calculator-combo</I>
+ execute the following command
+ <TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn dependency:unpack</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will unpack the Tuscany Standalone Runtime Distribution to the <I>target\distribution
+ </I>sub-directory within the present working directory - <I>samples\standalone\calculator-combo</I></TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>This sample would require the following extensions of Tuscany : -<BR>RMI Binding Extension, JavaSCript Container Extension, Axis2 Binding Extension, Ruby Container Extension. <BR>The jar files of all of these extensions have to copied from the the <I>contrib </I>sub-directory
+ into the <I>extensions </I>directory of the distribution. ie. execute
+ the following from the <I>samples\standalone\calculator-combo </I>sub-directory:
+ -
+ <TABLE>
+ <TBODY>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">copy
+ target\distribution\contrib\rmi-1.0-incubator-M2.jar <FONT
+ color="purple" face="Courier New">target\distribution\extensions\rmi-1.0-incubator-M2.jar</FONT></FONT></TD>
+ </TR>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD><TD><FONT color="purple" face="Courier New">copy
+ target\distribution\contrib\axis2-1.0-incubator-M2.jar <FONT color="purple" face="Courier New">target\distribution\extensions\axis2-1.0-incubator-M2.jar</FONT></FONT></TD>
+
+ </TR>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD><TD><FONT color="purple" face="Courier New">copy
+ target\distribution\contrib\javascript-1.0-incubator-M2.jar <FONT color="purple" face="Courier New">target\distribution\extensions\javascript-1.0-incubator-M2.jar</FONT></FONT></TD>
+
+ </TR>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD><TD><FONT color="purple" face="Courier New">copy
+ target\distribution\contrib\ruby-1.0-incubator-M2.jar <FONT color="purple" face="Courier New">target\distribution\extensions\ruby-1.0-incubator-M2.jar</FONT></FONT></TD>
+
+ </TR>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">copy
+ target\distribution\contrib\databinding-sdo-1.0-incubator-M2.jar <FONT
+ color="purple" face="Courier New">target\distribution\extensions\databinding-sdo-1.0-incubator-M2.jar</FONT></FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ <I>Note</I> : <I>If you are working with SNAPSHOTs versions of
+ Tuscany Extensions then the files in the above commands must be substituted with the corresponding SNAPSHOT versions. For example <B>rmi-1.0-incubator-M2.jar</B> in
+ the above command must be substituted with <B>rmi-1.0-incubator-M2-SNAPSHOT.jar</B></I></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4>Running the Calculator-Combo Sample
+</H4>
+<P>Now that the sample source has been built and the Tuscany Standalone
+Runtime setup, you may run the Calculator-Combo sample as follows: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top">i)</TD>
+ <TD>Ensure that the Calculator-RMIService Sample and the Calculator WebService samples are running. You can find them under <I>samples\standalone\calcualtorRMIService </I>and <I>samples\webapp\calcualtorws</I> directories of the samples source distribution respectively. Details pertaining to building and running these samples can be found in the respective readme.html files under each of them.</TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD><TD>Switch to the <I>samples\standalone\calculator-combo\target\distribution
+ </I>sub-directory and execute the following command:
+ <TABLE>
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">java -jar
+ bin\launcher.jar ..\sample-calculator-combo.jar</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </TD>
+
+ </TR>
+ <TR>
+ <TD valign="top">iii)</TD>
+ <TD>You will initially observe messages that relate to resolution of
+ dependencies required to run this sample and finlly see the following
+ message on your console<BR>
+ <FONT color="green" face="Courier New"></FONT><FONT
+ face="Courier New" color="green" size="+0">***************************************<BR>
+ Starting the Calculator Combo sample!!!<BR>
+ ***************************************<BR>
+ Invoking Java Implementation ...<BR>
+ 3 + 2 = 5.0<BR>
+ Invoking Ruby Implementation ...<BR>
+ 3 - 2 = 1.0<BR>
+ Invoking over RMI Reference...<BR>
+ 3 * 2 = 6.0<BR>
+ Invoking WebService Implementation ...<BR>
+ 3 / 2 = 1.5<BR>
+ Invoking Scientific Calculator Composite Implementation ...<BR>
+ .....Invoking Java Implementation ...<BR>
+ .....Average of 1,2,3,4,5,6,7,8,9 = 5.0<BR>
+ .....Invoking JavaScript Implementation ...<BR>
+ .....Square Root of 81 = 9.0<BR>
+ .....Invoking Java Implementation configued for Property ...<BR>
+ .....Sine 90 Degrees = 1.0<BR>
+ .....Cos 90 Degrees = 6.123233995736766E-17<BR>
+ .....Tan 90 Degrees = 1.633123935319537E16</FONT><FONT color="green"></FONT></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<P>Thus we see the Calculator Combo demonstrating the assembly of different technologies to provide a wholesome Calculator Service to the external world.<BR>
+</P><H2>Code Overview</H2>
+<P>The source files are physically organized as shown below:<BR>
+</P>
+<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td>
+<pre>
+<B><U></U></B><B><U>Calculator Combo</U></B>
++---main<BR> +---java<BR> | +---calculator
+<I> &lt;Interfaces and Implementations for Calculator Functions&gt;
+
+</I> +---client
+ CalculatorClient.java
+ +---resources
+ +---wsdl
+ calculator.wsdl
+ +---webapp
+ +---WEB-INF
+ default.scdl
+ web.xml</pre></td></tr></tbody></table>
+<P><B> <BR>
+</B></P>
+<P><B>Calculator Combo Sample (Standalone Deployment)</B></P><TABLE border="1">
+ <TBODY>
+ <TR>
+ <TD width="230" valign="top">default.scdl</TD>
+ <TD width="396" valign="top">- Defines an assembly of calculator
+ functions implemented in Java and exposed as a WebService using the
+ Axis2 binding.<BR>- Defines a SciCalculatorComponent that is implemented by an SCA Composite defined in sci_calc.scdl </TD>
+ </TR>
+ <TR>
+ <TD width="230" valign="top">sci_calc.scdl</TD>
+ <TD width="396" valign="top">- Defines an assembley of advanced calculator functions implemented in Java<BR>- Uses a property configuration called 'trig-metric' that configures the metric that is used when invoking trignometric functions (sin, cos, tan)</TD>
+ </TR>
+ <TR>
+ <TD width="230">AddService.java<BR>
+ AddServiceImpl.java<BR>
+ DivideService.java<BR>MathService.java<BR>
+ MathServiceImpl.java<BR>
+ MultiplyService.java<BR>
+ MultiplyServiceImpl.java<BR>
+ SubtractService.java<BR>
+ SubtractServiceImpl.java</TD>
+ <TD width="396">Java Interfaces and Java Implementations for various calculator
+ functions. <I>
+ </I></TD>
+ </TR>
+ <TR>
+ <TD width="230">CalculatorService.java<BR>
+ CalculatorServiceImpl.java</TD>
+ <TD width="396">- Defines the coarse grained Calculator Interface and
+ Implementation. This calculator implementation delegates function
+ requests to other granular implemenations listed above. <BR>- Holds a reference to the RMI Calculator Service which is invoked to provide the 'multiply' function</TD>
+ </TR>
+ <TR>
+ <TD width="230">DivideServiceImpl.java</TD>
+ <TD width="396">- Provides an implementation for the DivideService and is called by the CalculatorService to provide the 'divide' function<BR>- Holds a reference to the Calculator WebService which is invoked to provide the 'divide' function.</TD>
+ </TR>
+ <TR>
+ <TD width="230">SciCalculatorService<BR>SciCalculatorService
+ </TD>
+ <TD width="396">Java Interface and Implementation for advanced functions of the calculator (avg, sqrt, sin, cos, tan, ...)</TD>
+ </TR>
+ <TR>
+ <TD width="230">SqrtService.java</TD>
+ <TD width="396">Provides an interface defintion for the JavaScript ComponentType definition of the square-root service</TD>
+ </TR>
+ <TR>
+ <TD width="230">calculator.wsdl</TD>
+ <TD width="396">- Defines the Calculator service using WSDL to enable
+ the CalculatorServiceImpl to be exposed as a Axis2 WebService<BR>- This wsdl is required to establish the client binding to the Calculator WebService
+ </TD>
+ </TR>
+ <TR>
+ <TD width="230">Sqrt.componentType</TD>
+ <TD width="396">Provides the component type information (component type sidefile) for the JavaScript implementation of the Square-Root service</TD>
+ </TR>
+ <TR>
+ <TD width="230">Sqrt.js</TD>
+ <TD width="396">A JavaScript implementation for the square-root function</TD>
+ </TR>
+ <TR>
+ <TD width="230">SubtractImpl.componentType</TD>
+ <TD width="396">Provides the component type information (component type sidefile) for the Ruby implementation of the Subtract service</TD>
+ </TR>
+ <TR>
+ <TD width="230">SubtractImpl.rb</TD>
+ <TD width="396">A Ruby implementation for the Subtract function</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<P><B></B></P>
+</body></html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..6392676e76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..39e9be92e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/AddServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Add service
+ */
+@Scope("MODULE")
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..d17650ec3f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+@Service
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..0953eae036
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Scope("MODULE")
+public class CalculatorServiceImpl implements CalculatorService {
+
+ @Reference
+ protected AddService addService;
+
+ @Reference
+ protected SubtractService subtractService;
+
+ @Reference
+ protected MultiplyService multiplyService;
+
+ @Reference
+ protected DivideService divideService;
+
+ @Reference
+ protected CalculatorService rmiCalculatorService;
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return rmiCalculatorService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..3158458b5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..6363068cfd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/DivideServiceImpl.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Scope("MODULE")
+public class DivideServiceImpl implements DivideService {
+
+ @Reference
+ protected CalculatorService calculatorWebService;
+
+ public double divide(double n1, double n2) {
+ return calculatorWebService.divide(n1, n2);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..62db05175e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7276bb6964
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Scope("MODULE")
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..309f88f098
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..3c3388f4cd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/SubtractServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Scope("MODULE")
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/client/CalculatorClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/client/CalculatorClient.java
new file mode 100644
index 0000000000..c02c284007
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/client/CalculatorClient.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator.client;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import calculator.CalculatorService;
+import calculator.sci.SciCalculatorService;
+
+/**
+ * Calculator client
+ */
+public class CalculatorClient {
+
+ public CalculatorClient() {
+ }
+
+ public static void main(String args[]) throws Exception {
+ try {
+ CalculatorClient calcClient = new CalculatorClient();
+ calcClient.testCalcCombo(args);
+ System.exit(0);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void testCalcCombo(String args[]) {
+ System.out.println("\n\n***************************************");
+ System.out.println("Starting the Calculator Combo sample!!!");
+ System.out.println("***************************************");
+ CompositeContext context = CurrentCompositeContext.getContext();
+ CalculatorService calculatorService =
+ (CalculatorService)context.locateService(CalculatorService.class, "CalculatorServiceComponent");
+ System.out.println("\nInvoking Java Implementation ... ");
+ System.out.println((new StringBuilder()).append("3 + 2 = ").append(calculatorService.add(3D, 2D))
+ .toString());
+ System.out.println("\nInvoking Ruby Implementation ... ");
+ System.out.println((new StringBuilder()).append("3 - 2 = ")
+ .append(calculatorService.subtract(3D, 2D)).toString());
+ System.out.println("\nInvoking over RMI Reference... ");
+ System.out.println((new StringBuilder()).append("3 * 2 = ")
+ .append(calculatorService.multiply(3D, 2D)).toString());
+ System.out.println("\nInvoking WebService Implementation ... ");
+ System.out.println((new StringBuilder()).append("3 / 2 = ").append(calculatorService.divide(3D, 2D))
+ .toString());
+ System.out.println("\nInvoking Scientific Calculator Composite Implementation ... ");
+ SciCalculatorService sciCalculator =
+ (SciCalculatorService)context.locateService(SciCalculatorService.class, "sciCalculatorService");
+ double values[] = {1.0D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D};
+ System.out.println("\tInvoking Java Implementation ... ");
+ System.out.println((new StringBuilder()).append("\tAverage of 1,2,3,4,5,6,7,8,9 = ")
+ .append(sciCalculator.average(values)).toString());
+ System.out.println("\n\tInvoking JavaScript Implementation ... ");
+ System.out.println((new StringBuilder()).append("\tSquare Root of 81 = ").append(sciCalculator
+ .sqrt(81D)).toString());
+ System.out.println("\tInvoking Java Implementation configured for Property ... ");
+ System.out.println((new StringBuilder()).append("\tSine 90 Degrees = ")
+ .append(sciCalculator.sin(90D)).toString());
+ System.out.println((new StringBuilder()).append("\tCos 90 Degrees = ").append(sciCalculator.cos(90D))
+ .toString());
+ System.out.println((new StringBuilder()).append("\tTan 90 Degrees = ").append(sciCalculator.tan(90D))
+ .toString());
+ System.out.println("\nExiting...");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorService.java
new file mode 100644
index 0000000000..ef36007eb6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator.sci;
+
+/**
+ * Scientific calculator
+ */
+public interface SciCalculatorService {
+ public abstract double average(double ad[]);
+
+ public abstract double sqrt(double d);
+
+ public abstract double sin(double d);
+
+ public abstract double cos(double d);
+
+ public abstract double tan(double d);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorServiceImpl.java
new file mode 100644
index 0000000000..b1aba993a7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SciCalculatorServiceImpl.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator.sci;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+public class SciCalculatorServiceImpl implements SciCalculatorService {
+
+ public static final String RADIANS = "RADIANS";
+ public static final String DEGREES = "DEGREES";
+
+ @Reference
+ protected SqrtService sqrtService;
+
+ private String trig_metric;
+
+ public SciCalculatorServiceImpl() {
+ }
+
+ public double average(double values[]) {
+ double sum = 0.0D;
+ int count = 0;
+ double arr$[] = values;
+ int len$ = arr$.length;
+ for (int i$ = 0; i$ < len$; i$++) {
+ double aValue = arr$[i$];
+ sum += aValue;
+ count++;
+ }
+
+ return sum / (double)count;
+ }
+
+ public double sqrt(double n) {
+ return sqrtService.sqrt(n);
+ }
+
+ public double sin(double angle) {
+ if (trig_metric.equalsIgnoreCase("DEGREES"))
+ angle = Math.toRadians(angle);
+ return Math.sin(angle);
+ }
+
+ public double cos(double angle) {
+ if (trig_metric.equalsIgnoreCase("DEGREES"))
+ angle = Math.toRadians(angle);
+ return Math.cos(angle);
+ }
+
+ public double tan(double angle) {
+ if (trig_metric.equalsIgnoreCase("DEGREES"))
+ angle = Math.toRadians(angle);
+ return Math.tan(angle);
+ }
+
+ public String getTrig_metric() {
+ return trig_metric;
+ }
+
+ @Property
+ public void setTrig_metric(String trig_metric) {
+ this.trig_metric = trig_metric;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SqrtService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SqrtService.java
new file mode 100644
index 0000000000..d9027b5616
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/java/calculator/sci/SqrtService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator.sci;
+
+/**
+ * Interface to calculate the square root
+ */
+public interface SqrtService {
+ public abstract double sqrt(double d);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..73c0fb48cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rmi="http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2"
+ xmlns:rb="http://incubator.apache.org/tuscany/xmlns/container/rb/1.0-incubator-M2"
+ name="CalculatorComposite">
+
+ <service name="sciCalculatorService">
+ <interface.java interface="calculator.sci.SciCalculatorService"/>
+ <reference>SciCalculatorComponent</reference>
+ </service>
+
+ <component name="SciCalculatorComponent">
+ <implementation.composite name="SciCalculatorComposite" scdlLocation="./sci_calc.scdl" />
+ </component>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService">AddServiceComponent</reference>
+ <reference name="subtractService">SubtractServiceComponent</reference>
+ <reference name="rmiCalculatorService">CalculatorRmiService</reference>
+ <reference name="divideService">DivideServiceComponent</reference>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <!--implementation.java class="calculator.SubtractServiceImpl"/-->
+ <rb:implementation.rb script="SubtractImpl.rb" class="SubtractImpl"/>
+ </component>
+
+ <reference name="CalculatorRmiService">
+ <interface.java interface="calculator.CalculatorService"/>
+ <rmi:binding.rmi host="localhost" port="9999" serviceName="rmiCalculator"/>
+ </reference>
+
+ <!--component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component-->
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" location="wsdl/calculator.wsdl"/>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ <reference name="calculatorWebService">CalculatorWebService</reference>
+ </component>
+
+ <reference name="CalculatorWebService">
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ interface="http://calculator#wsdl.interface(Calculator)"
+ wsdli:wsdlLocation="http://calculator wsdl/calculator.wsdl" />
+ <binding.ws endpoint="http://calculator#wsdl.endpoint(CalculatorService/CalculatorServiceSOAP11port)"
+ location="wsdl/calculator.wsdl" />
+ </reference>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/sci_calc.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/sci_calc.scdl
new file mode 100644
index 0000000000..d753a66774
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/META-INF/sca/sci_calc.scdl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:js="http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2" name="SciCalculatorComposite">
+
+ <service name="sciCalculatorService">
+ <interface.java interface="calculator.sci.SciCalculatorService" />
+ <reference>SciCalculatorServiceComponent</reference>
+ </service>
+
+ <!--
+ <property name="trig_metric" type="xsd:string">DEGREES</property>
+ -->
+
+ <component name="SciCalculatorServiceComponent">
+ <implementation.java class="calculator.sci.SciCalculatorServiceImpl" />
+ <!-- property name="trig_metric" source="$trig_metric"/ -->
+ <property name="trig_metric">DEGREES</property>
+ <reference name="sqrtService">SqrtServiceComponent</reference>
+ </component>
+
+ <component name="SqrtServiceComponent">
+ <js:implementation.js script="Sqrt.js" />
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.componentType b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.componentType
new file mode 100644
index 0000000000..1880164f29
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="SqrtService">
+ <interface.java interface="calculator.sci.SqrtService"/>
+ </service>
+
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.js b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.js
new file mode 100644
index 0000000000..b0e2ef81d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/Sqrt.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+function sqrt(n) {
+ return java.lang.Math.sqrt(n);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.componentType b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.componentType
new file mode 100644
index 0000000000..94bd4549d6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.componentType
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="SubtractService">
+ <interface.java interface="calculator.SubtractService"/>
+ </service>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.rb b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.rb
new file mode 100644
index 0000000000..1f949e933e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/SubtractImpl.rb
@@ -0,0 +1,22 @@
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+class SubtractImpl
+ def subtract(arg1, arg2)
+ arg1 - arg2
+ end
+
+end \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/wsdl/calculator.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/wsdl/calculator.wsdl
new file mode 100644
index 0000000000..46928e7055
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/main/resources/wsdl/calculator.wsdl
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="http://calculator/xsd" xmlns:axis2ns1="http://calculator" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calculator">
+ <wsdl:types>
+ <xs:schema xmlns:ns="http://calculator/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://calculator/xsd">
+ <xs:element name="add">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="addResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="divide">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="divideResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="multiply">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="multiplyResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="subtract">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="subtractResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sqrt">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sqrtResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="addMessage">
+ <wsdl:part name="part1" element="ns1:add" />
+ </wsdl:message>
+ <wsdl:message name="addResponseMessage">
+ <wsdl:part name="part1" element="ns1:addResponse" />
+ </wsdl:message>
+ <wsdl:message name="divideMessage">
+ <wsdl:part name="part1" element="ns1:divide" />
+ </wsdl:message>
+ <wsdl:message name="divideResponseMessage">
+ <wsdl:part name="part1" element="ns1:divideResponse" />
+ </wsdl:message>
+ <wsdl:message name="multiplyMessage">
+ <wsdl:part name="part1" element="ns1:multiply" />
+ </wsdl:message>
+ <wsdl:message name="multiplyResponseMessage">
+ <wsdl:part name="part1" element="ns1:multiplyResponse" />
+ </wsdl:message>
+ <wsdl:message name="subtractMessage">
+ <wsdl:part name="part1" element="ns1:subtract" />
+ </wsdl:message>
+ <wsdl:message name="subtractResponseMessage">
+ <wsdl:part name="part1" element="ns1:subtractResponse" />
+ </wsdl:message>
+ <wsdl:message name="sqrtMessage">
+ <wsdl:part name="part1" element="ns1:sqrt" />
+ </wsdl:message>
+ <wsdl:message name="sqrtResponseMessage">
+ <wsdl:part name="part1" element="ns1:sqrtResponse" />
+ </wsdl:message>
+ <wsdl:portType name="Calculator">
+ <wsdl:operation name="add">
+ <wsdl:input message="axis2ns1:addMessage" />
+ <wsdl:output message="axis2ns1:addResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="divide">
+ <wsdl:input message="axis2ns1:divideMessage" />
+ <wsdl:output message="axis2ns1:divideResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="multiply">
+ <wsdl:input message="axis2ns1:multiplyMessage" />
+ <wsdl:output message="axis2ns1:multiplyResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="subtract">
+ <wsdl:input message="axis2ns1:subtractMessage" />
+ <wsdl:output message="axis2ns1:subtractResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="sqrt">
+ <wsdl:input message="axis2ns1:sqrtMessage" />
+ <wsdl:output message="axis2ns1:sqrtResponseMessage" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSOAP11Binding" type="axis2ns1:Calculator">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <wsdl:operation name="add">
+ <soap:operation soapAction="urn:add" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="divide">
+ <soap:operation soapAction="urn:divide" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="multiply">
+ <soap:operation soapAction="urn:multiply" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="subtract">
+ <soap:operation soapAction="urn:subtract" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sqrt">
+ <soap:operation soapAction="urn:sqrt" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="CalculatorServiceSOAP12Binding" type="axis2ns1:Calculator">
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <wsdl:operation name="add">
+ <soap12:operation soapAction="urn:add" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="divide">
+ <soap12:operation soapAction="urn:divide" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="multiply">
+ <soap12:operation soapAction="urn:multiply" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="subtract">
+ <soap12:operation soapAction="urn:subtract" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sqrt">
+ <soap:operation soapAction="urn:sqrt" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port name="CalculatorServiceSOAP11port" binding="axis2ns1:CalculatorServiceSOAP11Binding">
+ <soap:address location="http://localhost:8080/sample-calculatorws/services/CalculatorWebService" />
+ </wsdl:port>
+ <wsdl:port name="CalculatorServiceSOAP12port" binding="axis2ns1:CalculatorServiceSOAP12Binding">
+ <soap12:address location="http://localhost:8080/sample-calculatorws/services/CalculatorWebService" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/test/java/calculator/CalculatorTestClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/test/java/calculator/CalculatorTestClient.java
new file mode 100644
index 0000000000..61a9f0f699
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator-combo/src/test/java/calculator/CalculatorTestClient.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.apache.tuscany.test.SCATestCase;
+
+import calculator.client.CalculatorClient;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorTestClient extends SCATestCase {
+
+ protected void setUp() throws Exception {
+
+ addExtension("ruby.extension", getClass().getClassLoader()
+ .getResource("META-INF/sca/ruby.system.scdl"));
+ addExtension("rmi.extension", getClass().getClassLoader()
+ .getResource("META-INF/sca/rmi_extension.scdl"));
+ addExtension("js.extension", getClass().getClassLoader()
+ .getResource("META-INF/sca/js.system.scdl"));
+ addExtension("axis2.extension", getClass().getClassLoader()
+ .getResource("META-INF/sca/binding.axis2.scdl"));
+ addExtension("databinding.sdo.extension", getClass().getClassLoader()
+ .getResource("META-INF/sca/databinding.sdo.scdl"));
+
+ setApplicationSCDL(getClass().getClassLoader().getResource("META-INF/sca/default.scdl"));
+ super.setUp();
+
+ }
+
+ public void testCalculatorClient() throws Exception {
+ CalculatorClient.main(new String[0]);
+ }
+
+ protected void tearDown() throws Exception {
+ // super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/pom.xml
new file mode 100644
index 0000000000..4efd818037
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-calculator</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Calculator Sample</name>
+ <description>A sample Calculator made of several SCA components wired together.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal> <!-- requires install as this sample is also used by the webapp sample -->
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>calculator.CalculatorClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/readme.html
new file mode 100644
index 0000000000..5d4e2cfcfb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/readme.html
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Simple Calculator Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Simple Calculator Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>This sample illustrates the use of SCA to wire components together inside a composite.
+All connections between the components are local and are defined using Java interfaces.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\calculator directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-calculator.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-calculator.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>3 + 2=5.0
+<br>3 - 2=1.0
+<br>3 * 2=6.0
+<br>3 / 2=1.5
+</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..4eeb30a9c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..da6a530052
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/AddServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Add service
+ */
+@Scope("MODULE")
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..cb4edeac7e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the Calculator service and invoke it.
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ CalculatorService calculatorService =
+ context.locateService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..031fa8b912
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..efb49ead63
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Scope("MODULE")
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..131c5a8014
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..535298d31d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/DivideServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Scope("MODULE")
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..a917896aeb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..e1d491beee
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Scope("MODULE")
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..e328f024ea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..053f323627
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/java/calculator/SubtractServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Scope("MODULE")
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..3ac67d4b44
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="CalculatorComposite">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService"/>
+ <reference>CalculatorServiceComponent</reference>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService">AddServiceComponent</reference>
+ <reference name="subtractService">SubtractServiceComponent</reference>
+ <reference name="multiplyService">MultiplyServiceComponent</reference>
+ <reference name="divideService">DivideServiceComponent</reference>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..f33d7abb02
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculator/src/test/java/calculator/CalculatorTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import org.apache.tuscany.test.SCATestCase;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorTestCase extends SCATestCase {
+
+ private CalculatorService calculatorService;
+
+ protected void setUp() throws Exception {
+ setApplicationSCDL(CalculatorService.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ calculatorService = context.locateService(CalculatorService.class, "CalculatorServiceComponent");
+ }
+
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/pom.xml
new file mode 100644
index 0000000000..97176810dc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-calculator-rmiService</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Calculator RMI Service Sample</name>
+ <description>A sample Calculator RMI Service.</description>
+
+ <dependencies>
+
+ <!-- SCA API dependencies -->
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>${scaVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Tuscany RMI Binding -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>rmi</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <!-- Tuscany API dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- Unit testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>calculator.server.CalculatorRMIServer</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/readme.html
new file mode 100644
index 0000000000..bebe69ec8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/readme.html
@@ -0,0 +1,248 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><title>Tuscany
+Calculator RMI Service Sample</title><!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
+<style type="text/css" media="all">
+@import url("../../../../css/maven-base.css");
+@import url("../../../../css/maven-theme.css");
+@import url("../../../../css/site.css");
+</style><link rel="stylesheet" href="./css/print.css" type="text/css" media="print"><!-- end maven --></head>
+<body>
+<H3>Tuscany Calculator-RMI Service - A Simple SCA Assembly that hosts calculator functions as RMI Services</H3>
+<H3>Overview</H3>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD width="100%" valign="top" align="left"> This sample is an assembly of Calculator functions implemented in Java and exposed as RMI Services. The primary objective of developing this sample is to support the Calculator-Combo sample.<BR>
+ <BR>To test this sample you might have to either run the Calculator-Combo sample after running this sample or you might write your won SCA Application that references the services of this sample</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H3>Location</H3>
+<P>The source for this sample is located &nbsp;in the paths - <I>samples\standalone\calculatorRMIService</I>
+ of the source
+distribution.<BR>
+<BR>
+If there is binary distribution available for these samples, then you may find these samples packaged as <I>sample-calculator-rmiService.jar.</I>
+</P>
+<H3><BR>
+Building &amp; Running the CalculatorRMIService Sample Source</H3>
+<P>If you are working with a source distribution, then you must first
+build the source of this sample. <BR>
+- Ensure that you have Java 5 installed on your system.<BR>
+- Next, you must have Maven 2.0.4 installed on your system. Look up
+http://maven.apache.org/download.html for downloading and installing
+Maven.</P>
+<H4>Building the CalculatorRMIService Sample</H4>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top"></TD>
+ <TD valign="top">Having installed Maven, open a command line console
+ and switch over to the directory on your local system, where you have
+ extracted the source.<BR>
+ - Now switch futher into the subdirectory <I>samples\standalone\calcualtorRMIService.
+ </I>Within this directory execute the following command
+ <TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will build the <I>calculatorRMIService</I> sample, package a JAR
+ file for the composite and make it available in the sub-directory <I>samples\standalone\calculatorRMIService/target</I></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4>Setting up Tuscany Standalone Runtime</H4>
+<P>To run these samples you need the Tuscany Standalone Runtime. This is
+available as a distribution that can be conveniently unpacked and setup
+in the samples directory itself. For this, do the following: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top" align="right">i)</TD>
+ <TD>From the directory <I>samples\standalone\calculatorRMIService</I>
+ execute the following command
+ <TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn dependency:unpack</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will unpack the Tuscany Standalone Runtime Distribution to the <I>target\distribution
+ </I>sub-directory within the present working directory - <I>samples\standalone\calculatorRMIService</I></TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>Since this sample would require the RMI Binding Extension of
+ Tuscany you must copy the RMI Extension JAR from the <I>contrib </I>sub-directory
+ into the <I>extensions </I>directory of the distribution. ie. execute
+ the following from the <I>samples\standalone\calculatorRMIService </I>sub-directory:
+ -
+ <TABLE>
+ <TBODY>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">copy
+ target\distribution\contrib\rmi-1.0-incubator-M2.jar <FONT
+ color="purple" face="Courier New">target\distribution\extensions\rmi-1.0-incubator-M2.jar</FONT></FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ <I>Note</I> : <I>If you are working with SNAPSHOTs versions of
+ Tuscany Extensions then the file <B>rmi-1.0-incubator-M2.jar</B> in
+ the above command must be substituted with <B>rmi-1.0-incubator-M2-SNAPSHOT.jar</B></I></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4><BR>
+Running the CalculatorRMIService Sample</H4>
+<P>Now that the sample source has been built and the Tuscany Standalone Runtime setup, you may run the CalculatorRMIService sample as follows: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top">i)</TD>
+ <TD>Switch to the <I>samples\standalone\calculatorRMIService\target\distribution
+ </I>sub-directory and execute the following command:
+ <TABLE>
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">java -jar
+ bin\launcher.jar ..\sample-calculator-rmiService.jar</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>You will initially observe messages that relate to resolution of
+ dependencies required to run this sample and finlly see the following
+ message on your console<BR>
+ <FONT color="green" face="Courier New">**********************************************<BR>
+ Calculator Rmi Service Started and Running...<BR>
+ ***********************************************<BR>
+ Hit ENTER to exit</FONT><FONT color="green"></FONT></TD>
+ </TR>
+ <TR>
+ <TD valign="top">iii)</TD>
+ <TD>This message indicates that the CalculatorRMIServer has been
+ successfully started and is running.</TD>
+ </TR>
+ <TR>
+ <TD valign="top">iv)</TD>
+ <TD>Whenever a client invokes this RMI Service, the console displays a message about the service method invoked.
+</TD>
+ </TR>
+ <TR>
+ <TD valign="top">v)</TD>
+ <TD>Pressing the 'Enter' key will stop the RMI Server and the Tuscany
+ Standalone Runtime, ending this sample with the following message<BR>
+ <FONT color="green" face="Courier New">***********************************************************<BR>
+ Calculator RMI Service Stopped!<BR>
+ *********************************************************** </FONT></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4>Trying the CalculatorRMIService Sample</H4>
+<P>With the CalculatorRMIService started up and running you may try it
+out by writing your own RMI Client that can invoke the
+CalculatorRMIService. The details of the hostname, port and server name
+which your client should look up is as follows: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD align="right">host =</TD>
+ <TD>&quot;localhost&quot;</TD>
+ </TR>
+ <TR>
+ <TD align="right">port =</TD>
+ <TD>&quot;9999&quot;</TD>
+ </TR>
+ <TR>
+ <TD align="right">server name =</TD>
+ <TD>&quot;rmiCalculator&quot;</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<P><I>Note: You are free to modify any of the above (host, port, server
+name) by making corresponding modifications to the default.scdl file of
+the CalculatorRMIService sample and then running this sample.</I></P>
+<P><B><I><FONT color="maroon" size="+0">Note : You may also try the
+CalculatorRMIService Sample by running the Calculator-Combo sample after
+running this sample. For details on setting up and running the
+Calculator-Combo sample look at the readme.html under that sample.</FONT></I></B></P><H2>Code Overview</H2>
+<P>The source files are physically organized as shown below:<BR>
+</P>
+<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td>
+<pre>
+<B><U>Calculator RMI Service</U></B>
++---main<br> +---java<br> | +---calculator
+<I> &lt;Interfaces and Implementations for Calculator Functions&gt;
+
+</I> +---server
+ CalculatorRMIServer.java
+ +---resources
+ +---META-INF
+ +---sca
+ default.scdl<B></B></pre></td></tr></tbody></table>
+<P><B> <BR>
+<BR>
+Calculator RMI Service Sample (Standalone Deployment)</B></P>
+<TABLE border="1">
+ <TBODY>
+ <TR>
+ <TD width="230" valign="top">default.scdl</TD>
+ <TD width="396" valign="top">Defines an assembly of calculator funtions implemented in Java and exposed as an RMI Service.</TD>
+ </TR>
+ <TR>
+ <TD width="230">AddService.java<BR>
+ AddServiceImpl.java<BR>DivideService.java<BR>
+ DivideServiceImpl.java<BR>
+ MathService.java<BR>
+ MathServiceImpl.java<BR>
+ MultiplyService.java<BR>
+ MultiplyServiceImpl.java<BR>
+ SubtractService.java<BR>
+ SubtractServiceImpl.java</TD>
+ <TD width="396">Java Interfaces and Java Implementations for various calculator
+ functions..</TD>
+ </TR>
+ <TR>
+ <TD width="230">CalculatorService.java<BR>CalculatorServiceImpl.java</TD>
+ <TD width="396">Defines the coarse grained Calculator Interface and Implementation. This calculator implementation delegates function requests to other granular implemenations listed above.</TD>
+ </TR>
+ <TR>
+ <TD width="230">CalculatorRMIServer</TD>
+ <TD width="396">The main method of the RMI Server sample that keeps the runtime up and exits the appplication after the user presses 'Enter' key.</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+
+<P></P><P></P>
+</body></html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..6392676e76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..39e9be92e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/AddServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Add service
+ */
+@Scope("MODULE")
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..f1185a2494
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+@Service
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+ double sqrt (double n);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d72c0d30c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Scope("MODULE")
+public class CalculatorServiceImpl implements CalculatorService {
+
+ @Reference
+ protected AddService addService;
+
+ @Reference
+ protected SubtractService subtractService;
+
+ @Reference
+ protected MultiplyService multiplyService;
+
+ @Reference
+ protected DivideService divideService;
+
+ @Reference
+ protected MathService mathService;
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+ public double sqrt(double n) {
+ // TODO Auto-generated method stub
+ return mathService.sqrt(n);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..3158458b5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..159ca463c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/DivideServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Scope("MODULE")
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathService.java
new file mode 100644
index 0000000000..42e8e5ca67
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+
+
+public interface MathService {
+
+ double sqrt(double n);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathServiceImpl.java
new file mode 100644
index 0000000000..76caace7bb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MathServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Scope("MODULE")
+public class MathServiceImpl implements MathService {
+
+ public double sqrt(double n1) {
+ return java.lang.Math.sqrt(n1);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..62db05175e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..2c9053f61a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Scope("MODULE")
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ System.out.println("Multiplying... " + n1 + " x " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..309f88f098
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..3c3388f4cd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/SubtractServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Scope("MODULE")
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/server/CalculatorRMIServer.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/server/CalculatorRMIServer.java
new file mode 100644
index 0000000000..3608d6b92a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/java/calculator/server/CalculatorRMIServer.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator.server;
+
+/**
+ * The class holds up the Tuscany Runtime until a Enter key is pressed
+ *
+ */
+public class CalculatorRMIServer {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ try {
+ System.out.println("*********************************************");
+ System.out.println("Calculator RMI Service Started and Running...");
+ System.out.println("*********************************************");
+ System.out.println("Hit ENTER to exit");
+ System.in.read();
+ System.out.println("Calculator RMI Service Stopped!");
+ System.exit(0);
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..bc12412818
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rmi="http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="calculatorRmiService">
+
+ <service name="calculatorRMIService">
+ <interface.java interface="calculator.CalculatorService"/>
+ <rmi:binding.rmi host="localhost" port="9999" serviceName="rmiCalculator"/>
+ <reference>CalculatorServiceComponent</reference>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService">AddServiceComponent</reference>
+ <reference name="subtractService">SubtractServiceComponent</reference>
+ <reference name="multiplyService">MultiplyServiceComponent</reference>
+ <reference name="divideService">DivideServiceComponent</reference>
+ <reference name="mathService">MathServiceComponent</reference>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <component name="MathServiceComponent">
+ <implementation.java class="calculator.MathServiceImpl"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/test/java/calculator/server/CalculatorRMITestServer.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/test/java/calculator/server/CalculatorRMITestServer.java
new file mode 100644
index 0000000000..0f3408129a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/calculatorRMIService/src/test/java/calculator/server/CalculatorRMITestServer.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator.server;
+
+import org.apache.tuscany.test.SCATestCase;
+
+import calculator.server.CalculatorRMIServer;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorRMITestServer extends SCATestCase {
+
+ protected void setUp() throws Exception {
+
+ addExtension("rmi.extension", getClass().getClassLoader()
+ .getResource("META-INF/sca/rmi_extension.scdl"));
+ setApplicationSCDL(getClass().getClassLoader().getResource("META-INF/sca/default.scdl"));
+ super.setUp();
+
+ }
+
+ public void testCalculatorClient() throws Exception {
+ CalculatorRMIServer.main(new String[0]);
+ }
+
+ protected void tearDown() throws Exception {
+ // super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/NOTICE.txt
new file mode 100644
index 0000000000..e445fc9ae5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/pom.xml
new file mode 100644
index 0000000000..b799db3738
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-greeterwsclient-oneway</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany HelloWorld Web Service Async Client Sample</name>
+ <description>A sample client for a HelloWorld Web Service.</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.0.1</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-axiom</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>sample-greeterwsclient-oneway-1.0-incubator-M2</finalName>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>greeter.GreeterClient</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>${notice.dir}</directory>
+ <targetPath>META-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>LICENSE.txt</include>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/readme.html
new file mode 100644
index 0000000000..3201794102
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/readme.html
@@ -0,0 +1,129 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Greeter OneWay Webservice Client Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Greeter One-Way Client Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Greeter One-Way client sample shows using the Tuscany SCA
+ runtime in a J2SE environment &nbsp;loading a component client that
+ performs an asynchronous one-way web service call.
+ The client uses a one-way (asynchronous) interface
+ that is supported by the web services binding (binding.ws) that
+ it specifies. The component definition is given implicitly by
+ the Java code and the use of the <code>@OneWay</code> annotation.</p>
+ </p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ <span style=
+ "font-weight: bold;">samples\standalone\greeterwsclient-oneway</span> directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-greeterwsclient-oneway-1.0-incubator-M2.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>This sample depends on the <a href=
+ "../../webapp/greeterws-oneway/readme.html" target=
+ "_blank">greeterws-oneway</a> already running to
+ execute successfully</p>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <p>Each sample can require one or more Tuscany runtime
+ extensions. For this sample copy from <span style=
+ "font-weight: bold;">target\distribution\contrib</span> to the
+ <span style=
+ "font-weight: bold;">target\distribution\extensions</span>
+ directory the following extensions:</p>
+
+ <table style="text-align: left;" class="extensiontable" border=
+ "1" cellpadding="2" cellspacing="2">
+ <tbody>
+ <tr>
+ <td class="extensiontable">axis2-1.0-incubator-M2.jar</td>
+
+ <td class="extensiontable" align="undefined" valign=
+ "undefined">Axis webservices binding</td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-greeterwsclient-oneway-1.0-incubator-M2.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the <span style=
+ "font-weight: bold;">Tomcat console window's</span> standard output:</p>
+ <p><samp>Hello John</samp></p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java
new file mode 100644
index 0000000000..1aa3dce320
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterClient.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package greeter;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class GreeterClient {
+
+ public final static void main(String[] args) throws Exception {
+ CompositeContext compositeContext = CurrentCompositeContext.getContext();
+ GreeterLocal greeterLocal =
+ compositeContext.locateService(GreeterLocal.class, "GreeterServiceComponent");
+ greeterLocal.greet("John");
+ System.out.println("Sleeping for 5 seconds ...");
+ Thread.sleep(5000);
+ System.out.println("Done ...");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java
new file mode 100644
index 0000000000..39ca24aadd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterImpl.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package greeter;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class GreeterImpl implements GreeterLocal {
+
+ private GreeterService greeterService;
+
+ @Reference
+ public void setGreeterService(GreeterService greeterService) {
+ this.greeterService = greeterService;
+ }
+
+ public void greet(String name) {
+ this.greeterService.greet(name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java
new file mode 100644
index 0000000000..7cf650f73b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterLocal.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package greeter;
+
+public interface GreeterLocal {
+ public void greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java
new file mode 100644
index 0000000000..57279b8a7c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/java/greeter/GreeterService.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package greeter;
+
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+@Remotable
+@Service
+public interface GreeterService {
+ @OneWay
+ public void greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..c450e10408
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" name="greeterws">
+
+ <component name="GreeterServiceComponent">
+ <implementation.java class="greeter.GreeterImpl" />
+ </component>
+
+ <component name="GreeterServiceComponent">
+ <implementation.java class="greeter.GreeterImpl" />
+ <reference name="greeterService">GreeterService</reference>
+ </component>
+
+ <reference name="GreeterService">
+ <!--
+ <interface.java interface="helloworld.HelloWorldService"
+ callbackInterface="helloworld.HelloWorldCallback"/>
+ -->
+
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" interface="http://greeter#wsdl.interface(Greeter)"
+ wsdli:wsdlLocation="http://greeter wsdl/greeter.wsdl" />
+
+ <binding.ws endpoint="http://greeter#wsdl.endpoint(GreeterService/GreeterSoapPort)" location="wsdl/greeter.wsdl" />
+ </reference>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl
new file mode 100644
index 0000000000..f96b24bae6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/main/resources/wsdl/greeter.wsdl
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://greeter" xmlns:tns="http://greeter" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="greeter">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://greeter" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="greet">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="greetRequest">
+ <wsdl:part element="tns:greet" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="greet">
+ <wsdl:input message="tns:greetRequest" name="greetRequest" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="GreeterSoapBinding" type="tns:Greeter">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="greet">
+ <wsdlsoap:operation soapAction="greet" />
+ <wsdl:input name="greetRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="GreeterService">
+ <wsdl:port binding="tns:GreeterSoapBinding" name="GreeterSoapPort">
+ <wsdlsoap:address
+ location="http://localhost:8080/sample-greeterws-oneway-1.0-incubator-M2/services/GreeterWebService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java
new file mode 100644
index 0000000000..1f017744de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/java/greeter/GreeterWSOneWayClient.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package greeter;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class GreeterWSOneWayClient extends SCATestCase {
+
+ private GreeterLocal greeterLocal;
+
+ @Override
+ protected void setUp() throws Exception {
+ try {
+ setApplicationSCDL(GreeterService.class, "META-INF/sca/default.scdl");
+ ClassLoader classLoader = getClass().getClassLoader();
+ addExtension("test.extensions", classLoader.getResource("META-INF/tuscany/test-extensions.scdl"));
+
+ super.setUp();
+ CompositeContext compositeContext = CurrentCompositeContext.getContext();
+ greeterLocal = compositeContext.locateService(GreeterLocal.class, "GreeterServiceComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public void testWSClient() {
+ try {
+ greeterLocal.greet("John");
+
+ System.out.println("Sleeping ...");
+ Thread.sleep(5000);
+
+ System.out.println("Done ...");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl
new file mode 100644
index 0000000000..ec3643cf00
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/greeterwsclient-oneway/src/test/resources/META-INF/tuscany/test-extensions.scdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="test.extensions">
+
+ <include name="org.apache.tuscany.databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl"/>
+ <include name="org.apache.tuscany.databinding.sdo" scdlResource="META-INF/sca/databinding.sdo.scdl"/>
+ <include name="org.apache.tuscany.idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl"/>
+ <include name="org.apache.tuscany.binding.axis2" scdlResource="META-INF/sca/binding.axis2.scdl"/>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/pom.xml
new file mode 100644
index 0000000000..d8184fc5b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworld-javascript</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany JavaScript Helloworld Sample</name>
+ <description>A helloworld sample using a single SCA JavaScript component</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r${specVersion}</artifactId>
+ <version>${scaVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <version>${scaImplVersion}</version>
+ <artifactId>test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>javascript</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/readme.html
new file mode 100644
index 0000000000..bf10f0caa9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/readme.html
@@ -0,0 +1,104 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany JavaScript Helloworld Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany JavaScript Helloworld Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>This sample illustrates the use of an extension to support implementation types other than Java. In this sample the component is implemented using a JavaScript script.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\helloworldJavaScript directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-helloworld-javascript.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <p>The Tuscany JavaScript implementation requires the JavaScript extension so you need to copy this to the standalone launcher extensions directory:</p>
+ <pre>
+<code>copy target\distribution\contrib\javascript-1.0-incubator-M2.jar target\distribution\extensions<br></code>
+</pre>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-helloworld-javascript.jar Petra</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>Hello Petra
+</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..257270f65a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldClient.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate the HelloWorld service and invoke it.
+ */
+public class HelloWorldClient {
+ public static void main(String[] args) throws Exception {
+
+ HelloWorldService helloWorldService = CurrentCompositeContext.getContext().locateService(HelloWorldService.class,
+ "HelloWorldComponent");
+
+ System.out.println(helloWorldService.sayHello(args.length < 1 ? "world" : args[0]));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..bfea460664
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+public interface HelloWorldService {
+
+ String sayHello(String s);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.componentType b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.componentType
new file mode 100644
index 0000000000..2b18d7f75d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.js b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.js
new file mode 100644
index 0000000000..520153329e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/HelloWorld.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+function sayHello(s) {
+ return "Hello " + s;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..03209cb450
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:js="http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2"
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <js:implementation.js script="HelloWorld.js"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..77a51bb7e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldJavaScript/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import java.net.URL;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends SCATestCase {
+
+ private HelloWorldService helloWorldService;
+
+ protected void setUp() throws Exception {
+ URL scdl = getClass().getClassLoader().getResource("META-INF/sca/js.system.scdl");
+ addExtension("JavaScriptContainer", scdl);
+ setApplicationSCDL(HelloWorldService.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponent");
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+ public void testHelloWorld() throws Exception {
+ assertEquals(helloWorldService.sayHello("petra"), "Hello petra");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/pom.xml
new file mode 100644
index 0000000000..41fda4bb3c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworld-rmiReference</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany RMI Reference Helloworld Sample</name>
+ <description>A helloworld sample using a RMI Reference</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>rmi</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldRmiClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/readme.html
new file mode 100644
index 0000000000..c6dae4784c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/readme.html
@@ -0,0 +1,215 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><!-- * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><title>Tuscany
+Hello World RMI Reference Sample</title><!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
+<style type="text/css" media="all">
+@import url("../../../../css/maven-base.css");
+@import url("../../../../css/maven-theme.css");
+@import url("../../../../css/site.css");
+</style><link rel="stylesheet" href="./css/print.css" type="text/css" media="print"><!-- end maven --></head>
+<body>
+<H3>Tuscany HelloWorld - RMI Reference Sample</H3>
+<H3>Overview</H3>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD width="100%" valign="top" align="left">The RMI Reference sample demonstrates how the Tuscany Runtime provides RMI client bindings for service components that would like to refer RMI Servcies.</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H3>Location</H3>
+<P>The source for this sample is located &nbsp;in the paths - <I>samples\standalone\helloworldRMIReference</I> <I></I>
+ of the source
+distribution.<BR>
+<BR>If there is binary distribution available for these samples, then you may find these samples packaged as <I></I><I>sample-helloworld-rmiReference.jar.</I>
+</P>
+<H3>Building &amp; Running the HelloWorldRMIReference Sample Source</H3>
+<P>If you are working with a source distribution, then you must first build the source of this sample. <BR>- Ensure that you have Java 5 installed on your system.<BR>- Next, you must have Maven 2.0.4 installed on your system. Look up
+http://maven.apache.org/download.html for downloading and installing
+Maven.</P>
+<H4>Building the HelloWorldRMIReference Sample</H4>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top"></TD>
+ <TD valign="top">Having installed Maven, , open a command line console and switch over to the directory on your local
+system, where you have extracted the source.<BR>-
+ Now switch futher into
+the subdirectory <I>samples\standalone\helloworldRMIReference. </I>In this directory execute the following command<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>This will build the <I>helloworldRMIReference</I> sample, package a JAR file for the composite and make this available in sub-directory <I>samples\standalone\helloworldRMIReference\target</I></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4>Setting up Tuscany Standalone Runtime </H4>
+<P>To run these samples you need the Tuscany Standalone Runtime. This is
+available as a distribution that can be conveniently unpacked and setup
+in the samples directory itself. For this, do the following: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top" align="right">i) </TD>
+ <TD>From the directory <I>samples\standalone\helloworldRMIReference</I>
+ execute the following command<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn dependency:unpack</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will unpack the Tuscany Standalone Runtime Distribution to the <I>target\distribution </I>sub-directory within the present working directory - <I>samples\standalone\helloworldRMIReference</I></TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>Since this sample would require the RMI Binding Extension of Tuscany you must copy the RMI Extension JAR from the <I>contrib </I>sub-directory into the <I>extensions </I>directory of the distribution. ie. execute the following from the
+ <I>samples\standalone\helloworldRMIReference </I>sub-directory: -
+ <TABLE>
+ <TBODY>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">copy target\distribution\contrib\rmi-1.0-incubator-M2.jar <FONT
+ color="purple" face="Courier New">target\distribution\extensions\rmi-1.0-incubator-M2.jar</FONT></FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ <I>Note</I> : <I>If you are working with SNAPSHOTs versions of
+ Tuscany Extensions then the file <B>rmi-1.0-incubator-M2.jar</B> in
+ the above command must be substituted with <B>rmi-1.0-incubator-M2-SNAPSHOT.jar</B></I></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4><BR>
+Running the HelloWorldRMIReference Sample</H4>
+<P>Now that the sample source has been built and the Tuscany Standalone Runtime setup, you may run the HelloWorldRMIReference sample as follows: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top">i) </TD>
+ <TD>First ensure that the HelloWorldRMIService Sample is up and running. </TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>Switch to the <I>samples\standalone\helloworldRMIReference\target\distribution
+ </I>sub-directory and execute the following command: <TABLE>
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">java -jar
+ bin\launcher.jar ..\sample-helloworld-rmiReference.jar</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </TD>
+ </TR>
+ <TR>
+ <TD valign="top">iii)</TD>
+ <TD>Running this sample will send a <I>'sayHello'</I> request to the HelloWorldRMIService (that must be running) with the argument '<I>name</I>' set to the string <I>&quot;SCA
+ RMI Client&quot;</I></TD>
+ </TR>
+ <TR>
+ <TD valign="top">iii)</TD>
+ <TD>You will initially observe messages that relate to resolution of dependencies required to run this sample and finlly see the following message on your console<BR>
+ <FONT face="Courier New" color="green"></FONT><FONT color="green" face="Courier New">***********************************************************<BR>
+ Hello SCA RMI Client - from the SCA RMI Service<BR>
+ ***********************************************************</FONT></TD>
+ </TR>
+ <TR>
+ <TD valign="top">iv)</TD>
+ <TD>This message indicates that the HelloWorldRMIReference sample has successfuly invoked the HelloWorldRMIService and obtained the string value <FONT
+ color="green" face="Courier New">&quot;Hello SCA RMI Client - from the SCA
+ RMI Service&quot;</FONT></TD>
+ </TR>
+ <TR>
+ <TD valign="top">v)</TD>
+ <TD>Meanwhile, on the console where you have started the HelloworldRMIService sample you will see a message <FONT
+ color="green">&quot;Saying Hello to - SCA RMI Client&quot;</FONT> that is displayed (implying that its service method was invoked)</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H3><B><I><FONT color="maroon" size="+1">Note : You may also try the
+HelloWorldRMIReference Sample by creating your own RMI Server with the following attributes </FONT></I></B></H3><TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD align="right"><FONT color="maroon">host =</FONT></TD>
+ <TD><FONT color="maroon">&quot;localhost&quot;</FONT></TD>
+ </TR>
+ <TR>
+ <TD align="right"><FONT color="maroon">port =</FONT></TD>
+ <TD><FONT color="maroon">&quot;1099&quot;</FONT></TD>
+ </TR>
+ <TR>
+ <TD align="right"><FONT color="maroon">server name =</FONT></TD>
+ <TD><FONT color="maroon">&quot;HelloWorldRemoteService&quot;</FONT></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<P><I><FONT color="maroon">Note: You are free to modify any of the above
+(host, port, server name) by making corresponding modifications to the
+default.scdl file of the HelloWorldRMIReference sample and then running this
+sample.</FONT></I></P>
+<P><B><I><FONT color="maroon" size="+1"></FONT></I></B>
+</P><H3>Code Overview</H3>
+The source files are physically organized as shown below:<br>
+<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td>
+<pre>
+<U><B></B></U><B><U>RMI Reference Sample</U></B>
++---main<BR> +---java<BR> | +---helloworld
+ HelloWorldService.java
+ HelloWorldImpl.java
+ HelloWorldRmiClient.java
+ +---resources
+ +----META-INF
+ +----sca
+ default.scdl</pre></td></tr></tbody></table>
+<H4><BR>
+<B>RMI Reference Sample</B></H4>
+<TABLE border="1">
+ <TBODY>
+ <TR>
+ <TD width="230" valign="top">default.scdl</TD>
+ <TD width="396" valign="top">Defines the assembly of the Helloworld
+ Application with the HelloWorldImpl component referring the a
+ HelloWorld RMI Service</TD>
+ </TR>
+ <TR>
+ <TD width="230">HelloWorldService.java</TD>
+ <TD width="396">Defines a HelloWorld service interface</TD>
+ </TR>
+ <TR>
+ <TD width="230">HelloWorldImpl.java</TD>
+ <TD width="396">Implements the HelloWorldService interface. This
+ implementation inturn calls out to the RMI Service under the covers
+ of the SCA Runtime - i.e. you will never notice any APIs in
+ java.rmi.* used in this application</TD>
+ </TR>
+ <TR>
+ <TD width="230">HelloWorldRmiClient.java</TD>
+ <TD width="396">Launches the Standalone Tuscany Runtime with the RMI
+ Client SCA Application loaded and run.</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+</p></body></html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..b024f28b54
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService
+{
+ @Reference
+ private HelloWorldService extService = null;
+
+ public HelloWorldService getExtService() {
+ return extService;
+ }
+
+ @Reference
+ public void setExtService(HelloWorldService extService) {
+ this.extService = extService;
+ }
+
+ public String sayHello(String name)
+ {
+ return extService.sayHello(name);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldRmiClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldRmiClient.java
new file mode 100644
index 0000000000..cfb0d3eee0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldRmiClient.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * @author administrator
+ *
+ */
+public class HelloWorldRmiClient {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ try {
+ HelloWorldRmiClient rmiClient = new HelloWorldRmiClient();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldServiceComponent");
+ System.out.println("***********************************************************");
+ System.out.println(helloWorldService.sayHello("SCA RMI Client"));
+ System.out.println("***********************************************************");
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..bed93eec99
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldService {
+
+ public String sayHello(String name) ;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/HelloWorldImpl.componentType b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..7f886c850b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/HelloWorldImpl.componentType
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+ <reference name="extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..72ec35ed96
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIReference/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rmi="http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2"
+ name="HelloWorldRmiComposite">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ <reference name="extService">HelloWorldRmiService</reference>
+ </component>
+
+ <reference name="HelloWorldRmiService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <rmi:binding.rmi host="localhost" port="1099" serviceName="HelloWorldRemoteService" />
+ </reference>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/pom.xml
new file mode 100644
index 0000000000..15ffd280af
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworld-rmiService</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany RMI Service Helloworld Sample</name>
+ <description>A helloworld sample hosting RMI Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>rmi</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldRmiServer</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/readme.html
new file mode 100644
index 0000000000..93b19f8e88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/readme.html
@@ -0,0 +1,206 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><!-- * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><title>Tuscany
+Hello World RMI Service Sample</title><!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
+<style type="text/css" media="all">
+@import url("../../../../css/maven-base.css");
+@import url("../../../../css/maven-theme.css");
+@import url("../../../../css/site.css");
+</style><link rel="stylesheet" href="./css/print.css" type="text/css" media="print"><!-- end maven --></head>
+<body>
+<H3>Tuscany HelloWorld - RMI Service Sample</H3>
+<H3>Overview</H3>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD width="100%" valign="top" align="left">The RMI Service sample demonstrates how the Tuscany Runtime can be used to host service components as RMI Services without the need to make any modifications to the service interfaces.</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H3>Location</H3>
+<P>The source for this sample is located &nbsp;in the paths - <I>samples\standalone\helloworldRMIService</I> <I></I>
+ of the source
+distribution.<BR>
+<BR>If there is binary distribution available for these samples, then you may find these samples packaged as <I>sample-helloworld-rmiService.jar.</I></P>
+<H3>Building &amp; Running the HelloWorldRMIService Sample Source</H3>
+<P>If you are working with a source distribution, then you must first build the source of this sample. <BR>- Ensure that you have Java 5 installed on your system.<BR>- Next, you must have Maven 2.0.4 installed on your system. Look up
+http://maven.apache.org/download.html for downloading and installing
+Maven.</P>
+<H4>Building the HelloWorldRMIService Sample</H4>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top"></TD>
+ <TD valign="top">Having installed Maven, open a command line console and switch over to the directory on your local
+system, where you have extracted the source.<BR>-
+ Now switch futher into
+the subdirectory <I>samples\standalone\helloworldRMIService. </I>Within
+this directory execute the following command<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>This will build the <I>helloworldRMIService</I> sample, package a JAR file for the composite and make it available in the sub-directory <I>samples\standalone\helloworldRMIService/target</I></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4>Setting up Tuscany Standalone Runtime </H4>
+<P>To run these samples you need the Tuscany Standalone Runtime. This is
+available as a distribution that can be conveniently unpacked and setup
+in the samples directory itself. For this, do the following: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top" align="right">i) </TD>
+ <TD>From the directory <I>samples\standalone\helloworldRMIService</I>
+ execute the following command<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn dependency:unpack</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will unpack the Tuscany Standalone Runtime Distribution to the <I>target\distribution </I>sub-directory within the present working directory - <I>samples\standalone\helloworldRMIService</I></TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>Since this sample would require the RMI Binding Extension of Tuscany you must copy the RMI Extension JAR from the <I>contrib </I>sub-directory into the <I>extensions </I>directory of the distribution. ie. execute the following from the
+ <I>samples\standalone\helloworldRMIService </I>sub-directory: -
+ <TABLE>
+ <TBODY>
+ <TR>
+ <TD valign="top"><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">copy target\distribution\contrib\rmi-1.0-incubator-M2.jar <FONT
+ color="purple" face="Courier New">target\distribution\extensions\rmi-1.0-incubator-M2.jar</FONT></FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ <I>Note</I> : <I>If you are working with SNAPSHOTs versions of
+ Tuscany Extensions then the file <B>rmi-1.0-incubator-M2.jar</B> in
+ the above command must be substituted with <B>rmi-1.0-incubator-M2-SNAPSHOT.jar</B></I></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4><BR>
+Running the HelloWorldRMIService Sample</H4>
+<P>Now that the sample source has been built and the Tuscany Standalone Runtime setup, you may run the HelloWorldRMIService sample as follows: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top">i) </TD>
+ <TD>Switch to the <I>samples\standalone\helloworldRMIService\target\distribution </I>sub-directory and execute the following command: <TABLE>
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">java -jar bin\launcher.jar ..\sample-helloworld-rmiService.jar</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE></TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>You will initially observe messages that relate to resolution of dependencies required to run this sample and finlly see the following message on your console<BR>
+ <FONT face="Courier New" color="green">***********************************************************<BR>
+ Helloworld RMI Service Started and Running...<BR>
+ ***********************************************************<BR>
+ Hit ENTER to exit</FONT><FONT color="green"></FONT></TD>
+ </TR>
+ <TR>
+ <TD valign="top">iii)</TD>
+ <TD>This message indicates that the HelloWorldRMIServer has been successfully started and is running. </TD>
+ </TR>
+ <TR>
+ <TD valign="top">iv)</TD>
+ <TD>For every client invocation, you will see a message <FONT
+ color="green">&quot;Saying Hello to - &lt;name&gt;&quot;</FONT> that is displayed</TD>
+ </TR>
+ <TR>
+ <TD valign="top">v)</TD>
+ <TD>Pressing the 'Enter' key will stop the RMI Server and the Tuscany Standalone Runtime, ending this sample with the following message<BR>
+ <FONT color="green" face="Courier New">***********************************************************<BR>
+ Server Stopped!<BR>
+ *********************************************************** </FONT></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4><BR>
+Trying the HelloWorldRMIService Sample</H4>
+<P>With the HelloWorldRMIService started up and running you may try it out by writing your own RMI Client that can invoke the HelloWorldRMIService. The details of the hostname, port and server name which your client should look up is as follows: -</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD align="right">host =</TD>
+ <TD>&quot;localhost&quot;</TD>
+ </TR>
+ <TR>
+ <TD align="right">port =</TD>
+ <TD>&quot;1099&quot;</TD>
+ </TR>
+ <TR>
+ <TD align="right">server name =</TD>
+ <TD>&quot;HelloWorldRemoteService&quot;</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<P><I>Note: You are free to modify any of the above (host, port, server
+name) by making corresponding modifications to the default.scdl file of
+the HelloWorldRMIService sample and then running this sample.</I></P>
+<P><B><I><FONT color="maroon" size="+1">Note : You may also try the HelloWorldRMIService
+Sample by running the HelloWorldRMIReference Sample.</FONT></I></B><BR>
+</P><H3>Code Overview</H3>
+The source files are physically organized as shown below:<br>
+<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td>
+<pre>
+<B><U>RMI Service Sample</U></B>
++---main<br> +---java<br> | +---helloworld
+ HelloWorldService.java
+ HelloWorldImpl.java
+ HelloWorldRmiServer.java
+ +---resources
+ +----META-INF
+ +----sca
+ default.scdl</pre></td></tr></tbody></table>
+<B> <BR>
+<BR><H4>RMI Service Sample</H4></B>
+<TABLE border="1">
+ <TBODY>
+ <TR>
+ <TD width="230" valign="top">default.scdl</TD>
+ <TD width="396" valign="top">Defines the assembly of the Helloworld Server Application with the HelloWorldImpl component defined to be hosted as an RMI Service under the covers of the SCA Runtime. You will never notice any APIs in java.rmi.*</TD>
+ </TR>
+ <TR>
+ <TD width="230">HelloWorldService.java</TD>
+ <TD width="396">Defines a HelloWorld service interface</TD>
+ </TR>
+ <TR>
+ <TD width="230">HelloWorldImpl.java</TD>
+ <TD width="396">Implements the HelloWorldService interface</TD>
+ </TR>
+ <TR>
+ <TD width="230">HelloWorldRmiServer.java</TD>
+ <TD width="396">Launches the Standalone Tuscany Runtime with the RMI Server SCA Application loaded and running</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+
+<P></P></p></body></html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..55982b38b9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService
+{
+
+ public String sayHello(String name)
+ {
+ System.out.println("Saying hello to - " + name);
+ return "Hello " + name + " - from the SCA RMI Service";
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldRmiServer.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldRmiServer.java
new file mode 100644
index 0000000000..e423f4e068
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldRmiServer.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+
+/**
+ * @author administrator
+ */
+public class HelloWorldRmiServer {
+
+ public static void main(String[] args) {
+ try {
+ System.out.println("***********************************************************");
+ System.out.println("Helloworld RMI Service Started and Running...");
+ System.out.println("***********************************************************");
+ System.out.println("Hit ENTER to exit");
+ System.in.read();
+ System.out.println("***********************************************************");
+ System.out.println("Server Stopped!");
+ System.out.println("***********************************************************");
+ System.exit(0);
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..0384344c2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldService {
+
+ public String sayHello(String name);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/HelloWorldImpl.componentType b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..6f90076a96
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/HelloWorldImpl.componentType
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..d5ab91e428
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRMIService/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rmi="http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2"
+ name="HelloWorldRmiComposite">
+
+ <service name="HelloWorldRmiService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <rmi:binding.rmi host="localhost" port="1099" serviceName="HelloWorldRemoteService" />
+ <reference>HelloWorldServiceComponent</reference>
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/pom.xml
new file mode 100644
index 0000000000..94a9480dc4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworld-ruby</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Ruby helloworld Sample</name>
+ <description>A helloworld sample using a single SCA Ruby component</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>${scaVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <version>${scaImplVersion}</version>
+ <artifactId>test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>ruby</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/readme.html
new file mode 100644
index 0000000000..ce05039861
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/readme.html
@@ -0,0 +1,104 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Ruby Helloworld Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Ruby Helloworld Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>This sample illustrates the use of an extension to support implementation types other than Java. In this sample the component is implemented using a Ruby script.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\helloworldRuby directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-helloworld-ruby.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <p>The Tuscany Ruby implementation requires the Ruby extension so you need to copy this to the standalone launcher extensions directory:</p>
+ <pre>
+<code>copy target\distribution\contrib\ruby-1.0-incubator-M2.jar target\distribution\extensions<br></code>
+</pre>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-helloworld-ruby.jar Petra</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>Hello to Petra from the Ruby World!
+</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..719a967230
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldClient.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * Client program to invoke the HelloWorld Ruby component
+ */
+public class HelloWorldClient {
+ public static void main(String[] args) throws Exception {
+
+ HelloWorldService helloWorldService =
+ CurrentCompositeContext.getContext().locateService(HelloWorldService.class, "HelloWorldComponent");
+
+ System.out.println(helloWorldService.sayHello(args.length < 1 ? "world" : args[0]));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..fd126a197a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+public interface HelloWorldService {
+
+ String sayHello(String s);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.componentType b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.componentType
new file mode 100644
index 0000000000..f3ae71779e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.rb b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.rb
new file mode 100644
index 0000000000..d9e54620f0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/HelloWorld.rb
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class Helloworld
+
+ def sayHello(s)
+ return "Hello to " + s + " from the Ruby World!"
+ end
+
+end
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..3fd1599f79
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,15 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the JRuby project (http://jruby.codehaus.org/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..0cd9855b7a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rb="http://incubator.apache.org/tuscany/xmlns/container/rb/1.0-incubator-M2"
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <rb:implementation.rb script="HelloWorld.rb" class="Helloworld"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..65d36d714b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldRuby/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import java.net.URL;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends SCATestCase {
+
+ private HelloWorldService helloWorldService;
+
+ protected void setUp() throws Exception {
+ URL scdl = getClass().getClassLoader().getResource("META-INF/sca/ruby.system.scdl");
+ addExtension("RubyContainer", scdl);
+ setApplicationSCDL(HelloWorldService.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponent");
+ }
+
+ public void testHelloWorld() throws Exception {
+ assertEquals("Hello to petra from the Ruby World!", helloWorldService.sayHello("petra"));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/pom.xml
new file mode 100644
index 0000000000..787fa56681
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/pom.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworldwsclient-async</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany HelloWorld Web Service Async Client Sample</name>
+ <description>A sample client for a HelloWorld Web Service.</description>
+
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.0.1</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-axiom</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldClient</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>${notice.dir}</directory>
+ <targetPath>META-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>LICENSE.txt</include>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/readme.html
new file mode 100644
index 0000000000..163d8b16a2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/readme.html
@@ -0,0 +1,131 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Hello World Async Client Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Hello World Async Client Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany helloworld sample shows using the Tuscany SCA runtime in a J2SE environment &nbsp;loading a component client that
+ performs an asynchronous web service call with callback. The client uses a bi-directional (asynchronous) interface
+ that is supported by the web services binding (binding.ws) that it specifies. The component definition is given
+ implicitly by the Java code and the use of the <code>@Callback</code> annotation.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\helloworldwsclient-async directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-helloworldwsclient-async-1.0-incubator-M2.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>This sample depends on the <a href=
+ "../../webapp/helloworldws-async/readme.html" target=
+ "_blank">Tuscany Hello World Async WS sample</a> already running to
+ execute successfully</p>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <p>Each sample can require one or more Tuscany runtime
+ extensions. For this sample copy from <span style=
+ "font-weight: bold;">target\distribution\contrib</span> to the
+ <span style=
+ "font-weight: bold;">target\distribution\extensions</span>
+ directory the following extensions:</p>
+
+ <table style="text-align: left;" class="extensiontable" border=
+ "1" cellpadding="2" cellspacing="2">
+ <tbody>
+ <tr>
+ <td class="extensiontable">axis2-1.0-incubator-M2.jar</td>
+
+ <td class="extensiontable" align="undefined" valign=
+ "undefined">Axis webservices binding</td>
+ </tr>
+
+ <tr>
+ <td class="extensiontable" align="undefined" valign=
+ "undefined">databinding-sdo-1.0-incubator-M2.jar</td>
+
+ <td class="extensiontable" align="undefined" valign=
+ "undefined">SDO data biinding.</td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-helloworldwsclient-async-1.0-incubator-M2.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+ <samp>Hello John</samp></p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java
new file mode 100644
index 0000000000..adc48e85a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldCallback.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface HelloWorldCallback {
+
+ public void getGreetingsCallback(String getGreetingsReturn);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..f59c409f45
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldClient.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to invoke a web service asynchronously with a callback
+ */
+
+public class HelloWorldClient {
+
+ public final static void main(String[] args) throws Exception {
+
+ CompositeContext compositeContext = CurrentCompositeContext.getContext();
+ HelloWorldLocal helloWorldLocal =
+ compositeContext.locateService(HelloWorldLocal.class, "HelloWorldServiceComponent");
+ helloWorldLocal.getGreetings("John");
+
+ // Sleep for 5 seconds to wait the callback to happen
+ Thread.sleep(5000);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java
new file mode 100644
index 0000000000..a5b9074af0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldLocal.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+
+@Service
+public interface HelloWorldLocal {
+
+ public String getGreetings(String name);
+ @DataType(name="commonj.sdo.DataObject")
+ public String getGreetings1(DataObject name);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..fc64f62a7b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+
+@Remotable
+@Service
+@Callback(HelloWorldCallback.class)
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+ @DataType(name="commonj.sdo.DataObject")
+ public String getGreetings1(DataObject name);
+
+ public void getGreetingsWithCallback(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java
new file mode 100644
index 0000000000..af5a21f5a1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/java/helloworld/HelloWorldServiceComponent.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Scope;
+
+import commonj.sdo.DataObject;
+
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the HelloWorld service and invoke it.
+ */
+
+
+@Scope("MODULE")
+public class HelloWorldServiceComponent implements HelloWorldLocal {
+
+ HelloWorldService helloWorldService;
+
+ public String getGreetings(String name) {
+
+ return helloWorldService.getGreetings(name);
+ }
+
+ public HelloWorldService getHelloWorldService() {
+ return helloWorldService;
+ }
+
+ public void setHelloWorldService(HelloWorldService helloWorldService) {
+ this.helloWorldService = helloWorldService;
+ }
+
+ public String getGreetings1(DataObject name) {
+ return helloWorldService.getGreetings1(name);
+ }
+
+ public void getGreetingsCallback(String getGreetingsReturn) {
+ System.out.println("Callback: " + getGreetingsReturn);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..2f52a1fae7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="helloworldwsclient">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-sdo</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" location="wsdl/helloworld.wsdl"/>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldServiceComponent"/>
+ <reference name="helloWorldService">HelloWorldService</reference>
+ </component>
+
+ <reference name="HelloWorldService">
+ <!--
+ <interface.java interface="helloworld.HelloWorldService"
+ callbackInterface="helloworld.HelloWorldCallback"/>
+ -->
+
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ interface="http://helloworld#wsdl.interface(HelloWorld)"
+ callbackInterface="http://helloworld#wsdl.interface(HelloWorldCallback)"
+ wsdli:wsdlLocation="http://helloworld wsdl/helloworld.wsdl" />
+
+ <binding.ws endpoint="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)"
+ location="wsdl/helloworld.wsdl" />
+ </reference>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/logging.properties
new file mode 100644
index 0000000000..78e24f1633
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/logging.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# $Rev$ $Date$
+#
+
+# Custom logging configuration for Tuscany samples
+# By default, only INFO level logging is enabled and ALL messages get sent to the console
+# For more messages from the runtime, uncomment specific settings at the end of this file
+handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = ALL
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+.level=INFO
+
+# Uncomment the next setting to get all Tuscany messages (this will be a lot)
+#org.apache.tuscany.level=FINEST
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/wsdl/helloworld.wsdl
new file mode 100644
index 0000000000..179e6319f2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/main/resources/wsdl/helloworld.wsdl
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsCallback">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetings1">
+ <complexType>
+ <sequence>
+ <element name="name" type="tns:NameType">
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+
+ <complexType name="NameType">
+ <sequence>
+ <element name="firstName" type="string"/>
+ <element name="lastName" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="getGreetings1Response">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsCallback">
+ <wsdl:part element="tns:getGreetingsCallback" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Request">
+ <wsdl:part element="tns:getGreetings1" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Response">
+ <wsdl:part element="tns:getGreetings1Response" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdl:input message="tns:getGreetings1Request" name="getGreetings1Request"/>
+ <wsdl:output message="tns:getGreetings1Response" name="getGreetings1Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsWithCallback">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:portType name="HelloWorldCallback">
+ <wsdl:operation name="getGreetingsCallback">
+ <wsdl:input message="tns:getGreetingsCallback" name="getGreetingsCallback"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetings1Request">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetings1Response">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsWithCallback">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/sample-helloworldws-async-1.0-incubator-M2-SNAPSHOT/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/java/helloworld/HelloWorldWSAsyncClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/java/helloworld/HelloWorldWSAsyncClient.java
new file mode 100644
index 0000000000..294e83a582
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/java/helloworld/HelloWorldWSAsyncClient.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * Test case for helloworld web service client
+ */
+public class HelloWorldWSAsyncClient extends SCATestCase {
+
+ private HelloWorldLocal helloWorldLocal;
+
+ @Override
+ protected void setUp() throws Exception {
+ try {
+ setApplicationSCDL(HelloWorldCallback.class, "META-INF/sca/default.scdl");
+ ClassLoader classLoader = getClass().getClassLoader();
+ addExtension("test.extensions", classLoader.getResource("META-INF/tuscany/test-extensions.scdl"));
+
+ super.setUp();
+ CompositeContext compositeContext = CurrentCompositeContext.getContext();
+ helloWorldLocal =
+ compositeContext.locateService(HelloWorldLocal.class, "HelloWorldServiceComponent");
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public void testWSClient() throws Exception {
+ try {
+ String msg = helloWorldLocal.getGreetings("John");
+ Assert.assertNull(msg);
+
+ // Sleep for 5 seconds to wait the callback to happen
+ Thread.sleep(5000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/resources/META-INF/tuscany/test-extensions.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/resources/META-INF/tuscany/test-extensions.scdl
new file mode 100644
index 0000000000..ec3643cf00
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient-async/src/test/resources/META-INF/tuscany/test-extensions.scdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="test.extensions">
+
+ <include name="org.apache.tuscany.databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl"/>
+ <include name="org.apache.tuscany.databinding.sdo" scdlResource="META-INF/sca/databinding.sdo.scdl"/>
+ <include name="org.apache.tuscany.idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl"/>
+ <include name="org.apache.tuscany.binding.axis2" scdlResource="META-INF/sca/binding.axis2.scdl"/>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/pom.xml
new file mode 100644
index 0000000000..11f1c6100a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworldwsclient</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany HelloWorld Web Service Client Sample</name>
+ <description>A sample client for a HelloWorld Web Service.</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.0.1</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>${scaVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-axiom</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldClient</mainClass>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/readme.html
new file mode 100644
index 0000000000..1545270c5a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/readme.html
@@ -0,0 +1,105 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Web services Helloworld Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Web services Client Helloworld Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Web services client Helloworld sample shows how to call a remote Web service by wiring an SCA component to a reference which uses a Web service binding.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\helloworldwsclient directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-helloworldwsclient.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <p>The Tuscany Web servivces binding requires the Axis2 and SDO databinding extensions so copy these to the standalone launcher extensions directory:</p>
+ <pre>
+<code>copy target\distribution\contrib\axis2-1.0-incubator-M2.jar target\distribution\extensions<br></code>
+<code>copy target\distribution\contrib\databinding-sdo-1.0-incubator-M2.jar target\distribution\extensions<br></code>
+</pre>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-helloworldwsclient.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>Hello World
+</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..9951f89959
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldClient.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the HelloWorld service and invoke it.
+ */
+public class HelloWorldClient {
+
+ public final static void main(String[] args) throws Exception {
+ CompositeContext compositeContext = CurrentCompositeContext.getContext();
+ HelloWorldService helloWorldService= compositeContext.locateService(HelloWorldService.class, "HelloWorldServiceComponent");
+ String value = helloWorldService.getGreetings("World");
+ System.out.println(value);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..e5894e1ef1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+@Remotable
+@Service
+public interface HelloWorldService {
+ public String getGreetings(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldServiceComponent.java
new file mode 100644
index 0000000000..e04f200499
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/java/helloworld/HelloWorldServiceComponent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the HelloWorld service and invoke it.
+ */
+@Scope("MODULE")
+public class HelloWorldServiceComponent implements HelloWorldService {
+
+ HelloWorldService helloWorldService;
+
+ public String getGreetings(String name) {
+ return helloWorldService.getGreetings(name);
+ }
+
+ public HelloWorldService getHelloWorldService() {
+ return helloWorldService;
+ }
+
+ public void setHelloWorldService(HelloWorldService helloWorldService) {
+ this.helloWorldService = helloWorldService;
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..8e2c4b920d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="helloworldwsclient">
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" location="wsdl/helloworld.wsdl"/>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldServiceComponent"/>
+ <reference name="helloWorldService">HelloWorldService</reference>
+ </component>
+
+ <reference name="HelloWorldService">
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ interface="http://helloworld#wsdl.interface(HelloWorld)"
+ wsdli:wsdlLocation="http://helloworld wsdl/helloworld.wsdl" />
+ <binding.ws endpoint="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)"
+ location="wsdl/helloworld.wsdl" />
+ </reference>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/wsdl/helloworld.wsdl
new file mode 100644
index 0000000000..92a42f231b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/main/resources/wsdl/helloworld.wsdl
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getGreetings1">
+ <complexType>
+ <sequence>
+ <element name="name" type="tns:NameType">
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+
+ <complexType name="NameType">
+ <sequence>
+ <element name="firstName" type="string"/>
+ <element name="lastName" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="getGreetings1Response">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Request">
+
+ <wsdl:part element="tns:getGreetings1" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Response">
+ <wsdl:part element="tns:getGreetings1Response" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdl:input message="tns:getGreetings1Request" name="getGreetings1Request"/>
+ <wsdl:output message="tns:getGreetings1Response" name="getGreetings1Response"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetings1Request">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetings1Response">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/sample-helloworldws/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/test/java/helloworld/HelloWorldWSClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/test/java/helloworld/HelloWorldWSClient.java
new file mode 100644
index 0000000000..63e5f9e854
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/helloworldwsclient/src/test/java/helloworld/HelloWorldWSClient.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package helloworld;
+
+import java.net.URL;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * Test case for helloworld web service client
+ */
+public class HelloWorldWSClient extends SCATestCase {
+
+ private HelloWorldService helloWorldService;
+
+ @Override
+ protected void setUp() throws Exception {
+ setApplicationSCDL(HelloWorldService.class, "META-INF/sca/default.scdl");
+ URL base = getClass().getResource("/META-INF/sca/binding.axis2.scdl");
+ addExtension("binding.ws", new URL(base, "default.scdl"));
+ base = getClass().getResource("/META-INF/sca/databinding.sdo.scdl");
+ addExtension("databindning.sdo", new URL(base, "default.scdl"));
+ super.setUp();
+ CompositeContext compositeContext = CurrentCompositeContext.getContext();
+ helloWorldService = compositeContext.locateService(HelloWorldService.class, "HelloWorldServiceComponent");
+ }
+
+ public void testWSClient() throws Exception {
+ String msg = helloWorldService.getGreetings("Smith");
+ Assert.assertEquals("Hello Smith", msg);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/pom.xml
new file mode 100644
index 0000000000..c3514e2269
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-innercomposite</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Inner Composite Sample</name>
+ <description>A sample implementation showing local wiring of an inner composite.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>innercomposite.InnerCompositeClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/readme.html
new file mode 100644
index 0000000000..1b8ece4396
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/readme.html
@@ -0,0 +1,112 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Inner Composite Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Inner Composite Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Inner Composite sample illustrates an asynchronous
+ callback scenario across atomic components contained in separate
+ composites. The containing (inner) composites are themselves contained in
+ a single composite and an explicit wire connects them. Thus, the
+ corresponding composite reference and service do not specify a
+ binding (not even binding.sca), and the connection and invocation
+ occur in the same process.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\inner.composite directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-innercomposite.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-innercomposite.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>Main thread Thread[main,5,main]
+<br>Source: Client.main -> Source.clientMethod
+<br>Source: Client.main => Source.clientMethod
+<br>Target: Client.main => Source.clientMethod
+<br>Work thread Thread[pool-1-thread-2,5,main]
+<br>Result: Client.main => Source.clientMethod -> Target.someMethod
+<br>Target: Client.main -> Source.clientMethod
+<br>Work thread Thread[pool-1-thread-3,5,main]
+<br>Result: Client.main -> Source.clientMethod -> Target.someMethod</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/InnerCompositeClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/InnerCompositeClient.java
new file mode 100644
index 0000000000..0a2fb3f74e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/InnerCompositeClient.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * Simple client program that invokes the components that we wired together.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InnerCompositeClient {
+
+ public static void main(String[] args) throws Exception {
+ CompositeContext context = CurrentCompositeContext.getContext();
+
+ Source source = context.locateService(Source.class, "SourceComponent");
+ System.out.println("Main thread " + Thread.currentThread());
+ source.clientMethod("Client.main");
+ Thread.sleep(500);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Source.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Source.java
new file mode 100644
index 0000000000..ceceb79360
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Source.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+public interface Source {
+
+ void clientMethod(String arg);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceCallback.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceCallback.java
new file mode 100644
index 0000000000..0807d455a6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceCallback.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+public interface SourceCallback {
+
+ void receiveResult(String result);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceImpl.java
new file mode 100644
index 0000000000..90d231ab14
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/SourceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(Source.class)
+@Scope("MODULE")
+public class SourceImpl implements Source, SourceCallback {
+
+ private Target targetReference;
+ private Target targetReference2;
+
+ @Reference
+ public void setTargetReference(Target target) {
+ this.targetReference = target;
+ }
+
+ @Reference
+ public void setTargetReference2(Target target) {
+ this.targetReference2 = target;
+ }
+
+ public void clientMethod(String arg) {
+ System.out.println("Source: " + arg + " -> Source.clientMethod");
+ targetReference.someMethod(arg + " -> Source.clientMethod");
+
+ System.out.println("Source: " + arg + " => Source.clientMethod");
+ targetReference2.someMethod(arg + " => Source.clientMethod");
+ }
+
+ public void receiveResult(String result) {
+ System.out.println("Work thread " + Thread.currentThread());
+ System.out.println("Result: " + result);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Target.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Target.java
new file mode 100644
index 0000000000..4f67262ae4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/Target.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+import org.osoa.sca.annotations.Callback;
+
+@Callback(SourceCallback.class)
+public interface Target {
+
+ void someMethod(String arg);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/TargetImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/TargetImpl.java
new file mode 100644
index 0000000000..a416086dae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/java/innercomposite/TargetImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(Target.class)
+@Scope("MODULE")
+public class TargetImpl implements Target {
+
+ private SourceCallback sourceCallback;
+
+ @Callback
+ public void setSourceCallback(SourceCallback sourceCallback) {
+ this.sourceCallback = sourceCallback;
+ }
+
+ public void someMethod(String arg) {
+ System.out.println("Target: " + arg);
+ sourceCallback.receiveResult(arg + " -> Target.someMethod");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite.scdl
new file mode 100644
index 0000000000..f7d7b55e10
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="InnerComposite">
+
+ <service name="InnerSourceService" target="InnerSourceComponent">
+ <interface.java interface="innercomposite.Source"/>
+ <reference name="innerSource">InnerSourceComponent</reference>
+ </service>
+
+ <component name="InnerSourceComponent">
+ <implementation.java class="innercomposite.SourceImpl"/>
+ <reference name="targetReference">TargetComponentRef</reference>
+ <reference name="targetReference2">TargetComponentRef2</reference>
+ </component>
+
+ <reference name="TargetComponentRef">
+ <interface.java interface="innercomposite.Target"
+ callbackInterface="innercomposite.SourceCallback"/>
+ </reference>
+
+ <reference name="TargetComponentRef2">
+ <interface.java interface="innercomposite.Target"
+ callbackInterface="innercomposite.SourceCallback"/>
+ </reference>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite2.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite2.scdl
new file mode 100644
index 0000000000..a5ad0abd46
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/InnerComposite2.scdl
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="InnerComposite2">
+
+ <service name="InnerTargetService" target="InnerTargetComponent">
+ <interface.java interface="innercomposite.Target"
+ callbackInterface="innercomposite.SourceCallback"/>
+ <reference name="innerSource">InnerTargetComponent</reference>
+ </service>
+
+ <component name="InnerTargetComponent">
+ <implementation.java class="innercomposite.TargetImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..cd525d8175
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="OuterComposite">
+
+ <component name="SourceComponent">
+ <implementation.composite name="InnerComposite" scdlLocation="InnerComposite.scdl"/>
+ <reference name="TargetComponentRef">TargetComponent</reference>
+ <reference name="TargetComponentRef2">TargetComponent2</reference>
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="innercomposite.TargetImpl"/>
+ </component>
+
+ <component name="TargetComponent2">
+ <implementation.composite name="InnerComposite2" scdlLocation="InnerComposite2.scdl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/test/java/innercomposite/InnerCompositeTestCase.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/test/java/innercomposite/InnerCompositeTestCase.java
new file mode 100644
index 0000000000..5c5b5bdd9d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/inner.composite/src/test/java/innercomposite/InnerCompositeTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package innercomposite;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class InnerCompositeTestCase extends SCATestCase {
+
+ private Source source;
+
+ protected void setUp() throws Exception {
+ setApplicationSCDL(Source.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ source = context.locateService(Source.class, "SourceComponent");
+ }
+
+ public void test() throws Exception {
+ try {
+ System.out.println("Main thread " + Thread.currentThread());
+ source.clientMethod("Client.main");
+ System.out.println("Sleeping ...");
+ Thread.sleep(1000);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/pom.xml
new file mode 100644
index 0000000000..72dd8f2863
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-simplecallback</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Simple Callback Sample</name>
+ <description>A sample implementation of a simple callback application.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>simplecallback.SimpleCallbackClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/readme.html
new file mode 100644
index 0000000000..f70eb732c1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/readme.html
@@ -0,0 +1,106 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Simple Callback Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Simple Callback Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Simple Callback sample illustrates a simple asynchronous
+ callback scenario, similar to the one illustrated in the Client
+ and Implementation Model for Java SCA specification. Two atomic
+ components are wired together that implement a bi-directional
+ interface. The component definitions are given implicitly by
+ the Java code and the use of <code>@Callback</code> annotations.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\simplecallback directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-simplecallback.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-simplecallback.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>Main thread Thread[main,5,main]
+<br>Work thread Thread[pool-1-thread-1,5,main]
+<br>Result: -> someMethod -> receiveResult
+</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClient.java
new file mode 100644
index 0000000000..4cc00d6d0f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClient.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+/**
+ * The client interface
+ */
+public interface MyClient {
+
+ void aClientMethod();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClientImpl.java
new file mode 100644
index 0000000000..016ee8d3df
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyClientImpl.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Demonstrates a component-to-component callback invocation
+ */
+@Service(MyClient.class)
+@Scope("MODULE")
+public class MyClientImpl implements MyClient, MyServiceCallback {
+
+ private MyService myService;
+
+ @Reference
+ public void setMyService(MyService myService) {
+ this.myService = myService;
+ }
+
+ public void aClientMethod() {
+ myService.someMethod("-> someMethod");
+ }
+
+ public void receiveResult(String result) {
+ System.out.println("Work thread " + Thread.currentThread());
+ System.out.println("Result: " + result);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyService.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyService.java
new file mode 100644
index 0000000000..3b12a95b70
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyService.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+import org.osoa.sca.annotations.Callback;
+
+/**
+ * This service that will be invoked in a non-blocking fashion
+ */
+@Callback(MyServiceCallback.class)
+public interface MyService {
+
+ void someMethod(String arg);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceCallback.java
new file mode 100644
index 0000000000..b27eea44f5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceCallback.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+/**
+ * The callback interface for {@link MyService}.
+ */
+public interface MyServiceCallback {
+
+ void receiveResult(String result);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceImpl.java
new file mode 100644
index 0000000000..a903c36180
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/MyServiceImpl.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements MyService and uses a callback.
+ */
+@Service(MyService.class)
+@Scope("MODULE")
+public class MyServiceImpl implements MyService {
+
+ private MyServiceCallback myServiceCallback;
+
+ /**
+ * The setter used by the runtime to set the callback reference
+ * @param myServiceCallback
+ */
+ @Callback
+ public void setMyServiceCallback(MyServiceCallback myServiceCallback) {
+ this.myServiceCallback = myServiceCallback;
+ }
+
+ public void someMethod(String arg) {
+ // invoke the callback
+ myServiceCallback.receiveResult(arg + " -> receiveResult");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/SimpleCallbackClient.java
new file mode 100644
index 0000000000..4e421730e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/java/simplecallback/SimpleCallbackClient.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * Demonstrates resolving the client service and initiating the callback sequence
+ */
+public class SimpleCallbackClient {
+
+ public static void main(String[] args) throws Exception {
+ // Locate the MyClient component and invoke it
+ CompositeContext context = CurrentCompositeContext.getContext();
+ MyClient myClient = context.locateService(MyClient.class, "MyClientComponent");
+ System.out.println("Main thread " + Thread.currentThread());
+ myClient.aClientMethod();
+ Thread.sleep(500);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..1d4016ef44
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="simplecallback">
+
+ <component name="MyClientComponent">
+ <implementation.java class="simplecallback.MyClientImpl"/>
+ <reference name="myService">MyServiceComponent</reference>
+ </component>
+
+ <component name="MyServiceComponent">
+ <implementation.java class="simplecallback.MyServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/test/java/simplecallback/SimpleCallbackTestCase.java
new file mode 100644
index 0000000000..6ce600ad79
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/simplecallback/src/test/java/simplecallback/SimpleCallbackTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package simplecallback;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import org.apache.tuscany.test.SCATestCase;
+
+/**
+ * A testcase that demonstrates resolving the client service and initiating the callback sequence
+ */
+public class SimpleCallbackTestCase extends SCATestCase {
+
+ private MyClient myClient;
+
+ protected void setUp() throws Exception {
+ setApplicationSCDL(MyClient.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ myClient = context.locateService(MyClient.class, "MyClientComponent");
+ }
+
+ public void test() throws Exception {
+ System.out.println("Main thread " + Thread.currentThread());
+ myClient.aClientMethod();
+ System.out.println("Sleeping ...");
+ Thread.sleep(1000);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/pom.xml
new file mode 100644
index 0000000000..ebd605b3d8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-supplychain</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Supply Chain Sample</name>
+ <description>A sample implementation of an asynchronous supply chain application.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>supplychain.SupplyChainClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/readme.html
new file mode 100644
index 0000000000..b2af9f3c75
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/readme.html
@@ -0,0 +1,107 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Supply Chain Sample</title>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <h3>Tuscany Supply Chain Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Supply Chain sample illustrates a one-way
+ invocation example in the context of a simple supply chain
+ scenario. The scenario consists of the following components:<br>
+ Customer, Retailer, Warehouse and Shipper. Request/response
+ invocations flow down the chain from the Customer to the
+ Shipper, and a one-way (asynchronous) invocation flows back
+ from the Shipper to the Customer.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located &nbsp;in the
+ samples\standalone\supplychain directory. All the
+ following commands should be issued while working in the sample
+ directory.</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample&nbsp; issue :</p>
+ <pre>
+<code>mvn<br></code>
+</pre>
+
+ <p>The result after executing is in the <span style=
+ "font-weight: bold;">target</span> subdirectory the <span style=
+ "font-weight: bold;">sample-supplychain.jar</span></p>
+
+ <h4>Setup</h4>
+
+ <p>Set up the Tuscany standalone runtime environment using the
+ following command:</p>
+ <pre>
+<code>mvn dependency:unpack <br></code>
+</pre>
+
+ <p>After completion there should be a <span style=
+ "font-weight: bold;">target\distribution</span> subdirectory
+ created that has the Tuscany standalone runtime.</p>
+
+ <h4>Running</h4>
+
+ <p>Execute the following command: (<span style=
+ "font-style: italic;">cut and paste to command line</span>)</p>
+ <pre>
+<code>java -jar target/distribution/bin/launcher.jar target/sample-supplychain.jar</code>
+</pre>
+
+ <h4>Results</h4>
+
+ <p>The sample when run should simply display to the standard
+ output:<br>
+<samp>
+<br>Main thread Thread[main,5,main]
+<br>Main thread sleeping ...
+<br>Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shipped
+</samp>
+</p>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Customer.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Customer.java
new file mode 100644
index 0000000000..8088001898
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Customer.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.annotations.OneWay;
+
+/**
+ * This is the business interface of the Customer service component.
+ */
+public interface Customer {
+
+ public void purchaseGoods();
+
+ @OneWay
+ public void notifyShipment(String order);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/CustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/CustomerComponentImpl.java
new file mode 100644
index 0000000000..b718af89ed
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/CustomerComponentImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the Customer service component.
+ */
+@Service(Customer.class)
+@Scope("MODULE")
+public class CustomerComponentImpl implements Customer {
+
+ private Retailer retailer;
+
+ @Reference
+ public void setRetailer(Retailer retailer) {
+ this.retailer = retailer;
+ }
+
+ public void purchaseGoods() {
+ retailer.submitOrder("Order");
+ }
+
+ public void notifyShipment(String order) {
+ System.out.print("Work thread " + Thread.currentThread() + " - ");
+ System.out.println(order);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Retailer.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Retailer.java
new file mode 100644
index 0000000000..1add63fb4e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Retailer.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+/**
+ * This is the business interface of the Retailer service component.
+ */
+public interface Retailer {
+
+ public void submitOrder(String order);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/RetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/RetailerComponentImpl.java
new file mode 100644
index 0000000000..0cb30c4199
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/RetailerComponentImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the Customer service component.
+ */
+@Service(Retailer.class)
+@Scope("MODULE")
+public class RetailerComponentImpl implements Retailer {
+
+ private Warehouse warehouse;
+
+ @Reference
+ public void setWarehouse(Warehouse warehouse) {
+ this.warehouse = warehouse;
+ }
+
+ public void submitOrder(String order) {
+ warehouse.fulfillOrder(order + ", submitted");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Shipper.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Shipper.java
new file mode 100644
index 0000000000..d4d49a922b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Shipper.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+/**
+ * This is the business interface of the Shipper service component.
+ */
+public interface Shipper {
+
+ public void processShipment(String order);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/ShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/ShipperComponentImpl.java
new file mode 100644
index 0000000000..b36f0352c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/ShipperComponentImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the Warehouse service component.
+ */
+@Service(Shipper.class)
+@Scope("MODULE")
+public class ShipperComponentImpl implements Shipper {
+
+ private Customer customer;
+
+ @Reference
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+
+ public void processShipment(String order) {
+ customer.notifyShipment(order + ", shipped");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/SupplyChainClient.java
new file mode 100644
index 0000000000..990381e2f5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/SupplyChainClient.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate a Customer service component and invoke it.
+ */
+public class SupplyChainClient {
+
+ public static final void main(String[] args) throws Exception {
+
+ // Locate the Customer component and invoke it
+ CompositeContext context = CurrentCompositeContext.getContext();
+ Customer customer =
+ context.locateService(Customer.class, "CustomerComponent");
+
+ System.out.println("Main thread " + Thread.currentThread());
+ customer.purchaseGoods();
+ System.out.println("Main thread sleeping ...");
+ Thread.sleep(1000);
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Warehouse.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Warehouse.java
new file mode 100644
index 0000000000..0be499f569
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/Warehouse.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+/**
+ * This is the business interface of the Warehouse service component.
+ */
+public interface Warehouse {
+
+ public void fulfillOrder(String order);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java
new file mode 100644
index 0000000000..e994f4bc0d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the Warehouse service component.
+ */
+@Service(Warehouse.class)
+@Scope("MODULE")
+public class WarehouseComponentImpl implements Warehouse {
+
+ private Shipper shipper;
+
+ @Reference
+ public void setShipper(Shipper shipper) {
+ this.shipper = shipper;
+ }
+
+ public void fulfillOrder(String order) {
+ shipper.processShipment(order + ", fulfilled");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..0633be84a5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="supplychain">
+
+ <component name="CustomerComponent">
+ <implementation.java class="supplychain.CustomerComponentImpl" />
+ <reference name="retailer">RetailerComponent</reference>
+ </component>
+
+ <component name="RetailerComponent">
+ <implementation.java class="supplychain.RetailerComponentImpl" />
+ <reference name="warehouse">WarehouseComponent</reference>
+ </component>
+
+ <component name="WarehouseComponent">
+ <implementation.java class="supplychain.WarehouseComponentImpl" />
+ <reference name="shipper">ShipperComponent</reference>
+ </component>
+
+ <component name="ShipperComponent">
+ <implementation.java class="supplychain.ShipperComponentImpl" />
+ <reference name="customer">CustomerComponent</reference>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java
new file mode 100644
index 0000000000..85c6c5eece
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/standalone/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package supplychain;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import org.apache.tuscany.test.SCATestCase;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate a simple HelloWorld service component and
+ * invoke it.
+ */
+public class SupplyChainClientTestCase extends SCATestCase {
+
+ private Customer customer;
+
+ protected void setUp() throws Exception {
+ setApplicationSCDL(SupplyChainClient.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ customer = context.locateService(Customer.class, "CustomerComponent");
+ }
+
+ public void test() throws Exception {
+
+ System.out.println("Main thread " + Thread.currentThread());
+ customer.purchaseGoods();
+ System.out.println("Sleeping ...");
+ Thread.sleep(1000);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/pom.xml
new file mode 100644
index 0000000000..bd5998a29e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/pom.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-calculatorws</artifactId>
+ <packaging>war</packaging>
+ <name>Tuscany Calculator Web Service Sample</name>
+ <description>A sample Calculator Web Service.</description>
+
+ <properties>
+ <ws.type>axis2</ws.type>
+ </properties>
+
+ <dependencies>
+
+ <!-- SCA API dependencies -->
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>${scaVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Tuscany API dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- SDO API dependencies -->
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.0.1</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- SDO's XXXHelper.INSTANCE pattern requires the implementation -->
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- SDO's XMLStreamHelper requires StAX API and impl (it's not pulled by
+ tuscany-sdo-impl because the maven dependency scope is provided -->
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- runtime is need for webapp integration to include jar -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Unit testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>sample-calculatorws</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Set to true to embed external jars for extensions in the WAR -->
+ <!-- Set to false to leave external jars for extensions to be resolved from maven repository -->
+ <loadExtensionDependencies>false</loadExtensionDependencies>
+ <extensions>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ </extensions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/readme.html
new file mode 100644
index 0000000000..5ddd8c58b7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/readme.html
@@ -0,0 +1,153 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><title>Tuscany
+Calculator Web Service Sample</title><!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
+<style type="text/css" media="all">
+@import url("../../../../css/maven-base.css");
+@import url("../../../../css/maven-theme.css");
+@import url("../../../../css/site.css");
+</style><link rel="stylesheet" href="./css/print.css" type="text/css" media="print"><!-- end maven --></head>
+<body>
+<H3>Tuscany Calculator-Combo - A Simple SCA Assembly that hosts calculator functions as WebServices</H3>
+<H3>Overview</H3>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD width="100%" valign="top" align="left"> This sample is an assembly of Calculator functions implemented in Java and exposed as Web Services. The primary objective of developing this sample is to support the Calculator-Combo sample.<BR>
+ <BR>
+ To test this sample you might have to either run the Calculator-Combo sample after running this sample or you might right your won SCA Application that refereences the services of this sample</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H3>Location</H3>
+<P>The source for this sample is located &nbsp;in the paths - <I>samples\webapp\calculatorws</I>
+ of the source
+distribution.<BR>
+<BR>
+If there is binary distribution available for these samples, then you may find these samples packaged as <I>sample-calculatorws.war.</I><BR></P>
+<H3>Building &amp; Running the CalculatorWS Sample Source</H3>
+<P>If you are working with a source distribution, then you must first
+build the source of this sample. <BR>
+- Ensure that you have Java 5 installed on your system.<BR>
+- Next, you must have Maven 2.0.4 installed on your system. Look up
+http://maven.apache.org/download.html for downloading and installing
+Maven.<BR>
+ - Install the Apache Tomcat Server (latest release). Look up http://tomcat.apache.org/ for more information on releases and downloads.<BR></P>
+<H4>Building the CalculatorWS Sample</H4>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top"></TD>
+ <TD valign="top">Having installed Maven, open a command line console
+ and switch over to the directory on your local system, where you have
+ extracted the source.<BR>
+ - Now switch futher into the subdirectory <I>samples\webapp\calculatorws.
+ </I>Within this directory execute the following command
+ <TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD><FONT color="purple">&gt;</FONT></TD>
+ <TD><FONT color="purple" face="Courier New">mvn</FONT></TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ This will build the <I>calculatorws</I> sample, package a WAR file for the composite and make it available in the sub-directory <I>samples\webapp\calculatorws\target</I></TD>
+ <TD></TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<H4>Running the CalculatorWS Sample </H4>
+<P>Now that the sample source has been built and Tomcat setup, you may run the Calculator WebService sample as follows: -
+</P>
+<TABLE border="0">
+ <TBODY>
+ <TR>
+ <TD valign="top">i)</TD>
+ <TD>Copy the <I>sample-calculatorws.war</I> located in the <I>samples\webapp\calculatorws\target</I> into the WebApps directory of the Tomcat Installation.
+ </TD>
+ </TR>
+ <TR>
+ <TD valign="top">ii)</TD>
+ <TD>Ensure that the Calculator Web Application is up and running.</TD>
+ </TR>
+ </TBODY>
+</TABLE><H4><BR>
+Trying the CalculatorWS Sample</H4>
+<P>To test this sample completely, run the Calculator-Combo sample after running this sample. For details on setting up and running the Calculator-Combo sample look at the readme.html
+under that sample.<BR>
+<BR>
+</P>
+<H2>Code Overview</H2>
+<P>The source files are physically organized as shown below:<BR>
+</P>
+<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td>
+<pre>
+<B><U></U></B><B><U>Calculator WebService</U></B>
++---main<BR> +---java<BR> | +---calculator
+<I> &lt;Interfaces and Implementations for Calculator Functions&gt;
+
+</I>
+ +---resources
+ +---wsdl
+ calculator.wsdl
+ +---webapp
+ +---WEB-INF
+ default.scdl
+ web.xml</pre></td></tr></tbody></table>
+<P><B>Calculator WebService Sample (WebApp Deployment)</B></P><TABLE border="1">
+ <TBODY>
+ <TR>
+ <TD width="230" valign="top">default.scdl</TD>
+ <TD width="396" valign="top">Defines an assembly of calculator
+ funtions implemented in Java and exposed as a WebService using the Axis2 binding.</TD>
+ </TR>
+ <TR>
+ <TD width="230">AddService.java<BR>
+ AddServiceImpl.java<BR>
+ DivideService.java<BR>
+ DivideServiceImpl.java<BR>
+ MathService.java<BR>
+ MathServiceImpl.java<BR>
+ MultiplyService.java<BR>
+ MultiplyServiceImpl.java<BR>
+ SubtractService.java<BR>
+ SubtractServiceImpl.java</TD>
+ <TD width="396">Java Interfaces and Java Implementations for various calculator
+ functions.</TD>
+ </TR>
+ <TR>
+ <TD width="230">CalculatorService.java<BR>
+ CalculatorServiceImpl.java</TD>
+ <TD width="396">Defines the coarse grained Calculator Interface and
+ Implementation. This calculator implementation delegates function
+ requests to other granular implemenations listed above.</TD>
+ </TR>
+ <TR>
+ <TD width="230">calculator.wsdl</TD>
+ <TD width="396">Defines the Calculator service using WSDL to enable the CalculatorServiceImpl to be exposed as a Axis2 WebService</TD>
+ </TR>
+ <TR>
+ <TD width="230">web.xml</TD>
+ <TD width="396">The Web App. descriptor for the Web App. deployment of the Tuscany Runtime.</TD>
+ </TR>
+ </TBODY>
+</TABLE>
+<P></P></body></html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..6392676e76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..39e9be92e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/AddServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Add service
+ */
+@Scope("MODULE")
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..f1185a2494
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+@Service
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+ double sqrt (double n);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d72c0d30c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Scope("MODULE")
+public class CalculatorServiceImpl implements CalculatorService {
+
+ @Reference
+ protected AddService addService;
+
+ @Reference
+ protected SubtractService subtractService;
+
+ @Reference
+ protected MultiplyService multiplyService;
+
+ @Reference
+ protected DivideService divideService;
+
+ @Reference
+ protected MathService mathService;
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+ public double sqrt(double n) {
+ // TODO Auto-generated method stub
+ return mathService.sqrt(n);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..3158458b5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..159ca463c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/DivideServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Scope("MODULE")
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathService.java
new file mode 100644
index 0000000000..42e8e5ca67
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+
+
+public interface MathService {
+
+ double sqrt(double n);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathServiceImpl.java
new file mode 100644
index 0000000000..76caace7bb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MathServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ */
+@Scope("MODULE")
+public class MathServiceImpl implements MathService {
+
+ public double sqrt(double n1) {
+ return java.lang.Math.sqrt(n1);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..62db05175e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7276bb6964
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Multiply service.
+ */
+@Scope("MODULE")
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..309f88f098
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..3c3388f4cd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/java/calculator/SubtractServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the subtract service.
+ */
+@Scope("MODULE")
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/wsdl/calculator.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/wsdl/calculator.wsdl
new file mode 100644
index 0000000000..46928e7055
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/resources/wsdl/calculator.wsdl
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="http://calculator/xsd" xmlns:axis2ns1="http://calculator" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calculator">
+ <wsdl:types>
+ <xs:schema xmlns:ns="http://calculator/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://calculator/xsd">
+ <xs:element name="add">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="addResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="divide">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="divideResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="multiply">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="multiplyResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="subtract">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ <xs:element name="param1" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="subtractResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sqrt">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="param0" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sqrtResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:double" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="addMessage">
+ <wsdl:part name="part1" element="ns1:add" />
+ </wsdl:message>
+ <wsdl:message name="addResponseMessage">
+ <wsdl:part name="part1" element="ns1:addResponse" />
+ </wsdl:message>
+ <wsdl:message name="divideMessage">
+ <wsdl:part name="part1" element="ns1:divide" />
+ </wsdl:message>
+ <wsdl:message name="divideResponseMessage">
+ <wsdl:part name="part1" element="ns1:divideResponse" />
+ </wsdl:message>
+ <wsdl:message name="multiplyMessage">
+ <wsdl:part name="part1" element="ns1:multiply" />
+ </wsdl:message>
+ <wsdl:message name="multiplyResponseMessage">
+ <wsdl:part name="part1" element="ns1:multiplyResponse" />
+ </wsdl:message>
+ <wsdl:message name="subtractMessage">
+ <wsdl:part name="part1" element="ns1:subtract" />
+ </wsdl:message>
+ <wsdl:message name="subtractResponseMessage">
+ <wsdl:part name="part1" element="ns1:subtractResponse" />
+ </wsdl:message>
+ <wsdl:message name="sqrtMessage">
+ <wsdl:part name="part1" element="ns1:sqrt" />
+ </wsdl:message>
+ <wsdl:message name="sqrtResponseMessage">
+ <wsdl:part name="part1" element="ns1:sqrtResponse" />
+ </wsdl:message>
+ <wsdl:portType name="Calculator">
+ <wsdl:operation name="add">
+ <wsdl:input message="axis2ns1:addMessage" />
+ <wsdl:output message="axis2ns1:addResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="divide">
+ <wsdl:input message="axis2ns1:divideMessage" />
+ <wsdl:output message="axis2ns1:divideResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="multiply">
+ <wsdl:input message="axis2ns1:multiplyMessage" />
+ <wsdl:output message="axis2ns1:multiplyResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="subtract">
+ <wsdl:input message="axis2ns1:subtractMessage" />
+ <wsdl:output message="axis2ns1:subtractResponseMessage" />
+ </wsdl:operation>
+ <wsdl:operation name="sqrt">
+ <wsdl:input message="axis2ns1:sqrtMessage" />
+ <wsdl:output message="axis2ns1:sqrtResponseMessage" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSOAP11Binding" type="axis2ns1:Calculator">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <wsdl:operation name="add">
+ <soap:operation soapAction="urn:add" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="divide">
+ <soap:operation soapAction="urn:divide" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="multiply">
+ <soap:operation soapAction="urn:multiply" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="subtract">
+ <soap:operation soapAction="urn:subtract" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sqrt">
+ <soap:operation soapAction="urn:sqrt" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="CalculatorServiceSOAP12Binding" type="axis2ns1:Calculator">
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <wsdl:operation name="add">
+ <soap12:operation soapAction="urn:add" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="divide">
+ <soap12:operation soapAction="urn:divide" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="multiply">
+ <soap12:operation soapAction="urn:multiply" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="subtract">
+ <soap12:operation soapAction="urn:subtract" style="document" />
+ <wsdl:input>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sqrt">
+ <soap:operation soapAction="urn:sqrt" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" namespace="http://calculator" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port name="CalculatorServiceSOAP11port" binding="axis2ns1:CalculatorServiceSOAP11Binding">
+ <soap:address location="http://localhost:8080/sample-calculatorws/services/CalculatorWebService" />
+ </wsdl:port>
+ <wsdl:port name="CalculatorServiceSOAP12port" binding="axis2ns1:CalculatorServiceSOAP12Binding">
+ <soap12:address location="http://localhost:8080/sample-calculatorws/services/CalculatorWebService" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..f54aa81dd4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="calculatorws">
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" location="wsdl/calculator.wsdl" />
+
+ <service name="CalculatorWebService">
+ <interface.wsdl interface="http://calculator#wsdl.interface(Calculator)" wsdli:wsdlLocation="http://calculator wsdl/calculator.wsdl" />
+ <binding.ws endpoint="http://calculator#wsdl.endpoint(CalculatorService/CalculatorServiceSOAP11port)" location="wsdl/calculator.wsdl" />
+ <reference>CalculatorServiceComponent</reference>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService">AddServiceComponent</reference>
+ <reference name="subtractService">SubtractServiceComponent</reference>
+ <reference name="multiplyService">MultiplyServiceComponent</reference>
+ <reference name="divideService">DivideServiceComponent</reference>
+ <reference name="mathService">MathServiceComponent</reference>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+ <component name="MathServiceComponent">
+ <implementation.java class="calculator.MathServiceImpl"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..eab2430d04
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/calculatorws/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <display-name>Tuscany Calculator Web Service Sample</display-name>
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <display-name>Tuscany Servlet</display-name>
+ <servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/NOTICE.txt
new file mode 100644
index 0000000000..e445fc9ae5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/pom.xml
new file mode 100644
index 0000000000..4ed2d8f6eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-greeterws-oneway</artifactId>
+ <packaging>war</packaging>
+ <name>Tuscany Greeter Web Service Sample</name>
+ <description>A sample Greeter OneWay Web Service.</description>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope> <!-- runtime is need for webapp integration to include jar -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>runtime</scope> <!-- runtime is need for webapp integration to include jar -->
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>sample-greeterws-oneway-1.0-incubator-M2</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Set to true to embed external jars for extensions in the WAR -->
+ <!-- Set to false to leave external jars for extensions to be resolved from maven repository -->
+ <loadExtensionDependencies>false</loadExtensionDependencies>
+
+ <extensions>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ </extensions>
+ </configuration>
+
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>${notice.dir}</directory>
+ <targetPath>META-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>LICENSE.txt</include>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/readme.html
new file mode 100644
index 0000000000..c0ee8490de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/readme.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Greeter Oneway Web servce Sample</title>
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+
+ <h3>Tuscany Greeter One-Way Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Tuscany Greeter One-Way sample application&nbsp;
+ shows the use of the Tuscany SCA runtime in a web service application.
+ The service implements a one-way (asynchronous) interface
+ that is supported by the web services binding (binding.ws) that
+ it specifies. The component definition is given implicitly by
+ the Java code and the use of the <code>@OneWay</code> annotation.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located&nbsp;in the&nbsp; <a href=
+ ".">samples\webapp\greeterws-oneway</a> directory. &nbsp;All
+ the following commands should be issued while working in the
+ sample directory.&nbsp;</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+
+ <li><a href="http://tomcat.apache.org/download-55.cgi" target=
+ "_blank">Apache Tomcat 5.xx</a> latest version binary core
+ distribution.&nbsp;</li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample issue :</p>
+ <pre>
+<code>mvn</code>
+</pre>
+
+ <p>This should result in the creation of the war file
+ <span style="font-weight: bold;">target\sample-greeterws-oneway-1.0-incubator-M2.war</span></p>
+
+ <h4>Setup</h4>
+
+ <p>If you have enabled remote deployment in Tomcat by adding the
+ line:</p>
+
+ <p><code>&lt;user username="admin" password=""
+ roles="manager"/&gt;</code></p>
+
+ <p>into <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\conf\tomcat-users.xml you can deploy the WARs to
+ Tomcat using the tomcat-maven-plugin:</p>
+
+ <p><code>mvn tomcat:deploy</code></p>
+
+ <p>Alternatively you can copy the WAR files to Tomcat's webapps
+ directory. Copy <span style=
+ "font-weight: bold;">target\sample-greeterws-oneway-1.0-incubator-M2.war</span>
+ <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>/webapps/.</p>
+
+ <h4>Running</h4>
+
+ <p>Start the tomcat server by issuing the following command ind
+ the <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\bin directory:</p>
+
+ <p><code>starup</code></p>
+
+ <p>Once you've started your web server, following the directions
+ in <a href=
+ "../../standalone/greeterwsclient-oneway/readme.html" target=
+ "_blank">client side demo</a> to execute the service.</p><br>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterImpl.java
new file mode 100644
index 0000000000..16cd96dbe3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package greeter;
+
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(GreeterService.class)
+@Scope("MODULE")
+public class GreeterImpl implements GreeterService {
+
+ public void greet(String name) {
+ System.out.println("Hello " + name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterService.java
new file mode 100644
index 0000000000..fef29e17e5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/java/greeter/GreeterService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package greeter;
+
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+@Remotable
+@Service
+public interface GreeterService {
+
+ @OneWay
+ public void greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/resources/wsdl/greeter.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/resources/wsdl/greeter.wsdl
new file mode 100644
index 0000000000..1ee877fbef
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/resources/wsdl/greeter.wsdl
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://greeter" xmlns:tns="http://greeter" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="greeter">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://greeter" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="greet">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="greetRequest">
+ <wsdl:part element="tns:greet" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="greet">
+ <wsdl:input message="tns:greetRequest" name="greetRequest" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="GreeterSoapBinding" type="tns:Greeter">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="greet">
+ <wsdlsoap:operation soapAction="greet" />
+ <wsdl:input name="greetRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="GreeterService">
+ <wsdl:port binding="tns:GreeterSoapBinding" name="GreeterSoapPort">
+ <wsdlsoap:address
+ location="http://localhost:8080/sample-greeterws-oneway-1.0-incubator-M2-SNAPSHOT/services/GreeterWebService" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..b1dbb078c6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="greeterws">
+
+ <service name="GreeterWebService" target="http:///foo">
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ interface="http://greeter#wsdl.interface(Greeter)"
+ wsdli:wsdlLocation="http://greeter wsdl/greeter.wsdl" />
+
+ <!--FIXME the location attribute is a really bad hack here! does not follow to spec at all
+ -->
+ <binding.ws endpoint="http://greeter#wsdl.endpoint(GreeterService/GreeterSoapPort)"
+ conformanceURIs="http://ws-i.org/profiles/basic/1.1" location="wsdl/greeter.wsdl" />
+
+ <reference>GreeterServiceComponent</reference>
+ </service>
+
+ <component name="GreeterServiceComponent">
+ <implementation.java class="greeter.GreeterImpl" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..0498cb266c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/greeterws-oneway/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <display-name>Tuscany Greeter Web Service Sample</display-name>
+
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <display-name>Tuscany Servlet</display-name>
+ <servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/pom.xml
new file mode 100644
index 0000000000..1648201f0a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworldws-async</artifactId>
+ <packaging>war</packaging>
+ <name>Tuscany HelloWorld Web Service Async Sample</name>
+ <description>A sample HelloWorld Async Web Service.</description>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope> <!-- runtime is need for webapp integration to include jar -->
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>runtime</scope> <!-- runtime is need for webapp integration to include jar -->
+ </dependency>
+
+ <!-- java.xml.stream API -->
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- StAX implementation -->
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>sample-helloworldws-async-1.0-incubator-M2-SNAPSHOT</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Set to true to embed external jars for extensions in the WAR -->
+ <!-- Set to false to leave external jars for extensions to be resolved from maven repository -->
+ <loadExtensionDependencies>false</loadExtensionDependencies>
+
+ <extensions>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ </extensions>
+ </configuration>
+
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>${notice.dir}</directory>
+ <targetPath>META-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>LICENSE.txt</include>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/readme.html
new file mode 100644
index 0000000000..33dd6d6123
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/readme.html
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Hello World Async Sample</title>
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <!-- maven --><!-- end maven -->
+
+ <h3>Tuscany Hello World Async Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Tuscany Hello World Aysnc sample application&nbsp;
+ shows the use of the Tuscany SCA runtime in a web service application.
+ The service implements a bi-directional (asynchronous) interface
+ that is supported by the web services binding (binding.ws) that
+ it specifies. The component definition is given implicitly by
+ the Java code and the use of the <code>@Callback</code> annotation.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located&nbsp;in the&nbsp; <a href=
+ ".">samples\webapp\helloworldws-async</a> directory. &nbsp;All
+ the following commands should be issued while working in the
+ sample directory.&nbsp;</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+
+ <li><a href="http://tomcat.apache.org/download-55.cgi" target=
+ "_blank">Apache Tomcat 5.xx</a> latest version binary core
+ distribution.&nbsp;</li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample issue :</p>
+ <pre>
+<code>mvn</code>
+</pre>
+
+ <p>This should result in the creation of the war file
+ <span style="font-weight: bold;">target\sample-helloworldws-async-1.0-incubator-M2.war</span></p>
+
+ <h4>Setup</h4>
+
+ <p>If you have enabled remote deployment in Tomcat by adding the
+ line:</p>
+
+ <p><code>&lt;user username="admin" password=""
+ roles="manager"/&gt;</code></p>
+
+ <p>into <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\conf\tomcat-users.xml you can deploy the WARs to
+ Tomcat using the tomcat-maven-plugin:</p>
+
+ <p><code>mvn tomcat:deploy</code></p>
+
+ <p>Alternatively you can copy the WAR files to Tomcat's webapps
+ directory. Copy <span style=
+ "font-weight: bold;">target\sample-helloworldws-async-1.0-incubator-M2.war</span>
+ <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>/webapps/.</p>
+
+ <h4>Running</h4>
+
+ <p>Start the tomcat server by issuing the following command ind
+ the <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\bin directory:</p>
+
+ <p><code>starup</code></p>
+
+ <p>Once you've started your web server, following the directions
+ in <a href=
+ "../../standalone/helloworldwsclient-async/readme.html" target=
+ "_blank">client side demo</a> to execute the service.</p><br>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldCallback.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldCallback.java
new file mode 100644
index 0000000000..adc48e85a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldCallback.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface HelloWorldCallback {
+
+ public void getGreetingsCallback(String getGreetingsReturn);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..3fadda95de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+@Scope("MODULE")
+public class HelloWorldImpl implements HelloWorldService {
+
+ private HelloWorldCallback helloWorldCallback;
+
+ @Callback
+ public void setHelloWorldCallback(HelloWorldCallback helloWorldCallback) {
+ this.helloWorldCallback = helloWorldCallback;
+ }
+
+ public String getGreetings(String name) {
+ try {
+ helloWorldCallback.getGreetingsCallback("Hola " + name);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return "This should not be seen";
+ }
+
+ public String getGreetings1(DataObject name) {
+ String firstName = name.getString("firstName");
+ String lastName = name.getString("lastName");
+ return "Hi " + firstName + " " + lastName;
+ }
+
+ public void getGreetingsWithCallback(String name) {
+ try {
+ helloWorldCallback.getGreetingsCallback("Alo " + name);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..3db3b0cae4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+@Service
+@Callback(HelloWorldCallback.class)
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+ @DataType(name="commonj.sdo.DataObject")
+ public String getGreetings1(DataObject name);
+
+ public void getGreetingsWithCallback(String name);
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/wsdl/helloworld.wsdl
new file mode 100644
index 0000000000..b753706977
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/resources/wsdl/helloworld.wsdl
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsCallback">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetings1">
+ <complexType>
+ <sequence>
+ <element name="name" type="tns:NameType">
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+
+ <complexType name="NameType">
+ <sequence>
+ <element name="firstName" type="string"/>
+ <element name="lastName" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="getGreetings1Response">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsWithCallback">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsWithCallbackResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsCallback">
+ <wsdl:part element="tns:getGreetingsCallback" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Request">
+ <wsdl:part element="tns:getGreetings1" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Response">
+ <wsdl:part element="tns:getGreetings1Response" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsWithCallbackRequest">
+ <wsdl:part element="tns:getGreetingsWithCallback" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsWithCallbackResponse">
+ <wsdl:part element="tns:getGreetingsWithCallbackResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdl:input message="tns:getGreetings1Request" name="getGreetings1Request"/>
+ <wsdl:output message="tns:getGreetings1Response" name="getGreetings1Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsWithCallback">
+ <wsdl:input message="tns:getGreetingsWithCallbackRequest" name="getGreetingsWithCallbackRequest"/>
+ <wsdl:output message="tns:getGreetingsWithCallbackResponse" name="getGreetingsWithCallbackResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:portType name="HelloWorldCallback">
+ <wsdl:operation name="getGreetingsCallback">
+ <wsdl:input message="tns:getGreetingsCallback" name="getGreetingsCallback"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetings1Request">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetings1Response">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetingsWithCallback">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsWithCallbackRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsWithCallbackResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/sample-helloworldws-async-1.0-incubator-M2-SNAPSHOT/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..8d619ea894
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/sca/default.scdl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="helloworldws">
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0" location="wsdl/helloworld.wsdl" />
+
+ <service name="HelloWorldWebService" target="http:///foo">
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ interface="http://helloworld#wsdl.interface(HelloWorld)"
+ callbackInterface="http://helloworld#wsdl.interface(HelloWorldCallback)"
+ wsdli:wsdlLocation="http://helloworld wsdl/helloworld.wsdl" />
+
+ <!--
+ <interface.java interface="helloworld.HelloWorldService"
+ callbackInterface="helloworld.HelloWorldCallback"/>
+ -->
+
+ <!--FIXME the location attribute is a really bad hack here! does not follow to spec at all
+ -->
+ <binding.ws endpoint="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)"
+ conformanceURIs="http://ws-i.org/profiles/basic/1.1" location="wsdl/helloworld.wsdl" />
+
+ <reference>HelloWorldServiceComponent</reference>
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/binding.axis2.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/binding.axis2.scdl
new file mode 100644
index 0000000000..852f36e10d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/binding.axis2.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Axis2 based WebService binding extension -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/1.0-SNAPSHOT"
+ name="org.apache.tuscany.binding.axis2">
+
+ <!-- [rfeng] Commented it out for now. When this SCDL is loaded, the DependencyLoader component
+ has not been initiated yet. We may need to play with initLevel setting -->
+ <!--
+ <tuscany:dependency>
+ <group>axis2</group>
+ <artifact>axis2-core</artifact>
+ <version>SNAPSHOT</version>
+ </tuscany:dependency>
+ -->
+
+ <component name="webservice.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader"/>
+ </component>
+
+ <component name="webservice.axis2.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl
new file mode 100644
index 0000000000..49e8926aab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="org.apache.tuscany.databinding.Axiom">
+
+ <component name="databinding.axiom">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.AxiomDataBinding" />
+ </component>
+
+ <!-- Transformers -->
+ <component name="transformer.XMLStreamReader2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.String2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.String2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2String" />
+ </component>
+
+ <component name="transformer.Object2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.Object2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2Object">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2Object" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl
new file mode 100644
index 0000000000..8c1c36d466
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ import.sdo configuration
+
+ $Rev: 431086 $ $Date: 2006-08-12 13:58:17 -0700 (Sat, 12 Aug 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="org.apache.tuscany.databinding.sdo">
+
+ <!-- import.sdo element loader implementations -->
+ <component name="elementLoader.import.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
+ </component>
+
+ <component name="databinding.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.SDODataBinding" />
+ </component>
+
+ <component name="transformer.DataObject2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2String"/>
+ </component>
+ <component name="transformer.DataObject2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLDocument2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2String"/>
+ </component>
+ <component name="transformer.String2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.String2DataObject"/>
+ </component>
+ <component name="transformer.XMLDocument2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLStreamReader2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2DataObject"/>
+ </component>
+ <component name="transformer.XMLStreamReader2XMLDocument">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl
new file mode 100644
index 0000000000..9a15675f9f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev: 440894 $ $Date: 2006-09-06 15:52:01 -0700 (Wed, 06 Sep 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="org.apache.tuscany.idl.WSDL">
+
+ <component name="interface.wsdl.Loader">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLLoader" />
+ </component>
+
+ <component name="wsdl.Registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl" initLevel="40" />
+ </component>
+
+ <component name="xmlSchema.registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl" initLevel="35" />
+ </component>
+
+ <component name="interface.wsdl.Introspector">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospectorImpl" initLevel="40" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/webapp.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/webapp.scdl
new file mode 100644
index 0000000000..3111557013
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/META-INF/tuscany/webapp.scdl
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev: 449867 $ $Date: 2006-09-25 17:01:40 -0700 (Mon, 25 Sep 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="org.apache.tuscany.runtime.webapp.System">
+
+ <!-- Component that provides the Deployer service -->
+ <component name="deployer">
+ <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+ </component>
+
+ <!-- Work management -->
+ <component name="workContext">
+ <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+ </component>
+
+ <!-- Wire service -->
+ <component name="wireService">
+ <system:implementation.system class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+ </component>
+
+ <!-- Scope infrastructure -->
+ <component name="scopeRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+ </component>
+
+ <!-- Builder and BuilderRegistry -->
+ <component name="builder">
+ <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+ </component>
+
+ <!-- Loader and LoaderRegistry -->
+ <component name="loader">
+ <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+ </component>
+
+ <!-- Introspector and IntrospectionRegistry -->
+ <component name="introspector">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+ </component>
+
+ <!-- Connector infrastructure -->
+ <component name="connector">
+ <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+ </component>
+
+ <component name="wirePostProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+ </component>
+
+ <!-- Default scopes -->
+ <component name="scope.module">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
+ </component>
+ <component name="scope.stateless">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
+ </component>
+
+ <!-- include loader configuration -->
+ <include name="org.apache.tuscany.launcher.Loader" scdlResource="org/apache/tuscany/core/loader.scdl"/>
+
+ <!-- include implementation processor configuration -->
+ <include name="org.apache.tuscany.launcher.Implementation" scdlResource="org/apache/tuscany/core/implementation.scdl"/>
+
+ <!-- Java interface definition language -->
+ <include name="org.apache.tuscany.launcher.InterfaceJava" scdlResource="org/apache/tuscany/core/interfaceJava.scdl"/>
+
+ <!-- include omposite implementation type -->
+ <include name="org.apache.tuscany.launcher.Composite" scdlResource="org/apache/tuscany/core/composite.scdl"/>
+
+ <!-- System implementation type -->
+ <include name="org.apache.tuscany.launcher.SystemImplementation" scdlResource="org/apache/tuscany/core/systemImplementation.scdl"/>
+
+ <!-- Java implementation type -->
+ <include name="org.apache.tuscany.launcher.JavaImplementation" scdlResource="org/apache/tuscany/core/javaImplementation.scdl"/>
+
+ <!-- Data Binding -->
+ <include name="org.apache.tuscany.launcher.DataBinding" scdlResource="org/apache/tuscany/core/databinding.scdl"/>
+
+ <!-- WorkScheduler service -->
+ <component name="workManager">
+ <system:implementation.system
+ class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+ <property name="poolSize">10</property>
+ </component>
+
+ <component name="workScheduler">
+ <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
+ </component>
+
+ <!-- Web app ServletHost -->
+ <component name="servletHost">
+ <system:implementation.system class="org.apache.tuscany.runtime.webapp.ServletHostImpl"/>
+ </component>
+
+ <component name="policyBuilderRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+ </component>
+
+ <component name="propertyFactory">
+ <system:implementation.system class="org.apache.tuscany.core.property.PropertyObjectFactoryImpl"/>
+ </component>
+
+ <component name="artifactRepository">
+ <system:implementation.system class="org.apache.tuscany.core.services.artifact.LocalMavenRepository"/>
+ <!-- this value needs to change to a correct one -->
+ <property name = "repository">.</property>
+ </component>
+
+ <include name="databinding.sdo" scdlLocation="databinding.sdo.scdl"/>
+ <include name="databinding.axiom" scdlLocation="databinding.axiom.scdl"/>
+ <include name="binding.axis2" scdlLocation="binding.axis2.scdl"/>
+ <include name="interface.wsdl" scdlLocation="interface.wsdl.scdl"/>
+
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..3539ece4d1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="helloworldws">
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" location="wsdl/helloworld.wsdl" />
+
+ <service name="HelloWorldWebService" target="http:///foo">
+ <interface.wsdl xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ interface="http://helloworld#wsdl.interface(HelloWorld)"
+ callbackInterface="http://helloworld#wsdl.interface(HelloWorldCallback)"
+ wsdli:wsdlLocation="http://helloworld wsdl/helloworld.wsdl" />
+
+ <!--
+ <interface.java interface="helloworld.HelloWorldService"
+ callbackInterface="helloworld.HelloWorldCallback"/>
+ -->
+
+ <!--FIXME the location attribute is a really bad hack here! does not follow to spec at all
+ -->
+ <binding.ws endpoint="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)"
+ conformanceURIs="http://ws-i.org/profiles/basic/1.1" location="wsdl/helloworld.wsdl" />
+
+ <reference>HelloWorldServiceComponent</reference>
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..fc1ec3353b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws-async/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <display-name>Tuscany HelloWorld Web Service Sample</display-name>
+
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <display-name>Tuscany Servlet</display-name>
+ <servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/pom.xml
new file mode 100644
index 0000000000..84a293f22d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/pom.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-helloworldws</artifactId>
+ <packaging>war</packaging>
+ <name>Tuscany HelloWorld Web Service Sample</name>
+ <description>A sample HelloWorld Web Service.</description>
+
+ <dependencies>
+
+ <!-- SCA API dependencies -->
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>${scaVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Tuscany API dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- SDO API dependencies -->
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.0.1</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- SDO's XXXHelper.INSTANCE pattern requires the implementation -->
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>${sdoVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- SDO's XMLStreamHelper requires StAX API and impl (it's not pulled by
+ tuscany-sdo-impl because the maven dependency scope is provided -->
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- runtime is need for webapp integration to include jar -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Unit testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <finalName>sample-helloworldws</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- Set to true to embed external jars for extensions in the WAR -->
+ <!-- Set to false to leave external jars for extensions to be resolved from maven repository -->
+ <loadExtensionDependencies>false</loadExtensionDependencies>
+ <extensions>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ </extensions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/readme.html
new file mode 100644
index 0000000000..ef32023531
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/readme.html
@@ -0,0 +1,108 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Web Service Hello World Sample</title>
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <!-- maven --><!-- end maven -->
+
+ <h3>Tuscany Web Service Helloworld Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>The Tuscany Web services Helloworld sample shows how to expose an SCA component as a Web service endpoint by wiring the component to an SCA service which uses a Web service binding.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located&nbsp;in the&nbsp; <a href=
+ ".">samples\webapp\helloworldws</a> directory. &nbsp;All
+ the following commands should be issued while working in the
+ sample directory.&nbsp;</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+
+ <li><a href="http://tomcat.apache.org/download-55.cgi" target=
+ "_blank">Apache Tomcat 5.xx</a> latest version binary core
+ distribution.&nbsp;</li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample issue :</p>
+ <pre>
+<code>mvn</code>
+</pre>
+
+ <p>This should result in the creation of the war file
+ <span style="font-weight: bold;">target\sample-helloworldws.war</span></p>
+
+ <h4>Setup</h4>
+
+ <p>If you have enabled remote deployment in Tomcat by adding the
+ line:</p>
+
+ <p><code>&lt;user username="admin" password=""
+ roles="manager"/&gt;</code></p>
+
+ <p>into <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\conf\tomcat-users.xml you can deploy the WARs to
+ Tomcat using the tomcat-maven-plugin:</p>
+
+ <p><code>mvn tomcat:deploy</code></p>
+
+ <p>Alternatively you can copy the WAR files to Tomcat's webapps
+ directory. Copy <span style=
+ "font-weight: bold;">target\sample-helloworldws.war</span>
+ <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>/webapps/.</p>
+
+ <h4>Running</h4>
+
+ <p>Start the tomcat server by issuing the following command ind
+ the <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\bin directory:</p>
+
+ <p><code>startup</code></p>
+
+ <p>Once you've started your web server, following the directions
+ in <a href=
+ "../../standalone/helloworldwsclient/readme.html" target=
+ "_blank">client side demo</a> to execute the service.</p><br>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..b1de782f3a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+
+/**
+ * This class implements the HelloWorld Service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+ public String getGreetings1(DataObject name) {
+ String firstName = name.getString("firstName");
+ String lastName = name.getString("lastName");
+ return "Hello " + firstName + " " + lastName;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..89ef9423d1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+
+/**
+ * This is the business interface of the HelloWorld Greetings Service.
+ */
+@Remotable
+@Service
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+ @DataType(name="commonj.sdo.DataObject")
+ public String getGreetings1(DataObject name);
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..517cda22ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..11c564eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/wsdl/helloworld.wsdl
new file mode 100644
index 0000000000..df5aafd567
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/resources/wsdl/helloworld.wsdl
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetings1">
+ <complexType>
+ <sequence>
+ <element name="name" type="tns:NameType">
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+
+ <complexType name="NameType">
+ <sequence>
+ <element name="firstName" type="string"/>
+ <element name="lastName" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="getGreetings1Response">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Request">
+ <wsdl:part element="tns:getGreetings1" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetings1Response">
+ <wsdl:part element="tns:getGreetings1Response" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdl:input message="tns:getGreetings1Request" name="getGreetings1Request"/>
+ <wsdl:output message="tns:getGreetings1Response" name="getGreetings1Response"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getGreetings1">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetings1Request">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetings1Response">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/sample-helloworldws/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..dd3a99141d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ name="helloworldws">
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" location="wsdl/helloworld.wsdl" />
+
+ <service name="HelloWorldWebService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" wsdli:wsdlLocation="http://helloworld wsdl/helloworld.wsdl" />
+ <binding.ws endpoint="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)" location="wsdl/helloworld.wsdl" />
+ <reference>HelloWorldServiceComponent</reference>
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..1e8736d865
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/helloworldws/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <display-name>Tuscany HelloWorld Web Service Sample</display-name>
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <display-name>Tuscany Servlet</display-name>
+ <servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/LICENSE.txt
new file mode 100644
index 0000000000..bdec70a4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/LICENSE.txt
@@ -0,0 +1,416 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+===================================================================================================
+
+Common Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
+
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/NOTICE.txt
new file mode 100644
index 0000000000..4dbc3a8099
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/NOTICE.txt
@@ -0,0 +1,32 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+The terms and conditions governing the distribution may refer to the AL or other license
+agreements, notices or terms and conditions. Some of these other license agreements may
+include (but are not limited to):
+
+ . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html)
+ . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+
+It is your obligation to read and accept all such terms and conditions prior to use of the
+distribution. If term or condition is provided, please contact the Apache Software Foundation
+to determine what terms and conditions govern that particular distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/pom.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/pom.xml
new file mode 100644
index 0000000000..5539955b63
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany Simple WebApp Sample</name>
+ <description>A sample WebApplication showing how to include a Tuscany runtime.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>sample-calculator</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${scaImplVersion}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <version>${scaImplVersion}</version>
+ <executions>
+ <execution>
+ <id>tuscany-war</id>
+ <goals>
+ <goal>tuscany-war</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/readme.html b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/readme.html
new file mode 100644
index 0000000000..1f7cde1bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/readme.html
@@ -0,0 +1,118 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content=
+ "text/html; charset=us-ascii">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+
+ <title>Tuscany Webapp Sample</title>
+ <link rel="stylesheet" href="../../css/base.css" type="text/css">
+</head>
+
+<body>
+ <!-- LINK rel="stylesheet" href="ait.css" type="text/css" -->
+ <!-- maven --><!-- end maven -->
+
+ <h3>Tuscany Webapp Sample</h3>
+
+ <h4>Overview</h4>
+
+ <p>This sample illustrates how to use Apache Tuscany to run a SCA composite inside a
+web application. It describes how to run it on Apache Tomcat but the application
+should be portable to other containers such as Jetty or commmercial servers.</p>
+
+ <h4>Location</h4>
+
+ <p>This sample is located&nbsp;in the&nbsp; <a href=
+ ".">samples\webapp\webapp</a> directory. &nbsp;All
+ the following commands should be issued while working in the
+ sample directory.&nbsp;</p>
+
+ <h4>Prerequisites</h4>
+
+ <p>Obtain the following prerequisites and install according to
+ their documentation.</p>
+
+ <ul>
+ <li><a href="http://java.sun.com/javase/downloads/index.jsp"
+ target="_blank">JDK 5.0</a></li>
+
+ <li><a href="http://maven.apache.org/download.html" target=
+ "_blank">Maven 2.0.4</a></li>
+
+ <li><a href="http://tomcat.apache.org/download-55.cgi" target=
+ "_blank">Apache Tomcat 5.xx</a> latest version binary core
+ distribution.&nbsp;</li>
+
+ <li>This sample reuses the composite from the &nbsp;<a href= "../../standalone/calculator/readme.html" target="_blank">calculator sample</a>&nbsp;
+ so that sample must have beed built before building this sample.</li>
+ </ul>
+
+ <h4>Building</h4>
+
+ <p>To build the sample issue :</p>
+ <pre>
+<code>mvn</code>
+</pre>
+
+ <p>This should result in the creation of the war file
+ <span style="font-weight: bold;">target\sample-webapp.war</span></p>
+
+ <h4>Setup</h4>
+
+ <p>If you have enabled remote deployment in Tomcat by adding the
+ line:</p>
+
+ <p><code>&lt;user username="admin" password=""
+ roles="manager"/&gt;</code></p>
+
+ <p>into <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\conf\tomcat-users.xml you can deploy the WARs to
+ Tomcat using the tomcat-maven-plugin:</p>
+
+ <p><code>mvn tomcat:deploy</code></p>
+
+ <p>Alternatively you can copy the WAR files to Tomcat's webapps
+ directory. Copy <span style=
+ "font-weight: bold;">target\sample-webapp.war</span>
+ <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>/webapps/.</p>
+
+ <h4>Running</h4>
+
+ <p>Start the tomcat server by issuing the following command ind
+ the <span style="font-style: italic;">&lt;tomcat
+ dir&gt;</span>\bin directory:</p>
+
+ <p><code>startup</code></p>
+
+ <p>Once you've started your web server, open a browser and go to sample-webapp page at
+&nbsp;<a href=
+ "http://localhost:8080/sample-webapp/" target=
+ "_blank">http://localhost:8080/sample-webapp/</a>&nbsp; and you should see a web page displaying:</p>
+<samp>
+<br><B>Expression Result</B>
+<br>2 + 3 5.0
+<br>3 - 2 1.0
+</samp>
+</body>
+</html>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/default.scdl
new file mode 100644
index 0000000000..81a4503be3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/default.scdl
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="CalculatorComposite">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.composite name="CalculatorComposite" jarLocation="lib/sample-calculator-1.0-incubator-M2-SNAPSHOT.jar"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..ac8231faac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
+
+ <display-name>Apache Tuscany Simple Webapp Sample</display-name>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>calc.jsp</welcome-file>
+ </welcome-file-list>
+
+ <filter>
+ <filter-name>TuscanyFilter</filter-name>
+ <filter-class>org.apache.tuscany.runtime.webapp.TuscanyFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>TuscanyFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <listener>
+ <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+ </listener>
+</web-app>
diff --git a/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/calc.jsp b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/calc.jsp
new file mode 100644
index 0000000000..7122eca852
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/samples/webapp/webapp/src/main/webapp/calc.jsp
@@ -0,0 +1,43 @@
+<%@ page import="calculator.CalculatorService" %>
+<%@ page import="org.osoa.sca.CompositeContext" %>
+<%@ page import="org.osoa.sca.CurrentCompositeContext" %>
+<%--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+ CompositeContext context = CurrentCompositeContext.getContext();
+ CalculatorService calc = context.locateService(CalculatorService.class, "CalculatorServiceComponent");
+%>
+<html>
+<head><title>Calculator sample</title></head>
+
+<body>
+<table>
+ <tr>
+ <th>Expression</th><th>Result</th>
+ </tr>
+ <tr>
+ <td>2 + 3</td><td><%= calc.add(2, 3) %></td>
+ </tr>
+ <tr>
+ <td>3 - 2</td><td><%= calc.subtract(3, 2) %></td>
+ </tr>
+</table>
+</body>
+</html> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/BUILDING.txt b/sca-java-1.x/branches/sca-java-M2/sca/BUILDING.txt
new file mode 100644
index 0000000000..67b6b1d5f5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/BUILDING.txt
@@ -0,0 +1,29 @@
+Building Tuscany SCA
+====================
+
+Building this distribution requires a Maven 2.0.4 which can be downloaded from
+ http://maven.apache.org/download.html
+
+Maven automatically downloads project dependencies from remote repositories
+so a live internet connection is required the first time a build is run.
+For details of which repositories are used please consult pom.xml in this
+directory or in specific modules. Commonly used repositories are:
+ http://people.apache.org/repo/m2-incubating-repository/
+ http://download.eclipse.org/tools/emf/maven2
+ https://maven-repository.dev.java.net/nonav/repository
+
+Due to load on these servers you may experience occasional download failures.
+If these should occur simply rerun the build.
+
+The build generates a binary distribution intended for download from a
+distribution server and a number of other artifacts intended for distribution
+through the Maven repository system. Those include Maven plugins that can be
+used to build SCA applications intended to run on Apache Tuscany.
+
+
+Building
+--------
+To perform a default build run mvn from this directory. This build installs
+all module files in your local Maven repository (located by default in
+${user.home}/.m2/repository ) ready for deployment to a remote repository.
+It also assembles a binary distribution in the distribution module.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/LICENSE.txt
new file mode 100644
index 0000000000..9ee90786ef
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/LICENSE.txt
@@ -0,0 +1,323 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================================================
+
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+=================================================================================================================
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/NOTICE.txt
new file mode 100644
index 0000000000..5b5354fd50
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/NOTICE.txt
@@ -0,0 +1,18 @@
+Apache Tuscany SCA for Java
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be fully endorsed
+by the ASF.
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE.txt file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/STATUS.txt b/sca-java-1.x/branches/sca-java-M2/sca/STATUS.txt
new file mode 100644
index 0000000000..7514d9eb05
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/STATUS.txt
@@ -0,0 +1,78 @@
+Apache Tuscany Status
+
+Tuscany provides multiple language implementations of the Service Component Architecture (SCA) specifications and related technologies such as SDO.
+
+PROJECT STATUS
+==============
+
+ Tuscany is being incubated at the request of the Apache Web Services PMC.
+ For information on incubation please visit the project page at
+ http://incubator.apache.org/projects/tuscany.html
+
+
+Pending Issues
+==============
+none
+
+RESOLVED ISSUES SINCE LAST STATUS
+=================================
+2005-12-28 CCLA received for IBM's contribution of a C++ implementation
+2005-12-28 CCLA received for BEA and IBM joint contribution of a Java implementation
+
+OTHER NEWS
+==========
+
+2006-11-07 Vote to add Rajith Attapattu
+2006-11-03 C++ Milestone 2 release
+2006-10-19 Voted to release pom and buildtools for Java M2 release
+2006-09-29 Vote to add Ignacio Silva-Lepe as a new committer
+2006-09-18 Vote to add Venkata Krishnan as a new committer
+2006-08-10 Vote to add Andrew Borley as a new committer
+2006-08-07 Vote to add Meeraj Kunnumpurath as a new committer
+2006-08-07 Vote to add Kelvin Goodson as a new committer
+2006-08-06 Vote to add Brent Daniel as a new committer
+2006-08-04 Vote to add Raymond Feng as a new committer
+2006-08-01 C++ Milestone 1 release
+2006-06-07 Java Milestone 1 release
+2006-05-02 Vote to add Dan Kulp as a new committer
+
+2006-01-05 Contribution of Java implementation by BEA and IBM committed
+2006-01-05 Contribution of C+ implementation by IBM committed
+
+RELEASE STATUS
+==============
+None
+
+REFERENCES
+==========
+Status file http://svn.apache.org/repos/asf/incubator/tuscany/STATUS
+User List tuscany-user@ws.apache.org
+Developer List tuscany-dev@ws.apache.org
+Commits List tuscany-commits@ws.apache.org
+Source Code http://svn.apache.org/repos/asf/incubator/tuscany/
+Issue Tracking http://issues.apache.org/jira/browse/TUSCANY
+
+Committers
+ ajborley Andrew Borley
+ antelder Ant Elder
+ bdaniel Brent Daniel
+ dkulp Dan Kulp
+ dims Davanum Srinivas
+ edslattery Ed Slattery
+ ekoneil Eddie O'Neil
+ frankb Frank Budinsky
+ geirm Geir Magnusson Jr
+ isilval Ignacio Silva-Lepe
+ jsdelfino Jean-Sebastien Delfino
+ jboynes Jeremy Boynes
+ jmarino Jim Marino
+ kelvingoodson Kelvin Goodson
+ kentam Ken Tam
+ kwilliams Kevin Williams
+ edwardsmj Mike Edwards
+ meerajk Meeraj Kunnumpurath
+ rajith Rajith Attapattu
+ rfeng Raymond Feng
+ robbinspg Pete Robbins
+ rineholt Rick Rineholt
+ svkrish Venkata Krishnan
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/.ruleset
new file mode 100644
index 0000000000..f27a8fe562
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/pom.xml
new file mode 100644
index 0000000000..121e8ce439
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.commands</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>launcher</artifactId>
+ <name>Apache Tuscany SCA Application Launcher</name>
+ <description>Standalone executable jar that can be used to launch a SCA application.</description>
+
+ <!--
+ This library will typically be added to the application's classpath and so should
+ should have as few dependencies as possible and nothing from the Tuscany runtime.
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>standalone</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency> <!-- TUSCANY-871 -->
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.tuscany.launcher.MainLauncherBooter</mainClass>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>../lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/InvalidMainException.java b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/InvalidMainException.java
new file mode 100644
index 0000000000..0c11d95c2b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/InvalidMainException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.launcher;
+
+/**
+ * Exception indicating that application's main method is missing or invalid
+ * (for example it may not be static).
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidMainException extends LaunchException {
+ public InvalidMainException(String message) {
+ super(message);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/LaunchException.java b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/LaunchException.java
new file mode 100644
index 0000000000..83056574ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/LaunchException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.launcher;
+
+/**
+ * Exception indicating that there was a problem launching an application.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class LaunchException extends Exception {
+ public LaunchException() {
+ }
+
+ public LaunchException(String message) {
+ super(message);
+ }
+
+ public LaunchException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public LaunchException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
new file mode 100644
index 0000000000..e94b15b95c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.launcher;
+
+import java.beans.Beans;
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
+import org.apache.tuscany.host.util.LaunchHelper;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfoImpl;
+
+/**
+ * Launcher for launcher runtime environment that invokes a jar's Main class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MainLauncherBooter {
+ /**
+ * Main method.
+ *
+ * @param args the command line args
+ */
+ public static void main(String[] args) throws Throwable {
+ MainLauncherBooter booter = new MainLauncherBooter();
+
+ File installDir = getInstallDirectory();
+ URL baseUrl = installDir.toURI().toURL();
+ File bootDir = getBootDirectory(installDir);
+
+ boolean online = ! Boolean.parseBoolean(System.getProperty("offline", Boolean.FALSE.toString()));
+ StandaloneRuntimeInfo runtimeInfo = new StandaloneRuntimeInfoImpl(baseUrl, installDir, installDir, online);
+
+ File applicationJar = new File(args[0]);
+ URL applicationURL = applicationJar.toURI().toURL();
+ String[] appArgs = new String[args.length - 1];
+ System.arraycopy(args, 1, appArgs, 0, appArgs.length);
+
+ ClassLoader hostClassLoader = ClassLoader.getSystemClassLoader();
+ ClassLoader bootClassLoader = booter.getTuscanyClassLoader(bootDir);
+ ClassLoader applicationClassLoader = new URLClassLoader(new URL[]{applicationURL}, hostClassLoader);
+
+ URL systemScdl = booter.getSystemScdl(bootClassLoader);
+ URL applicationScdl = booter.getApplicationScdl(applicationClassLoader);
+
+ String className = System.getProperty("tuscany.launcherClass",
+ "org.apache.tuscany.runtime.standalone.host.StandaloneRuntimeImpl");
+ TuscanyRuntime runtime = (TuscanyRuntime) Beans.instantiate(bootClassLoader, className);
+ runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
+ runtime.setSystemScdl(systemScdl);
+ runtime.setHostClassLoader(hostClassLoader);
+ runtime.setApplicationName("application");
+ runtime.setApplicationScdl(applicationScdl);
+ runtime.setApplicationClassLoader(applicationClassLoader);
+ runtime.setRuntimeInfo(runtimeInfo);
+ runtime.initialize();
+ SCA context = runtime.getContext();
+
+ try {
+ context.start();
+ booter.runApplication(applicationJar, applicationClassLoader, appArgs);
+ } finally {
+ context.stop();
+ runtime.destroy();
+ }
+ }
+
+ protected void runApplication(File applicationJar, ClassLoader applicationClassLoader, String[] args)
+ throws Throwable {
+
+ Manifest manifest = new JarFile(applicationJar).getManifest();
+ String mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+ Class<?> mainClass = applicationClassLoader.loadClass(mainClassName);
+ Method main = mainClass.getMethod("main", String[].class);
+
+
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(applicationClassLoader);
+ main.invoke(null, new Object[]{args});
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+ }
+
+ protected ClassLoader getTuscanyClassLoader(File bootDir) {
+ URL[] urls = LaunchHelper.scanDirectoryForJars(bootDir);
+ return new URLClassLoader(urls, getClass().getClassLoader());
+ }
+
+ /**
+ * Find the directory containing the bootstrap jars.
+ * If the <code>tuscany.bootDir</code> system property is set then its value is used as the boot directory.
+ * Otherwise, we locate a jar file containing this class and return a "boot" directory that is a sibling
+ * to the directory that contains it. This class must be loaded from a jar file located on the local filesystem.
+ *
+ * @return the directory of the bootstrap jars
+ */
+ protected File findBootDir() {
+ String property = System.getProperty("tuscany.bootDir");
+ if (property != null) {
+ return new File(property);
+ }
+
+ URL url = MainLauncherBooter.class.getResource("MainLauncherBooter.class");
+ if (!"jar".equals(url.getProtocol())) {
+ throw new IllegalStateException("Must be run from a jar: " + url);
+ }
+ String jarLocation = url.toString();
+ jarLocation = jarLocation.substring(4, jarLocation.lastIndexOf("!/"));
+ if (!jarLocation.startsWith("file:")) {
+ throw new IllegalStateException("Must be run from a local filesystem: " + jarLocation);
+ }
+
+ File jarFile = new File(URI.create(jarLocation));
+ return new File(jarFile.getParentFile().getParentFile(), "boot");
+ }
+
+ protected void usage() {
+ ResourceBundle bundle = ResourceBundle.getBundle(MainLauncherBooter.class.getName());
+ System.err.print(bundle.getString("org.apache.tuscany.launcher.Usage"));
+ System.exit(1);
+ }
+
+ protected URL getSystemScdl(ClassLoader bootClassLoader) {
+ String resource = System.getProperty("tuscany.systemScdlPath", "META-INF/tuscany/system.scdl");
+ return bootClassLoader.getResource(resource);
+ }
+
+ protected URL getApplicationScdl(ClassLoader applicationClassLoader) {
+ String resource = System.getProperty("tuscany.applicationScdlPath", "META-INF/sca/default.scdl");
+ return applicationClassLoader.getResource(resource);
+ }
+
+ public static File getInstallDirectory() {
+ // use system property if defined
+ String property = System.getProperty("tuscany.installDir");
+ if (property != null) {
+ return new File(property);
+ }
+
+ // use the parent of directory containing this command
+ URL url = MainLauncherBooter.class.getResource("MainLauncherBooter.class");
+ if (!"jar".equals(url.getProtocol())) {
+ throw new IllegalStateException("Must be run from a jar: " + url);
+ }
+
+ String jarLocation = url.toString();
+ jarLocation = jarLocation.substring(4, jarLocation.lastIndexOf("!/"));
+ if (!jarLocation.startsWith("file:")) {
+ throw new IllegalStateException("Must be run from a local filesystem: " + jarLocation);
+ }
+
+ File jarFile = new File(URI.create(jarLocation));
+ return jarFile.getParentFile().getParentFile();
+ }
+
+ public static File getBootDirectory(File installDirectory) {
+ // use system property if defined
+ String property = System.getProperty("tuscany.bootDir");
+ if (property != null) {
+ return new File(property);
+ }
+ return new File(installDirectory, "boot");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
new file mode 100644
index 0000000000..358deeb919
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.launcher.System">
+
+ <!-- Component that provides the Deployer service -->
+ <component name="deployer">
+ <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+ </component>
+
+ <!-- Work management -->
+ <component name="workContext">
+ <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+ </component>
+
+ <!-- Wire service -->
+ <component name="wireService">
+ <system:implementation.system class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+ </component>
+
+ <!-- Scope infrastructure -->
+ <component name="scopeRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+ </component>
+
+ <!-- Builder and BuilderRegistry -->
+ <component name="builder">
+ <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+ </component>
+
+ <!-- Loader and LoaderRegistry -->
+ <component name="loader">
+ <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+ </component>
+
+ <!-- Introspector and IntrospectionRegistry -->
+ <component name="interfaceProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+ </component>
+
+ <!-- Connector infrastructure -->
+ <component name="connector">
+ <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+ </component>
+
+ <component name="wirePostProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+ </component>
+
+ <!-- Default scopes -->
+ <component name="scope.module">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
+ </component>
+ <component name="scope.stateless">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
+ </component>
+
+ <!-- include loader configuration -->
+ <include name="org.apache.tuscany.core.Loader" scdlResource="org/apache/tuscany/core/loader.scdl"/>
+
+ <!-- include databinding configuration -->
+ <include name="org.apache.tuscany.core.DataBinding" scdlResource="org/apache/tuscany/core/databinding.scdl"/>
+
+ <!-- include implementation processor configuration -->
+ <include name="org.apache.tuscany.core.Implementation" scdlResource="org/apache/tuscany/core/implementation.scdl"/>
+
+ <!-- Java interface definition language -->
+ <include name="org.apache.tuscany.core.InterfaceJava" scdlResource="org/apache/tuscany/core/interfaceJava.scdl"/>
+
+ <!-- include omposite implementation type -->
+ <include name="org.apache.tuscany.core.Composite" scdlResource="org/apache/tuscany/core/composite.scdl"/>
+
+ <!-- System implementation type -->
+ <include name="org.apache.tuscany.core.SystemImplementation" scdlResource="org/apache/tuscany/core/systemImplementation.scdl"/>
+
+ <!-- Java implementation type -->
+ <include name="org.apache.tuscany.core.JavaImplementation" scdlResource="org/apache/tuscany/core/javaImplementation.scdl"/>
+
+ <!-- service for resolving artifacts using Maven repositories -->
+ <component name="artifactRepository">
+ <system:implementation.system class="org.apache.tuscany.services.maven.MavenArtifactRepository"/>
+ <property name="remoteRepoUrl">http://repo1.maven.org/maven2,http://people.apache.org/repo/m2-incubating-repository,http://repo1.maven.org/maven,http://people.apache.org/repo/m2-snapshot-repository</property>
+ </component>
+
+ <!-- WorkScheduler service -->
+ <component name="workManager">
+ <system:implementation.system
+ class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+ <property name="poolSize">10</property>
+ </component>
+
+ <component name="workScheduler">
+ <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
+ </component>
+
+ <component name="policyBuilderRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+ </component>
+
+ <component name="propertyFactory">
+ <system:implementation.system class="org.apache.tuscany.core.property.PropertyObjectFactoryImpl"/>
+ </component>
+
+ <!-- component that scans the extension directory -->
+ <component name="directoryScanExtender" initLevel="90">
+ <system:implementation.system class="org.apache.tuscany.runtime.standalone.host.DirectoryScanExtender"/>
+ <property name="path">extensions</property>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/org/apache/tuscany/launcher/MainLauncher.properties b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/org/apache/tuscany/launcher/MainLauncher.properties
new file mode 100644
index 0000000000..16e3430ee6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/launcher/src/main/resources/org/apache/tuscany/launcher/MainLauncher.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# $Rev$ $Date$
+#
+# REVIEW: Move to core.launcher
+org.apache.tuscany.launcher.Usage=usage: java [jvm-options] -jar launcher.jar [options] arg...\n\
+ where [options] are:\n\
+ --classpath <path> set the classpath for loading application classes (required)\n\
+ --main <classname> specify the classname to launch (overrides manifest entries on classpath param)\n
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/commands/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/commands/pom.xml
new file mode 100644
index 0000000000..191b6cd4c8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/commands/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.commands</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Commands</name>
+
+ <modules>
+ <module>launcher</module>
+ </modules>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/distribution/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/distribution/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/distribution/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/distribution/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/distribution/NOTICE.txt
new file mode 100644
index 0000000000..3269a1169c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/distribution/NOTICE.txt
@@ -0,0 +1,306 @@
+${project.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+----- NOTICE from LICENSE.txt file for classworlds project --------------------
+
+/*
+ $Id$
+
+ Copyright 2002 (C) The Codehaus. All Rights Reserved.
+
+ Redistribution and use of this software and associated documentation
+ ("Software"), with or without modification, are permitted provided
+ that the following conditions are met:
+
+ 1. Redistributions of source code must retain copyright
+ statements and notices. Redistributions must also contain a
+ copy of this document.
+
+ 2. Redistributions in binary form must reproduce the
+ above copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+ 3. The name "classworlds" must not be used to endorse or promote
+ products derived from this Software without prior written
+ permission of The Codehaus. For written permission, please
+ contact bob@codehaus.org.
+
+ 4. Products derived from this Software may not be called "classworlds"
+ nor may "classworlds" appear in their names without prior written
+ permission of The Codehaus. "classworlds" is a registered
+ trademark of The Codehaus.
+
+ 5. Due credit should be given to The Codehaus.
+ (http://classworlds.codehaus.org/).
+
+ THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ */
+
+-------------------------------------------------------------------------------
+* boot/classworlds-1.1.jar
+-------------------------------------------------------------------------------
+
+
+----- NOTICE from LICENSE.txt file in jsch-0.1.24 distribution ----------------
+
+JSch 0.0.* was released under the GNU LGPL license. Later, we have switched
+over to a BSD-style license.
+
+------------------------------------------------------------------------------
+Copyright (c) 2002,2003,2004,2005 Atsuhiko Yamanaka, JCraft,Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------------------
+* boot/jsch-0.1.24.jar
+-------------------------------------------------------------------------------
+
+
+----- NOTICE from Codehaus for Plexus Project ---------------------------------
+
+ The MIT License
+
+ Copyright (c) 2004, The Codehaus
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do
+ so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+-----
+
+Some portions of Plexus are also distributed under other BSD-style licenses
+including the Apache License Version 2.0
+
+-------------------------------------------------------------------------------
+* boot/plexus-container-default-1.0-alpha-9.jar
+* boot/plexus-interactivity-api-1.0-alpha-4.jar
+* boot/plexus-utils-1.1.jar
+-------------------------------------------------------------------------------
+
+
+----- NOTICE from StAX project at http://svn.codehaus.org/stax/trunk/dev/README-API.txt
+
+These files together comprise the API for JSR 173 (Streaming API for XML Specification), including its API classes and interfaces.
+
+
+The following lists the files in this distribution:
+
+README-API.txt [README file for JSR 173 api bundle.]
+ASF2.0.txt [Apache Software Foundation License 2.0.]
+jsr173_1.0_api.jar [The API classes and interfaces in binary format.]
+jsr173_1.0_src.jar [The API classes and interfaces in source format.]
+
+Your right to use the listed files, whether together or individually, is governed by the Apache Software Foundation License 2.0 included in this bundle.
+
+Please see the javadoc for information on how to get started.
+
+-------------------------------------------------------------------------------
+* boot/stax-api-1.0.1.jar
+-------------------------------------------------------------------------------
+
+
+----- NOTICE from wstx-asl-3.0.1.jar ------------------------------------------
+
+This product currently only contains code developed by authors
+of specific components, as identified by the source code files.
+
+Since product implements StAX API, it has dependencies to StAX API
+classes.
+
+For additional credits (generally to people who reported problems)
+see CREDITS file.
+
+-------------------------------------------------------------------------------
+* boot/wstx-asl-3.0.1.jar
+-------------------------------------------------------------------------------
+
+
+----- NOTICE for sdo-api-r2.0.1-1.0-incubator-M2.jar--------------------------
+
+License for the Service Data Objects JavaDoc and Interface Definition files.
+
+Permission to copy, make derivative works of, and distribute the Service Data Objects
+JavaDoc and Interface Definition Files files in any medium without fee or royalty as part
+of a compliant implementation of the Service Data Objects Specification is hereby granted.
+The Service Data Objects Specification may be found at any of the following locations:
+
+http://dev2dev.bea.com/technologies/commonj/index.jsp
+http://www.ibm.com/developerworks/library/specification/ws-sdo/
+http://oracle.com/technology/webservices/sca
+https://www.sdn.sap.com/
+http://www.xcalia/xdn/specs/sdo
+
+THE SERVICE DATA OBJECTS SPECIFICATION AND THE JAVADOC AND INTERFACE DEFINITION FILES
+ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
+SPECIFICATION OR THE JAVADOC AND INTERFACE DEFINITION FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
+INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
+SERVICE DATA OBJECTS SPECIFICATION OR THE JAVADOC OR INTERFACE DEFINTION FILES.
+
+The name and trademarks of the Authors may NOT be used in any manner, including advertising or
+publicity pertaining to the Service Component Architecture Specification or its contents without specific,
+written prior permission. Title to copyright in the Service Data Objects Specification and the
+JavaDoc and Interface Definition Files will at all times remain with the Authors.
+
+No other rights are granted by implication, estoppel or otherwise.
+
+
+---- NOTICE for EMF jars --------------------------
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+-------------------------------------------------------------------------------
+* lib/common-2.2.1.jar
+* lib/ecore-2.2.1.jar
+* lib/ecore-change-2.2.1.jar
+* lib/ecore-xmi-2.2.1.jar
+* lib/xsd-2.2.1.jar
+-------------------------------------------------------------------------------
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/distribution/build.xml b/sca-java-1.x/branches/sca-java-M2/sca/distribution/build.xml
new file mode 100644
index 0000000000..fe62a12ae6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/distribution/build.xml
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="project" default="install">
+
+ <property name="prefix" value="tuscany-sca-1.0-incubator-M2"/>
+ <property name="url" value="http://svn.apache.org/repos/asf/incubator/tuscany"/>
+
+ <target name="clean">
+ <delete dir="target/javadoc" quiet="true"/>
+ <delete dir="target/source" quiet="true"/>
+ <delete dir="target" quiet="true">
+ <include name="*.zip"/>
+ <include name="*.tar.gz"/>
+ </delete>
+ </target>
+
+ <target name="install" depends="spec.sca, spec.commonj, source, sample, javadoc" />
+
+ <target name="javadoc" depends="spec.sca">
+
+ <delete dir="target/javadoc" quiet="true"/>
+
+ <javadoc packagenames="org.osoa.*" sourcepath="target/source/zip/spec/sca/src/main/java"
+ defaultexcludes="yes"
+ destdir="target/javadoc/spec/sca"
+ author="true"
+ version="true"
+ use="true">
+ <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
+ </javadoc>
+
+ <javadoc packagenames="commonj.*" sourcepath="target/source/zip/spec/commonj/src/main/java"
+ defaultexcludes="yes"
+ destdir="target/javadoc/spec/commonj"
+ author="true"
+ version="true"
+ use="true">
+ <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
+ </javadoc>
+
+ <unzip dest="target/javadoc/api">
+ <fileset dir="../kernel/api">
+ <include name="target/*javadoc.jar"/>
+ </fileset>
+ </unzip>
+ <unzip dest="target/javadoc/host-api">
+ <fileset dir="../kernel/host-api">
+ <include name="target/*javadoc.jar"/>
+ </fileset>
+ </unzip>
+ <unzip dest="target/javadoc/spi">
+ <fileset dir="../kernel/spi">
+ <include name="target/*javadoc.jar"/>
+ </fileset>
+ </unzip>
+
+ <copy todir="target/javadoc">
+ <fileset dir="..">
+ <include name="LICENSE.txt"/>
+ <include name="NOTICE.txt"/>
+ <include name="STATUS.txt"/>
+ </fileset>
+ </copy>
+
+ <zip destfile="target/${prefix}-javadoc.zip">
+ <zipfileset dir="target/javadoc" prefix="javadoc"/>
+ </zip>
+ <tar destfile="target/${prefix}-javadoc.tar" longfile="gnu">
+ <tarfileset dir="target/javadoc" prefix="javadoc"/>
+ </tar>
+ <gzip zipfile="target/${prefix}-javadoc.tar.gz" src="target/${prefix}-javadoc.tar" />
+ <delete file="target/${prefix}-javadoc.tar" />
+ </target>
+
+ <target name="spec.sca">
+ <property name="archive.prefix.sca" value="target/${prefix}-spec-sca-src"/>
+ <property name="target.zip.sca" value="target/source/zip/spec/sca"/>
+ <property name="target.gz.sca" value="target/source/gz/spec/sca"/>
+
+ <delete dir="${target.zip.sca}" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol CRLF ${url}/tags/java/spec/sca/1.0-incubator-M2 ${target.zip.sca}"/>
+ </exec>
+
+ <zip destfile="${archive.prefix.sca}.zip">
+ <zipfileset dir="${target.zip.sca}" prefix="src/spec/sca"/>
+ </zip>
+
+ <delete dir="${target.gz.sca}" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol LF ${url}/tags/java/spec/sca/1.0-incubator-M2 ${target.gz.sca}"/>
+ </exec>
+
+ <tar destfile="${archive.prefix.sca}.tar" longfile="gnu">
+ <tarfileset dir="${target.gz.sca}" prefix="src/spec/sca"/>
+ </tar>
+ <gzip zipfile="${archive.prefix.sca}.tar.gz" src="${archive.prefix.sca}.tar" />
+ <delete file="${archive.prefix.sca}.tar" />
+
+ </target>
+
+ <target name="spec.commonj">
+ <property name="archive.prefix.commonj" value="target/${prefix}-spec-commonj-src"/>
+ <property name="target.zip.commonj" value="target/source/zip/spec/commonj"/>
+ <property name="target.gz.commonj" value="target/source/gz/spec/commonj"/>
+
+ <delete dir="${target.zip.commonj}" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol CRLF ${url}/tags/java/spec/commonj/1.0-incubator-M2 ${target.zip.commonj}"/>
+ </exec>
+
+ <zip destfile="${archive.prefix.commonj}.zip">
+ <zipfileset dir="${target.zip.commonj}" prefix="src/spec/commonj"/>
+ </zip>
+
+ <delete dir="${target.gz.commonj}" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol LF ${url}/tags/java/spec/commonj/1.0-incubator-M2 ${target.gz.commonj}"/>
+ </exec>
+
+ <tar destfile="${archive.prefix.commonj}.tar" longfile="gnu">
+ <tarfileset dir="${target.gz.commonj}" prefix="src/spec/commonj"/>
+ </tar>
+ <gzip zipfile="${archive.prefix.commonj}.tar.gz" src="${archive.prefix.commonj}.tar" />
+ <delete file="${archive.prefix.commonj}.tar" />
+
+ </target>
+
+
+ <target name="source">
+
+ <delete dir="target/source/zip/sca" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol CRLF ${url}/branches/sca-java-M2/sca target/source/zip/sca"/>
+ </exec>
+
+ <zip destfile="target/${prefix}-src.zip">
+ <zipfileset dir="target/source/zip/sca" prefix="src/sca"/>
+ </zip>
+
+ <delete dir="target/source/gz/sca" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol LF ${url}/branches/sca-java-M2/sca target/source/gz/sca"/>
+ </exec>
+
+ <tar destfile="target/${prefix}-src.tar" longfile="gnu">
+ <tarfileset dir="target/source/gz/sca" prefix="src/sca"/>
+ </tar>
+ <gzip zipfile="target/${prefix}-src.tar.gz" src="target/${prefix}-src.tar" />
+ <delete file="target/${prefix}-src.tar" />
+
+ </target>
+
+ <target name="sample">
+
+ <delete dir="target/source/zip/samples" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol CRLF ${url}/branches/sca-java-M2/samples target/source/zip/samples"/>
+ </exec>
+
+ <zip destfile="target/${prefix}-sample-src.zip">
+ <zipfileset dir="target/source/zip/samples" prefix="src/samples"/>
+ </zip>
+
+ <delete dir="target/source/gz/samples" quiet="true"/>
+ <exec executable="svn">
+ <arg line="export --native-eol LF ${url}/branches/sca-java-M2/samples target/source/gz/samples"/>
+ </exec>
+
+ <tar destfile="target/${prefix}-sample-src.tar" longfile="gnu">
+ <tarfileset dir="target/source/gz/samples" prefix="src/samples"/>
+ </tar>
+ <gzip zipfile="target/${prefix}-sample-src.tar.gz" src="target/${prefix}-sample-src.tar" />
+ <delete file="target/${prefix}-sample-src.tar" />
+
+ </target>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/distribution/extensions.scdl b/sca-java-1.x/branches/sca-java-M2/sca/distribution/extensions.scdl
new file mode 100644
index 0000000000..4146d9b30c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/distribution/extensions.scdl
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Composite containing definitions for contributed extensions.
+ Extensions can be enabled either by including them in this file or
+ by copying their SCDL or jar file to the extensions directory.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.sca.distribution.Extensions">
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/distribution/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/distribution/pom.xml
new file mode 100644
index 0000000000..8aee04be1d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/distribution/pom.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>distribution</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Tuscany Standalone Distribution</name>
+ <description>Tuscany Distribution for a standalone runtime environment.</description>
+
+ <properties>
+ <sca.version>1.0-incubator-M2-SNAPSHOT</sca.version>
+ </properties>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <!-- dependencies for base distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>standalone-host</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>standalone</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.commands</groupId>
+ <artifactId>launcher</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>maven</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency><!-- TUSCANY-871 -->
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>compile</scope>
+ </dependency>
+
+
+
+ <!-- dependencies for contributed extensions -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>rmi</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>javascript</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>ruby</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>spring</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${sca.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <finalName>tuscany-sca-${sca.version}</finalName>
+ <descriptors>
+ <descriptor>src/main/assembly/standalone.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/distribution/src/main/assembly/standalone.xml b/sca-java-1.x/branches/sca-java-M2/sca/distribution/src/main/assembly/standalone.xml
new file mode 100644
index 0000000000..6db8f1f343
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/distribution/src/main/assembly/standalone.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<assembly>
+ <id>bin</id>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <formats>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+
+ <files>
+ <!-- include legal and other files -->
+ <file>
+ <source>LICENSE.txt</source>
+ <outputDirectory>/</outputDirectory>
+ </file>
+ <file>
+ <source>NOTICE.txt</source>
+ <outputDirectory>/</outputDirectory>
+ <filtered>true</filtered>
+ </file>
+
+ <!-- marker to create the extensions directory -->
+ <file>
+ <source>extensions.scdl</source>
+ <outputDirectory>/extensions</outputDirectory>
+ </file>
+ </files>
+
+
+ <dependencySets>
+ <!-- include commands in bin directory (without versions) -->
+ <dependencySet>
+ <outputDirectory>bin</outputDirectory>
+ <outputFileNameMapping>${artifactId}.${extension}</outputFileNameMapping>
+ <includes>
+ <include>org.apache.tuscany.sca.commands:launcher</include>
+ </includes>
+ <excludes>
+ <exclude>org.osoa:sca-api</exclude>
+ </excludes>
+ <fileMode>755</fileMode>
+ </dependencySet>
+
+ <!-- include libraries in lib directory (with versions) -->
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>org.osoa:sca-api</include>
+ <include>org.apache.tuscany.sca.kernel:tuscany-api</include>
+ <include>org.apache.tuscany.sca.kernel:tuscany-host-api</include>
+ <include>org.apache.tuscany.sca.runtime:standalone</include>
+
+ <!-- TUSCANY-871 -->
+ <include>org.apache.tuscany.sdo:tuscany-sdo-impl</include>
+
+ </includes>
+ <excludes>
+ <exclude>org.apache.tuscany.sca.runtime:standalone-host</exclude>
+ </excludes>
+ <fileMode>644</fileMode>
+ </dependencySet>
+
+ <!-- libraries needed to boot the runtime -->
+ <dependencySet>
+ <outputDirectory>boot</outputDirectory>
+ <scope>runtime</scope>
+ <includes>
+ <include>org.apache.tuscany.sca.runtime:standalone-host</include>
+ <include>org.apache.tuscany.sca.kernel:core</include>
+ <include>org.apache.tuscany.sca.kernel:tuscany-spi</include>
+ <include>org.apache.tuscany.sca.services:maven</include>
+ <include>stax:stax-api</include>
+ <include>woodstox:wstx-asl</include>
+ <include>javax.servlet:servlet-api</include>
+ </includes>
+ <excludes>
+ <exclude>junit:junit</exclude>
+ </excludes>
+ <fileMode>644</fileMode>
+ </dependencySet>
+
+ <!-- contributed extensions -->
+ <dependencySet>
+ <outputDirectory>contrib</outputDirectory>
+ <scope>compile</scope>
+ <includes>
+ <include>org.apache.tuscany.sca.services.bindings:axis2</include>
+ <include>org.apache.tuscany.sca.services.bindings:rmi</include>
+ <include>org.apache.tuscany.sca.services.containers:javascript</include>
+ <include>org.apache.tuscany.sca.services.containers:ruby</include>
+ <include>org.apache.tuscany.sca.services.containers:spring</include>
+ <include>org.apache.tuscany.sca.services.databinding:databinding-sdo</include>
+ </includes>
+ <excludes>
+ <exclude>org.apache.tuscany.sca.kernel:tuscany-spi</exclude>
+ <!-- dependencies from binding.axis2 -->
+ <exclude>org.apache.axis2:axis2-kernel</exclude>
+ <exclude>org.apache.ws.commons.axiom:axiom-api</exclude>
+ <exclude>org.apache.ws.commons.axiom:axiom-impl</exclude>
+ <exclude>org.apache.ws.commons.schema:XmlSchema</exclude>
+ <exclude>incubator-woden:woden</exclude>
+ <exclude>wsdl4j:wsdl4j</exclude>
+ <exclude>org.apache.tuscany.sca.services.idl:wsdl</exclude>
+
+ <!-- dependencies from binding.rmi -->
+ <exclude>cglib:cglib-nodep</exclude>
+
+ <!-- dependencies from container.javascript -->
+ <exclude>rhino:js</exclude>
+ <exclude>xmlbeans:xbean</exclude>
+
+ <!-- dependencies from container.ruby -->
+ <exclude>org.jruby:jruby</exclude>
+
+ <!-- dependencies from container.spring -->
+ <exclude>org.springframework:spring</exclude>
+ <exclude>org.apache.tuscany.sca.runtime:webapp</exclude>
+
+ <!-- dependencies from databinding.sdo -->
+ <exclude>org.apache.tuscany.sdo:tuscany-sdo-impl</exclude>
+
+ </excludes>
+ <fileMode>644</fileMode>
+ </dependencySet>
+ </dependencySets>
+</assembly>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.checkstyle b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.checkstyle
new file mode 100644
index 0000000000..3e57539570
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.checkstyle
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.pmd b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.pmd
new file mode 100644
index 0000000000..ffc4fe2bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/pom.xml
new file mode 100644
index 0000000000..f9c3ccc0c8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-api</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany SCA API</name>
+ <description>Tuscany Application Programming Interfaces.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java
new file mode 100644
index 0000000000..80ce0c652f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The root checked exception for the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class TuscanyException extends Exception {
+ private static final long serialVersionUID = -7847121698339635268L;
+ private List<String> contextStack;
+ private String identifier;
+
+ /**
+ * Override constructor from Exception.
+ *
+ * @see Exception
+ */
+ public TuscanyException() {
+ super();
+ }
+
+ /**
+ * Override constructor from Exception.
+ *
+ * @param message passed to Exception
+ * @see Exception
+ */
+ public TuscanyException(String message) {
+ super(message);
+ }
+
+ /**
+ * Override constructor from Exception.
+ *
+ * @param message passed to Exception
+ * @param cause passed to Exception
+ * @see Exception
+ */
+ public TuscanyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Override constructor from Exception.
+ *
+ * @param cause passed to Exception
+ * @see Exception
+ */
+ public TuscanyException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns a collection of names representing the context call stack where the error occured. The top of the stack
+ * is the first element in the collection.
+ *
+ * @return a collection of names representing the context call stack
+ */
+ public List<String> returnContextNames() {
+ if (contextStack == null) {
+ contextStack = new ArrayList<String>();
+ }
+ return contextStack;
+ }
+
+ /**
+ * Pushes a context name where an error occured onto the call stack.
+ *
+ * @param name the name of a context to push on the stack
+ */
+ public void addContextName(String name) {
+ if (contextStack == null) {
+ contextStack = new ArrayList<String>();
+ }
+ contextStack.add(name);
+ }
+
+ /**
+ * Returns a string representing additional error information referred to in the error message.
+ *
+ * @return additional error information
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Sets an additional error information referred to in the error message.
+ *
+ * @param identifier additional error information
+ */
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getMessage() {
+ if (identifier == null && contextStack == null) {
+ return super.getMessage();
+ }
+ StringBuilder b = new StringBuilder(256);
+ b.append(super.getMessage());
+
+ if (identifier != null) {
+ b.append(" [").append(identifier).append(']');
+ }
+ if (contextStack != null) {
+ b.append("\nContext stack trace: ");
+ for (int i = contextStack.size() - 1; i >= 0; i--) {
+ b.append('[').append(contextStack.get(i)).append(']');
+ }
+ }
+ return b.toString();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java
new file mode 100644
index 0000000000..ed70b8670e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The root unchecked exception for the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public abstract class TuscanyRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = -759677431966121786L;
+ private List<String> contextStack;
+ private String identifier;
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @see RuntimeException
+ */
+ public TuscanyRuntimeException() {
+ super();
+ }
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @param message passed to RuntimeException
+ * @see RuntimeException
+ */
+ public TuscanyRuntimeException(String message) {
+ super(message);
+ }
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @param message passed to RuntimeException
+ * @param cause passed to RuntimeException
+ * @see RuntimeException
+ */
+ public TuscanyRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @param cause passed to RuntimeException
+ * @see RuntimeException
+ */
+ public TuscanyRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns a collection of names representing the context call stack where the error occured. The top of the stack
+ * is the first element in the collection.
+ *
+ * @return a collection of names representing the context call stack
+ */
+ public List<String> returnContextNames() {
+ if (contextStack == null) {
+ contextStack = new ArrayList<String>();
+ }
+ return contextStack;
+ }
+
+ /**
+ * Pushes a context name where an error occured onto the call stack.
+ *
+ * @param name the name of a context to push on the stack
+ */
+ public void addContextName(String name) {
+ if (contextStack == null) {
+ contextStack = new ArrayList<String>();
+ }
+ contextStack.add(name);
+ }
+
+ /**
+ * Returns a string representing additional error information referred to in the error message.
+ *
+ * @return additional error information
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Sets an additional error information referred to in the error message.
+ *
+ * @param identifier additional error information
+ */
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getMessage() {
+ if (identifier == null && contextStack == null) {
+ return super.getMessage();
+ }
+ StringBuilder b = new StringBuilder(256);
+ b.append(super.getMessage());
+
+ if (identifier != null) {
+ b.append(" [").append(identifier).append(']');
+ }
+ if (contextStack != null) {
+ b.append("\nContext stack trace: ");
+ for (int i = contextStack.size() - 1; i >= 0; i--) {
+ b.append('[').append(contextStack.get(i)).append(']');
+ }
+ }
+ return b.toString();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java
new file mode 100644
index 0000000000..ab74ba9e5c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api.annotation;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * A key/value pair to represent information pertaining to a {@link DataType}
+ */
+@Target(ANNOTATION_TYPE)
+@Retention(RUNTIME)
+public @interface DataContext {
+ /**
+ * @return key for the context entry
+ */
+ String key();
+
+ /**
+ * @return key for the context value
+ */
+ String value();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java
new file mode 100644
index 0000000000..439aa837d2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Used to demarcate expected data types for an operation
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface DataType {
+
+ /**
+ * Returns the unique name of the data binding
+ * @return the unique name of the data binding
+ */
+ String name();
+
+ /**
+ * Returns the logical data type
+ * @return the logical data type
+ */
+ Class logicalType() default Object.class;
+
+ /**
+ * Returns the physical data type
+ * @return the physical data type
+ */
+ Class physicalType() default Object.class;
+
+ /**
+ * Returns an array of extensibility elements
+ * @return an array of extensibility elements
+ */
+ DataContext[] context() default {};
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java
new file mode 100644
index 0000000000..83c5df26d9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that can be applied to methods in a monitoring interface to indicate to logging frameworks the severity of
+ * the event.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface LogLevel {
+
+ /**
+ * The log level as specified by {@link java.util.logging.Level}.
+ */
+ @SuppressWarnings({"JavaDoc"}) String value();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java
new file mode 100644
index 0000000000..dea9489e5b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A system annotation to inject a monitor
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Monitor {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java
new file mode 100644
index 0000000000..304706142c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyExceptionTestCase extends TestCase {
+ private static final Throwable CAUSE = new Throwable("Cause");
+ private static final String MESSAGE = "Message";
+ private static final String IDENTIFIER = "IDENTIFIER";
+ private static final String CONTEXT1 = "CONTEXT1";
+ private static final String CONTEXT2 = "CONTEXT2";
+
+ public void testNoArgConstructor() {
+ TuscanyException ex = new DummyException();
+ assertNull(ex.getMessage());
+ assertNull(ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testMessageConstructor() {
+ TuscanyException ex = new DummyException(MESSAGE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertNull(ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testThrowableConstructor() {
+ TuscanyException ex = new DummyException(CAUSE);
+ assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testMessageThrowableConstructor() {
+ TuscanyException ex = new DummyException(MESSAGE, CAUSE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testIdentifier() {
+ TuscanyException ex = new DummyException(MESSAGE);
+ ex.setIdentifier(IDENTIFIER);
+ assertSame(IDENTIFIER, ex.getIdentifier());
+ assertEquals(MESSAGE + " [" + IDENTIFIER + ']', ex.getMessage());
+ }
+
+ public void testContextStack() {
+ TuscanyException ex = new DummyException(MESSAGE);
+ List<String> contexts = new ArrayList<String>();
+ contexts.add(CONTEXT1);
+ ex.addContextName(CONTEXT1);
+ assertEquals(contexts, ex.returnContextNames());
+ contexts.add(CONTEXT2);
+ ex.addContextName(CONTEXT2);
+ assertEquals(contexts, ex.returnContextNames());
+ }
+
+ public void testContextMessageWithNoIdentifier() {
+ TuscanyException ex = new DummyException(MESSAGE);
+ ex.addContextName(CONTEXT1);
+ ex.addContextName(CONTEXT2);
+ assertEquals("Message\nContext stack trace: [CONTEXT2][CONTEXT1]", ex.getMessage());
+ }
+
+
+ public void testContextMessageWithIdentifier() {
+ TuscanyException ex = new DummyException(MESSAGE);
+ ex.setIdentifier(IDENTIFIER);
+ ex.addContextName(CONTEXT1);
+ ex.addContextName(CONTEXT2);
+ assertEquals("Message [IDENTIFIER]\nContext stack trace: [CONTEXT2][CONTEXT1]", ex.getMessage());
+ }
+
+ public static class DummyException extends TuscanyException {
+ public DummyException() {
+ }
+
+ public DummyException(String message) {
+ super(message);
+ }
+
+ public DummyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DummyException(Throwable cause) {
+ super(cause);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java
new file mode 100644
index 0000000000..85cc1e752a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyRuntimeExceptionTestCase extends TestCase {
+ private static final Throwable CAUSE = new Throwable("Cause");
+ private static final String MESSAGE = "Message";
+ private static final String IDENTIFIER = "IDENTIFIER";
+ private static final String CONTEXT1 = "CONTEXT1";
+ private static final String CONTEXT2 = "CONTEXT2";
+
+ public void testNoArgConstructor() {
+ TuscanyRuntimeException ex = new DummyException();
+ assertNull(ex.getMessage());
+ assertNull(ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testMessageConstructor() {
+ TuscanyRuntimeException ex = new DummyException(MESSAGE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertNull(ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testThrowableConstructor() {
+ TuscanyRuntimeException ex = new DummyException(CAUSE);
+ assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testMessageThrowableConstructor() {
+ TuscanyRuntimeException ex = new DummyException(MESSAGE, CAUSE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ assertNull(ex.getIdentifier());
+ assertTrue(ex.returnContextNames().isEmpty());
+ }
+
+ public void testIdentifier() {
+ TuscanyRuntimeException ex = new DummyException(MESSAGE);
+ ex.setIdentifier(IDENTIFIER);
+ assertSame(IDENTIFIER, ex.getIdentifier());
+ assertEquals(MESSAGE + " [" + IDENTIFIER + ']', ex.getMessage());
+ }
+
+ public void testContextStack() {
+ TuscanyRuntimeException ex = new DummyException(MESSAGE);
+ List<String> contexts = new ArrayList<String>();
+ contexts.add(CONTEXT1);
+ ex.addContextName(CONTEXT1);
+ assertEquals(contexts, ex.returnContextNames());
+ contexts.add(CONTEXT2);
+ ex.addContextName(CONTEXT2);
+ assertEquals(contexts, ex.returnContextNames());
+ }
+
+ public void testContextMessageWithNoIdentifier() {
+ TuscanyRuntimeException ex = new DummyException(MESSAGE);
+ ex.addContextName(CONTEXT1);
+ ex.addContextName(CONTEXT2);
+ assertEquals("Message\nContext stack trace: [CONTEXT2][CONTEXT1]", ex.getMessage());
+ }
+
+
+ public void testContextMessageWithIdentifier() {
+ TuscanyRuntimeException ex = new DummyException(MESSAGE);
+ ex.setIdentifier(IDENTIFIER);
+ ex.addContextName(CONTEXT1);
+ ex.addContextName(CONTEXT2);
+ assertEquals("Message [IDENTIFIER]\nContext stack trace: [CONTEXT2][CONTEXT1]", ex.getMessage());
+ }
+
+ public static class DummyException extends TuscanyRuntimeException {
+ public DummyException() {
+ }
+
+ public DummyException(String message) {
+ super(message);
+ }
+
+ public DummyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DummyException(Throwable cause) {
+ super(cause);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.pmd b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.pmd
new file mode 100644
index 0000000000..ffc4fe2bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.ruleset
new file mode 100644
index 0000000000..ba9b5ce886
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/pom.xml
new file mode 100644
index 0000000000..0a90fb8333
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>core</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany SCA Core</name>
+ <description>Core Tuscany runtime.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-host-api</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>commonj-api_r1.1</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>${notice.dir}</directory>
+ <targetPath>META-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>LICENSE.txt</include>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
new file mode 100644
index 0000000000..0f6b4a2c92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.implementation.java.Introspector;
+import org.apache.tuscany.spi.loader.Loader;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+
+/**
+ * Interface that abstracts the process used to create a running Tuscany system. Implementation of this may provide
+ * different mechanisms for creating the primoridal system components used to boot the core to the level where it can
+ * support end-user applications.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Bootstrapper {
+ /**
+ * Return the MonitorFactory being used by the implementation to provide monitor interfaces for the primordial
+ * components.
+ *
+ * @return the MonitorFactory being used by the bootstrapper
+ */
+ MonitorFactory getMonitorFactory();
+
+ /**
+ * Create the RuntimeComponent that forms the fundamental root of the component assembly. This component has two
+ * children: a {@link org.apache.tuscany.spi.component.CompositeComponent} that is the root for all system
+ * components, and a {@link org.apache.tuscany.spi.component.CompositeComponent} that is the root for all
+ * application components.
+ *
+ * @return a new RuntimeComponent; basically a new Tuscany instance
+ */
+ RuntimeComponent createRuntime();
+
+ /**
+ * Create a Deployer that can be used to deploy the system definition. This will most likely only support a small
+ * subset of the available programming model.
+ *
+ * @return a new primordial Deployer
+ */
+ Deployer createDeployer();
+
+ /**
+ * Create a Loader for parsing a system definition represented as a XML SCDL file.
+ *
+ * @param propertyFactory the StAXPropertyFactory to be used to parse property values
+ * @param introspector the introspector to be used to extract component type information from a Java class
+ * @return a new prmordial Loader
+ */
+ Loader createLoader(PropertyObjectFactory propertyFactory, Introspector introspector);
+
+ /**
+ * Create a ScopeRegistry that supports the Scopes supported for primordial components
+ *
+ * @param workContext the WorkContext the Scopes should use
+ * @return a new primordial ScopeRegistry
+ */
+ ScopeRegistry createScopeRegistry(WorkContext workContext);
+
+ /**
+ * Create a Connector that can wire together primordial components.
+ *
+ * @return a new primordial Connector
+ */
+ Connector createConnector();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
new file mode 100644
index 0000000000..d42e07cbb8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.core.builder.BuilderRegistryImpl;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory;
+import org.apache.tuscany.core.component.scope.ScopeRegistryImpl;
+import org.apache.tuscany.core.deployer.DeployerImpl;
+import org.apache.tuscany.core.idl.java.InterfaceJavaLoader;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl;
+import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl;
+import org.apache.tuscany.core.implementation.composite.CompositeLoader;
+import org.apache.tuscany.core.implementation.processor.ConstructorProcessor;
+import org.apache.tuscany.core.implementation.processor.DestroyProcessor;
+import org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor;
+import org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl;
+import org.apache.tuscany.core.implementation.processor.InitProcessor;
+import org.apache.tuscany.core.implementation.processor.MonitorProcessor;
+import org.apache.tuscany.core.implementation.processor.PropertyProcessor;
+import org.apache.tuscany.core.implementation.processor.ReferenceProcessor;
+import org.apache.tuscany.core.implementation.processor.ScopeProcessor;
+import org.apache.tuscany.core.implementation.processor.ServiceProcessor;
+import org.apache.tuscany.core.implementation.system.builder.SystemBindingBuilder;
+import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder;
+import org.apache.tuscany.core.implementation.system.builder.SystemCompositeBuilder;
+import org.apache.tuscany.core.implementation.system.loader.SystemBindingLoader;
+import org.apache.tuscany.core.implementation.system.loader.SystemComponentTypeLoader;
+import org.apache.tuscany.core.implementation.system.loader.SystemCompositeComponentTypeLoader;
+import org.apache.tuscany.core.implementation.system.loader.SystemImplementationLoader;
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.loader.ComponentLoader;
+import org.apache.tuscany.core.loader.ComponentTypeElementLoader;
+import org.apache.tuscany.core.loader.IncludeLoader;
+import org.apache.tuscany.core.loader.LoaderRegistryImpl;
+import org.apache.tuscany.core.loader.PropertyLoader;
+import org.apache.tuscany.core.loader.ReferenceLoader;
+import org.apache.tuscany.core.loader.ServiceLoader;
+import org.apache.tuscany.core.property.PropertyObjectFactoryImpl;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.builder.Builder;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.Introspector;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+
+/**
+ * A default implementation of a Bootstrapper. Please see the documentation on the individual methods for how the
+ * primordial components are created.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultBootstrapper implements Bootstrapper {
+ private final MonitorFactory monitorFactory;
+ private final XMLInputFactory xmlFactory;
+
+ /**
+ * Create a default bootstrapper.
+ *
+ * @param monitorFactory the MonitorFactory to be used to create monitors for the primordial components
+ * @param xmlFactory the XMLInputFactory to be used by the components to load XML artifacts
+ */
+ public DefaultBootstrapper(MonitorFactory monitorFactory, XMLInputFactory xmlFactory) {
+ this.monitorFactory = monitorFactory;
+ this.xmlFactory = xmlFactory;
+ }
+
+ /**
+ * Returns the MonitorFactory being used by this bootstrapper.
+ *
+ * @return the MonitorFactory being used by this bootstrapper
+ */
+ public MonitorFactory getMonitorFactory() {
+ return monitorFactory;
+ }
+
+ /**
+ * Create the RuntimeComponent that will form the root of the component tree. Returns an new instance of a {@link
+ * DefaultRuntime} with the system and application root components initialized with default composite components.
+ *
+ * @return a newly created root for the component tree
+ */
+ public RuntimeComponent createRuntime() {
+ DefaultRuntime runtime = new DefaultRuntime();
+ CompositeComponent systemComponent =
+ new CompositeComponentImpl(ComponentNames.TUSCANY_SYSTEM, runtime, null, null);
+ runtime.setSystemComponent(systemComponent);
+ CompositeComponent rootComponent =
+ new CompositeComponentImpl(ComponentNames.TUSCANY_ROOT, runtime, null, null);
+ runtime.setRootComponent(rootComponent);
+ return runtime;
+ }
+
+ /**
+ * Create primordial deployer that can be used to load the system definition.
+ *
+ * @return the primordial deployer
+ */
+ public Deployer createDeployer() {
+ ScopeRegistry scopeRegistry = createScopeRegistry(new WorkContextImpl());
+ Builder builder = createBuilder(scopeRegistry);
+ JavaInterfaceProcessorRegistry interfaceIntrospector = new JavaInterfaceProcessorRegistryImpl();
+ Introspector introspector = createIntrospector(interfaceIntrospector);
+ LoaderRegistry loader = createLoader(new PropertyObjectFactoryImpl(), introspector);
+ return new DeployerImpl(xmlFactory, loader, builder);
+ }
+
+ /**
+ * Create a basic ScopeRegistry containing the ScopeContainers that are available to components in the system
+ * definition. The implementation returned only support MODULE scope.
+ *
+ * @param workContext the WorkContext the scopes should use
+ * @return a new ScopeRegistry
+ */
+ public ScopeRegistry createScopeRegistry(WorkContext workContext) {
+ ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+ new ModuleScopeObjectFactory(scopeRegistry); // self-registers
+ return scopeRegistry;
+ }
+
+ /**
+ * Create a Loader that can be used to parse an XML file containing the SCDL for the system definition. The
+ * following Implementation types are supported: <ul> <li>SystemImplementation</li>
+ * <li>SystemCompositeImplementation</li> </ul> and the following SCDL elements are supported: <ul>
+ * <li>composite</li> <li>component</li> <li>componentType</li> <li>interface.java</li> <li>property</li>
+ * <li>reference</li> <li>service</li> <li>implementation.system</li> <li>binding.system</li> </ul> Note the Java
+ * component type and the WSDL interface type are not supported.
+ *
+ * @param propertyFactory the StAXPropertyFactory to be used for parsing Property values
+ * @param introspector the Introspector to be used to inspect component implementations
+ * @return a new StAX XML loader
+ */
+ public LoaderRegistry createLoader(PropertyObjectFactory propertyFactory, Introspector introspector) {
+ LoaderRegistryImpl loaderRegistry =
+ new LoaderRegistryImpl(monitorFactory.getMonitor(LoaderRegistryImpl.Monitor.class));
+
+ // register component type loaders
+ loaderRegistry.registerLoader(SystemImplementation.class,
+ new SystemComponentTypeLoader(introspector));
+ loaderRegistry.registerLoader(SystemCompositeImplementation.class,
+ new SystemCompositeComponentTypeLoader(loaderRegistry));
+
+ // register element loaders
+ registerLoader(loaderRegistry, new ComponentLoader(loaderRegistry, propertyFactory));
+ registerLoader(loaderRegistry, new ComponentTypeElementLoader(loaderRegistry));
+ registerLoader(loaderRegistry, new CompositeLoader(loaderRegistry, null));
+ registerLoader(loaderRegistry, new IncludeLoader(loaderRegistry));
+ registerLoader(loaderRegistry,
+ new InterfaceJavaLoader(loaderRegistry, new JavaInterfaceProcessorRegistryImpl()));
+ registerLoader(loaderRegistry, new PropertyLoader(loaderRegistry));
+ registerLoader(loaderRegistry, new ReferenceLoader(loaderRegistry));
+ registerLoader(loaderRegistry, new ServiceLoader(loaderRegistry));
+ registerLoader(loaderRegistry, new SystemImplementationLoader(loaderRegistry));
+ registerLoader(loaderRegistry, new SystemBindingLoader(loaderRegistry));
+ return loaderRegistry;
+ }
+
+ /**
+ * Create new Introspector for extracting a ComponentType definition from a Java class.
+ *
+ * @return a new Introspector
+ */
+ public Introspector createIntrospector(JavaInterfaceProcessorRegistry registry) {
+ ImplementationProcessorService service = new ImplementationProcessorServiceImpl(registry);
+ IntrospectionRegistryImpl introspectionRegistry =
+ new IntrospectionRegistryImpl(monitorFactory.getMonitor(IntrospectionRegistryImpl.Monitor.class));
+ introspectionRegistry.registerProcessor(new ConstructorProcessor(service));
+ introspectionRegistry.registerProcessor(new DestroyProcessor());
+ introspectionRegistry.registerProcessor(new InitProcessor());
+ introspectionRegistry.registerProcessor(new ScopeProcessor());
+ introspectionRegistry.registerProcessor(new PropertyProcessor(service));
+ introspectionRegistry.registerProcessor(new ReferenceProcessor(registry));
+ introspectionRegistry.registerProcessor(new ServiceProcessor(service));
+ introspectionRegistry.registerProcessor(new HeuristicPojoProcessor(service));
+ introspectionRegistry.registerProcessor(new MonitorProcessor(monitorFactory, service));
+ return introspectionRegistry;
+ }
+
+ /**
+ * Create a new Connector that can be used to wire primordial components together.
+ *
+ * @return a new Connector
+ */
+ public Connector createConnector() {
+ return new ConnectorImpl();
+ }
+
+ /**
+ * Helper method for registering a loader with the registry. The Loader is registered once for the QName returned by
+ * its {@link LoaderExtension#getXMLType()} method.
+ *
+ * @param registry the LoaderRegistry to register with
+ * @param loader the Loader to register
+ */
+ protected void registerLoader(LoaderRegistry registry, LoaderExtension<?> loader) {
+ registry.registerLoader(loader.getXMLType(), loader);
+ }
+
+ /**
+ * Create a Builder that can be used to build the components in the system definition. The default implementation
+ * only supports implementations from the system programming model.
+ *
+ * @param scopeRegistry the ScopeRegistry defining the component scopes that will be supported
+ * @return a new Builder
+ */
+ private Builder createBuilder(ScopeRegistry scopeRegistry) {
+ BuilderRegistry builderRegistry = new BuilderRegistryImpl(scopeRegistry);
+ SystemCompositeBuilder builder = new SystemCompositeBuilder(builderRegistry, createConnector());
+ builderRegistry.register(SystemCompositeImplementation.class, builder);
+ builderRegistry.register(SystemImplementation.class, new SystemComponentBuilder());
+ builderRegistry.register(SystemBinding.class, new SystemBindingBuilder());
+ return builderRegistry;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java
new file mode 100644
index 0000000000..78a317df2c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+
+import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl;
+
+/**
+ * The default implementation of the Tuscany runtime component
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultRuntime extends CompositeComponentImpl implements RuntimeComponent {
+ private CompositeComponent rootComponent;
+ private CompositeComponent systemComponent;
+
+ /**
+ * Initialize a default runtime with an empty set of Property values.
+ */
+ public DefaultRuntime() {
+ this(new HashMap<String, Document>());
+ }
+
+ /**
+ * Initialize a runtime with the a set of properties
+ *
+ * @param runtimeProperties Property values for the runtime itself
+ */
+ public DefaultRuntime(Map<String, Document> runtimeProperties) {
+ super(ComponentNames.TUSCANY_RUNTIME, null, null, runtimeProperties);
+ }
+
+ protected void setRootComponent(CompositeComponent rootComponent) {
+ this.rootComponent = rootComponent;
+ }
+
+ protected void setSystemComponent(CompositeComponent systemComponent) {
+ this.systemComponent = systemComponent;
+ }
+
+ public CompositeComponent getRootComponent() {
+ return rootComponent;
+ }
+
+ public CompositeComponent getSystemComponent() {
+ return systemComponent;
+ }
+
+ public Deployer getDeployer() {
+ return systemComponent.resolveExternalInstance(Deployer.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
new file mode 100644
index 0000000000..c899af1a13
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BindingBuilder;
+import org.apache.tuscany.spi.builder.BindlessBuilder;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.ComponentBuilder;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * The default builder registry in the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class BuilderRegistryImpl implements BuilderRegistry {
+
+ protected WireService wireService;
+ protected ScopeRegistry scopeRegistry;
+
+ private final Map<Class<? extends Implementation<?>>,
+ ComponentBuilder<? extends Implementation<?>>> componentBuilders =
+ new HashMap<Class<? extends Implementation<?>>, ComponentBuilder<? extends Implementation<?>>>();
+ private final Map<Class<? extends Binding>,
+ BindingBuilder<? extends Binding>> bindingBuilders =
+ new HashMap<Class<? extends Binding>, BindingBuilder<? extends Binding>>();
+ private BindlessBuilder bindlessBuilder;
+
+ public BuilderRegistryImpl() {
+ }
+
+ public BuilderRegistryImpl(ScopeRegistry scopeRegistry) {
+ this.scopeRegistry = scopeRegistry;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ @Autowire
+ public void setScopeRegistry(ScopeRegistry scopeRegistry) {
+ this.scopeRegistry = scopeRegistry;
+ }
+
+ @Autowire
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ public <I extends Implementation<?>> void register(Class<I> implClass, ComponentBuilder<I> builder) {
+ componentBuilders.put(implClass, builder);
+ }
+
+ public <I extends Implementation<?>> void unregister(Class<I> implClass) {
+ componentBuilders.remove(implClass);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <I extends Implementation<?>> Component build(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition,
+ DeploymentContext deploymentContext) {
+ Class<?> implClass = componentDefinition.getImplementation().getClass();
+ ComponentBuilder<I> componentBuilder = (ComponentBuilder<I>) componentBuilders.get(implClass);
+ if (componentBuilder == null) {
+ BuilderConfigException e = new BuilderConfigException("No builder registered for implementation");
+ e.setIdentifier(implClass.getName());
+ e.addContextName(componentDefinition.getName());
+ throw e;
+ }
+
+ Component component = componentBuilder.build(parent, componentDefinition, deploymentContext);
+ ComponentType<?, ?, ?> componentType = componentDefinition.getImplementation().getComponentType();
+ assert componentType != null : "Component type must be set";
+ // create wires for the component
+ if (wireService != null && !(component instanceof SystemAtomicComponent)) {
+ wireService.createWires(component, componentDefinition);
+ }
+ return component;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <B extends Binding> void register(BindingBuilder<B> builder) {
+ Type[] interfaces = builder.getClass().getGenericInterfaces();
+ for (Type type : interfaces) {
+ if (!(type instanceof ParameterizedType)) {
+ continue;
+ }
+ ParameterizedType interfaceType = (ParameterizedType) type;
+ if (!BindingBuilder.class.equals(interfaceType.getRawType())) {
+ continue;
+ }
+ Class<B> implClass = (Class<B>) interfaceType.getActualTypeArguments()[0];
+ register(implClass, builder);
+ return;
+ }
+ throw new IllegalArgumentException("builder is not generified");
+ }
+
+ public <B extends Binding> void register(Class<B> implClass, BindingBuilder<B> builder) {
+ bindingBuilders.put(implClass, builder);
+ }
+
+ public void register(BindlessBuilder builder) {
+ bindlessBuilder = builder;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <B extends Binding> SCAObject build(CompositeComponent parent,
+ BoundServiceDefinition<B> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+ Class<?> bindingClass = boundServiceDefinition.getBinding().getClass();
+ BindingBuilder<B> bindingBuilder = (BindingBuilder<B>) bindingBuilders.get(bindingClass);
+ SCAObject object = bindingBuilder.build(parent, boundServiceDefinition, deploymentContext);
+ if (wireService != null) {
+ // wireService.createWires((Service) object, boundServiceDefinition);
+ String path = boundServiceDefinition.getTarget().getPath();
+ ServiceContract<?> contract = boundServiceDefinition.getServiceContract();
+ wireService.createWires((Service)object, path, contract);
+ }
+ return object;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <B extends Binding> SCAObject build(CompositeComponent parent,
+ BoundReferenceDefinition<B> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ Class<B> bindingClass = (Class<B>) boundReferenceDefinition.getBinding().getClass();
+ BindingBuilder<B> bindingBuilder = (BindingBuilder<B>) bindingBuilders.get(bindingClass);
+ SCAObject object = bindingBuilder.build(parent, boundReferenceDefinition, deploymentContext);
+ // create wires for the component
+ if (wireService != null) {
+ wireService.createWires((Reference) object, boundReferenceDefinition.getServiceContract());
+ }
+ return object;
+ }
+
+ public SCAObject build(CompositeComponent parent,
+ BindlessServiceDefinition serviceDefinition,
+ DeploymentContext deploymentContext) {
+ SCAObject object = bindlessBuilder.build(parent, serviceDefinition, deploymentContext);
+ if (wireService != null) {
+ String path = serviceDefinition.getTarget().getPath();
+ ServiceContract<?> contract = serviceDefinition.getServiceContract();
+ wireService.createWires((Service)object, path, contract);
+ }
+ return object;
+ }
+
+ public SCAObject build(CompositeComponent parent,
+ ReferenceDefinition referenceDefinition,
+ DeploymentContext deploymentContext) {
+ SCAObject object = bindlessBuilder.build(parent, referenceDefinition, deploymentContext);
+ if (wireService != null) {
+ wireService.createWires((Reference) object, referenceDefinition.getServiceContract());
+ }
+ return object;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
new file mode 100644
index 0000000000..5194bc5905
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
@@ -0,0 +1,484 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ComponentRuntimeException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.IncompatibleServiceContractException;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.core.implementation.composite.CompositeReference;
+import org.apache.tuscany.core.implementation.composite.CompositeService;
+import org.apache.tuscany.core.wire.NonBlockingBridgingInterceptor;
+import org.apache.tuscany.core.wire.OutboundAutowire;
+import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor;
+
+/**
+ * The default connector implmentation
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ConnectorImpl implements Connector {
+
+ private WirePostProcessorRegistry postProcessorRegistry;
+ private WireService wireService;
+ private WorkContext workContext;
+ private WorkScheduler scheduler;
+
+ public ConnectorImpl() {
+ }
+
+ @Constructor({"wireService", "processorRegistry", "scheduler", "workContext"})
+ public ConnectorImpl(@Autowire WireService wireService,
+ @Autowire WirePostProcessorRegistry processorRegistry,
+ @Autowire WorkScheduler scheduler,
+ @Autowire WorkContext workContext) {
+ this.postProcessorRegistry = processorRegistry;
+ this.wireService = wireService;
+ this.scheduler = scheduler;
+ this.workContext = workContext;
+ }
+
+ public void connect(SCAObject source) {
+ CompositeComponent parent = source.getParent();
+ if (source instanceof AtomicComponent) {
+ AtomicComponent sourceComponent = (AtomicComponent) source;
+ // connect outbound wires for component references to their targets
+ for (List<OutboundWire> referenceWires : sourceComponent.getOutboundWires().values()) {
+ for (OutboundWire outboundWire : referenceWires) {
+ if (outboundWire instanceof OutboundAutowire) {
+ continue;
+ }
+ try {
+ SCAObject target;
+ if (sourceComponent.isSystem()) {
+ target = parent.getSystemChild(outboundWire.getTargetName().getPartName());
+ } else {
+ target = parent.getChild(outboundWire.getTargetName().getPartName());
+ }
+ connect(sourceComponent, outboundWire, target);
+ } catch (BuilderConfigException e) {
+ e.addContextName(source.getName());
+ e.addContextName(parent.getName());
+ throw e;
+ }
+ }
+ }
+ // connect inbound wires
+ for (InboundWire inboundWire : sourceComponent.getInboundWires().values()) {
+ for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
+ Operation<?> operation = chain.getOperation();
+ String serviceName = inboundWire.getServiceName();
+ TargetInvoker invoker = sourceComponent.createTargetInvoker(serviceName, operation);
+ chain.setTargetInvoker(invoker);
+ chain.prepare();
+ }
+ }
+ } else if (source instanceof Reference) {
+ Reference reference = (Reference) source;
+ InboundWire inboundWire = reference.getInboundWire();
+ Map<Operation<?>, InboundInvocationChain> inboundChains = inboundWire.getInvocationChains();
+ for (InboundInvocationChain chain : inboundChains.values()) {
+ //TODO handle async
+ // add target invoker on inbound side
+ ServiceContract contract = inboundWire.getServiceContract();
+ Operation operation = chain.getOperation();
+ TargetInvoker invoker = reference.createTargetInvoker(contract, operation);
+ chain.setTargetInvoker(invoker);
+ chain.prepare();
+ }
+ OutboundWire outboundWire = reference.getOutboundWire();
+ // connect the reference's inbound and outbound wires
+ connect(inboundWire, outboundWire, true);
+
+ if (reference instanceof CompositeReference) {
+ // For a composite reference only, since its outbound wire comes
+ // from its parent composite,
+ // the corresponding target would not lie in its parent but
+ // rather in its parent's parent
+ parent = parent.getParent();
+ assert parent != null : "Parent of parent was null";
+ SCAObject target = parent.getChild(outboundWire.getTargetName().getPartName());
+ connect((Component)parent, outboundWire, target);
+ }
+ } else if (source instanceof Service) {
+ Service service = (Service) source;
+ InboundWire inboundWire = service.getInboundWire();
+ OutboundWire outboundWire = service.getOutboundWire();
+ // For a composite reference only, since its outbound wire comes from its parent composite,
+ // the corresponding target would not lie in its parent but rather in its parent's parent
+ if (source instanceof CompositeReference) {
+ parent = parent.getParent();
+ assert parent != null : "Parent of parent was null";
+ }
+ SCAObject target;
+ if (service.isSystem()) {
+ target = parent.getSystemChild(outboundWire.getTargetName().getPartName());
+ } else {
+ target = parent.getChild(outboundWire.getTargetName().getPartName());
+ }
+ // connect the outbound service wire to the target
+ connect(service, outboundWire, target);
+ // NB: this connect must be done after the outbound service chain is connected to its target above
+ if (!(source instanceof CompositeService)) {
+ //REVIEW JFM: do we need this to be special for composites?
+ connect(inboundWire, outboundWire, true);
+ }
+ }
+ }
+
+ public void connect(InboundWire sourceWire, OutboundWire targetWire, boolean optimizable)
+ throws BuilderConfigException {
+ Map<Operation<?>, OutboundInvocationChain> targetChains = targetWire.getInvocationChains();
+ // perform optimization, if possible
+ if (optimizable && sourceWire.getInvocationChains().isEmpty() && targetChains.isEmpty()) {
+ sourceWire.setTargetWire(targetWire);
+ if (postProcessorRegistry != null) {
+ // run wire post-processors
+ postProcessorRegistry.process(sourceWire, targetWire);
+ }
+ return;
+ }
+ for (InboundInvocationChain inboundChain : sourceWire.getInvocationChains().values()) {
+ // match wire chains
+ OutboundInvocationChain outboundChain = targetChains.get(inboundChain.getOperation());
+ if (outboundChain == null) {
+ BuilderConfigException e = new BuilderConfigException("Incompatible source and target interfaces");
+ e.setIdentifier(sourceWire.getServiceName());
+ throw e;
+ }
+ connect(inboundChain, outboundChain);
+ }
+ if (postProcessorRegistry != null) {
+ // run wire post-processors
+ postProcessorRegistry.process(sourceWire, targetWire);
+ }
+ }
+
+ /**
+ * Connects the source outbound wire to a corresponding target inbound wire
+ *
+ * @param sourceWire the source wire to connect
+ * @param targetWire the target wire to connect to
+ * @param optimizable true if the wire connection can be optimized
+ */
+ void connect(OutboundWire sourceWire, InboundWire targetWire, boolean optimizable) {
+ SCAObject source = sourceWire.getContainer();
+ SCAObject target = targetWire.getContainer();
+ ServiceContract contract = sourceWire.getServiceContract();
+ Map<Operation<?>, InboundInvocationChain> targetChains = targetWire.getInvocationChains();
+ // perform optimization, if possible
+ // REVIEW: (kentaminator@gmail.com) shouldn't this check whether the interceptors in the
+ // source & target chains are marked as optimizable? (and if so, optimize them away?)
+ if (optimizable && sourceWire.getInvocationChains().isEmpty() && targetChains.isEmpty()) {
+ sourceWire.setTargetWire(targetWire);
+ if (postProcessorRegistry != null) {
+ // run wire post-processors
+ postProcessorRegistry.process(sourceWire, targetWire);
+ }
+ return;
+ }
+ // match outbound to inbound chains
+ for (OutboundInvocationChain outboundChain : sourceWire.getInvocationChains().values()) {
+ Operation<?> operation = outboundChain.getOperation();
+ InboundInvocationChain inboundChain = targetChains.get(operation);
+ if (inboundChain == null) {
+ BuilderConfigException e =
+ new BuilderConfigException("Incompatible source and target interfaces for reference");
+ e.setIdentifier(sourceWire.getReferenceName());
+ throw e;
+ }
+ Operation<?> inboundOperation = inboundChain.getOperation();
+ boolean isOneWayOperation = operation.isNonBlocking();
+ boolean operationHasCallback = contract.getCallbackName() != null;
+ if (isOneWayOperation && operationHasCallback) {
+ throw new ComponentRuntimeException("Operation cannot be marked one-way and have a callback");
+ }
+ TargetInvoker invoker = null;
+ if (target instanceof Component) {
+ Component component = (Component) target;
+ if (isOneWayOperation || operationHasCallback) {
+ invoker = component.createAsyncTargetInvoker(targetWire, inboundOperation);
+ } else {
+ String portName = sourceWire.getTargetName().getPortName();
+ invoker = component.createTargetInvoker(portName, inboundOperation);
+ }
+ } else if (target instanceof Reference) {
+ Reference reference = (Reference) target;
+ if (!(reference instanceof CompositeReference) && operationHasCallback) {
+ // Notice that for bound references we only use async target invokers for callback operations
+ invoker = reference.createAsyncTargetInvoker(sourceWire, inboundOperation);
+ } else {
+ ServiceContract targetContract = targetWire.getServiceContract();
+ invoker = reference.createTargetInvoker(targetContract, inboundOperation);
+ }
+ } else if (target instanceof CompositeService) {
+ CompositeService compServ = (CompositeService) target;
+ invoker = compServ.createTargetInvoker(targetWire.getServiceContract(), inboundChain.getOperation());
+ }
+
+ if (source instanceof Service && !(source instanceof CompositeService)) {
+ // services are a special case: invoker must go on the inbound chain
+ if (target instanceof Component && (isOneWayOperation || operationHasCallback)) {
+ // if the target is a component and the operation is non-blocking
+ connect(outboundChain, inboundChain, null, true);
+ } else {
+ connect(outboundChain, inboundChain, null, false);
+ }
+ Service service = (Service) source;
+ InboundInvocationChain chain = service.getInboundWire().getInvocationChains().get(operation);
+ chain.setTargetInvoker(invoker);
+ } else {
+ if (target instanceof Component && (isOneWayOperation || operationHasCallback)) {
+ // if the target is a component and the operation is non-blocking
+ connect(outboundChain, inboundChain, invoker, true);
+ } else {
+ connect(outboundChain, inboundChain, invoker, false);
+ }
+ }
+ }
+
+ // create source callback chains and connect them if target callback chains exist
+ Map<Operation<?>, OutboundInvocationChain> sourceCallbackChains =
+ targetWire.getSourceCallbackInvocationChains(source.getName());
+ for (InboundInvocationChain inboundChain : sourceWire.getTargetCallbackInvocationChains().values()) {
+ Operation<?> operation = inboundChain.getOperation();
+ if (sourceCallbackChains != null && sourceCallbackChains.get(operation) != null) {
+ String name = operation.getName();
+ BuilderConfigException e =
+ new BuilderConfigException("Source callback chain should not exist for operation [" + name + "]");
+ e.setIdentifier(sourceWire.getReferenceName());
+ throw e;
+ }
+
+ Operation targetOp =
+ (Operation)targetWire.getServiceContract().getCallbackOperations().get(operation.getName());
+ OutboundInvocationChain outboundChain = wireService.createOutboundChain(targetOp);
+ targetWire.addSourceCallbackInvocationChain(source.getName(), targetOp, outboundChain);
+ if (source instanceof Component) {
+ Component component = (Component) source;
+ TargetInvoker invoker = component.createTargetInvoker(null, operation);
+ connect(outboundChain, inboundChain, invoker, false);
+ } else if (source instanceof CompositeReference) {
+ CompositeReference compRef = (CompositeReference) source;
+ ServiceContract sourceContract = sourceWire.getServiceContract();
+ TargetInvoker invoker = compRef.createCallbackTargetInvoker(sourceContract, operation);
+ connect(outboundChain, inboundChain, invoker, false);
+ } else if (source instanceof Service) {
+ Service service = (Service) source;
+ ServiceContract sourceContract = sourceWire.getServiceContract();
+ TargetInvoker invoker = service.createCallbackTargetInvoker(sourceContract, operation);
+ connect(outboundChain, inboundChain, invoker, false);
+ }
+ }
+ if (postProcessorRegistry != null) {
+ // run wire post-processors
+ postProcessorRegistry.process(sourceWire, targetWire);
+ }
+ }
+
+ /**
+ * Connects a source to target chain
+ *
+ * @param sourceChain the source chain
+ * @param targetChain the target chain
+ * @param invoker the invoker to place on the source chain for dispatching invocations
+ * @param nonBlocking true if the operation is non-blocking
+ */
+ void connect(OutboundInvocationChain sourceChain,
+ InboundInvocationChain targetChain,
+ TargetInvoker invoker,
+ boolean nonBlocking) {
+ Interceptor head = targetChain.getHeadInterceptor();
+ if (head == null) {
+ BuilderConfigException e = new BuilderConfigException("No interceptor for operation");
+ e.setIdentifier(targetChain.getOperation().getName());
+ throw e;
+ }
+ if (nonBlocking) {
+ sourceChain.setTargetInterceptor(new NonBlockingBridgingInterceptor(scheduler, workContext, head));
+ } else {
+ sourceChain.setTargetInterceptor(new SynchronousBridgingInterceptor(head));
+ }
+ sourceChain.prepare(); //FIXME prepare should be moved out
+ sourceChain.setTargetInvoker(invoker);
+ }
+
+
+ /**
+ * Connects an inbound source chain to an outbound target chain
+ *
+ * @param sourceChain
+ * @param targetChain
+ */
+ void connect(InboundInvocationChain sourceChain, OutboundInvocationChain targetChain) {
+ // invocations from inbound to outbound chains are always syncrhonius as they occur in services and references
+ sourceChain.addInterceptor(new SynchronousBridgingInterceptor(targetChain.getHeadInterceptor()));
+ }
+
+ /**
+ * Connects an component's outbound wire to its target in a composite. Valid targets are either
+ * <code>AtomicComponent</code>s contained in the composite, or <code>References</code> of the composite.
+ *
+ * @param sourceWire
+ * @throws BuilderConfigException
+ */
+ private void connect(SCAObject source, OutboundWire sourceWire, SCAObject target) throws BuilderConfigException {
+ assert sourceWire.getTargetName() != null : "Wire target name was null";
+ QualifiedName targetName = sourceWire.getTargetName();
+
+ if (target instanceof AtomicComponent) {
+ AtomicComponent targetComponent = (AtomicComponent) target;
+ InboundWire targetWire = targetComponent.getInboundWire(targetName.getPortName());
+ if (targetWire == null) {
+ String refName = sourceWire.getReferenceName();
+ BuilderConfigException e = new BuilderConfigException("No target service for reference " + refName);
+ e.setIdentifier(targetName.getPortName());
+ throw e;
+ }
+ checkIfWireable(sourceWire, targetWire);
+ boolean optimizable = isOptimizable(source.getScope(), target.getScope());
+ connect(sourceWire, targetWire, optimizable);
+ } else if (target instanceof Reference) {
+ InboundWire targetWire = ((Reference) target).getInboundWire();
+ assert targetWire != null;
+ checkIfWireable(sourceWire, targetWire);
+ boolean optimizable = isOptimizable(source.getScope(), target.getScope());
+ connect(sourceWire, targetWire, optimizable);
+ } else if (target instanceof CompositeComponent) {
+ CompositeComponent composite = (CompositeComponent) target;
+ InboundWire targetWire = null;
+ if (source.isSystem()) {
+ for (Object child : composite.getSystemChildren()) {
+ if (child instanceof CompositeService) {
+ CompositeService compServ = (CompositeService) child;
+ targetWire = compServ.getInboundWire();
+ assert targetWire != null;
+ Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
+ Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
+ if (sourceInterface.isAssignableFrom(targetInterface)) {
+ target = compServ;
+ break;
+ } else {
+ targetWire = null;
+ }
+ }
+ }
+ } else {
+ for (Object child : composite.getChildren()) {
+ if (child instanceof CompositeService) {
+ CompositeService compServ = (CompositeService) child;
+ targetWire = compServ.getInboundWire();
+ assert targetWire != null;
+ Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
+ Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
+ if (sourceInterface.isAssignableFrom(targetInterface)) {
+ target = compServ;
+ break;
+ } else {
+ targetWire = null;
+ }
+ }
+ }
+ }
+ if (targetWire == null) {
+ throw new BuilderConfigException("No target composite service in composite");
+ }
+ boolean optimizable = isOptimizable(source.getScope(), target.getScope());
+ connect(sourceWire, targetWire, optimizable);
+ } else {
+ String name = sourceWire.getReferenceName();
+ BuilderConfigException e = new BuilderConfigException("Invalid target type for reference " + name);
+ e.setIdentifier(targetName.getQualifiedName());
+ throw e;
+ }
+ }
+
+ private void checkIfWireable(OutboundWire sourceWire, InboundWire targetWire) {
+ if (wireService == null) {
+ Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
+ Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
+ if (!sourceInterface.isAssignableFrom(targetInterface)) {
+ throw new BuilderConfigException("Incompatible source and target interfaces");
+ }
+ } else {
+ try {
+ wireService.checkCompatibility(sourceWire.getServiceContract(), targetWire
+ .getServiceContract(), false);
+ } catch (IncompatibleServiceContractException e) {
+ throw new BuilderConfigException("Incompatible source and target interfaces", e);
+ }
+ }
+ }
+
+ private boolean isOptimizable(Scope pReferrer, Scope pReferee) {
+ if (pReferrer == Scope.UNDEFINED || pReferee == Scope.UNDEFINED) {
+ return false;
+ }
+ if (pReferee == pReferrer) {
+ return true;
+ } else if (pReferrer == Scope.STATELESS) {
+ return true;
+ } else if (pReferee == Scope.STATELESS) {
+ return true;
+ } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SESSION) {
+ return true;
+ } else if (pReferrer == Scope.REQUEST && pReferee == Scope.MODULE) {
+ return true;
+ } else if (pReferrer == Scope.REQUEST && pReferee == Scope.COMPOSITE) {
+ return true;
+ } else if (pReferrer == Scope.SESSION && pReferee == Scope.MODULE) {
+ return true;
+ } else if (pReferrer == Scope.SESSION && pReferee == Scope.COMPOSITE) {
+ return true;
+ } else if (pReferrer == Scope.COMPOSITE && pReferee == Scope.MODULE) {
+ // case where a service context points to a module scoped component
+ return true;
+ } else {
+ return pReferrer == Scope.MODULE && pReferee == Scope.COMPOSITE;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
new file mode 100644
index 0000000000..c1aeb62079
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.builder.WirePostProcessor;
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * The default implementation of a <code>WirePostProcessor</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class WirePostProcessorRegistryImpl implements WirePostProcessorRegistry {
+
+ private final List<WirePostProcessor> processors = new ArrayList<WirePostProcessor>();
+
+ public void process(OutboundWire source, InboundWire target) {
+ for (WirePostProcessor processor : processors) {
+ processor.process(source, target);
+ }
+ }
+
+ public void process(InboundWire source, OutboundWire target) {
+ for (WirePostProcessor processor : processors) {
+ processor.process(source, target);
+ }
+ }
+
+ public void register(WirePostProcessor processor) {
+ processors.add(processor);
+ }
+
+ public void unregister(WirePostProcessor processor) {
+ processors.remove(processor);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ComponentInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ComponentInitException.java
new file mode 100644
index 0000000000..e1ad3a6fea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ComponentInitException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component;
+
+import org.apache.tuscany.spi.component.ComponentRuntimeException;
+
+/**
+ * Denotes an error initializing a component
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ComponentInitException extends ComponentRuntimeException {
+ public ComponentInitException() {
+ }
+
+ public ComponentInitException(String message) {
+ super(message);
+ }
+
+ public ComponentInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComponentInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java
new file mode 100644
index 0000000000..35125b85ef
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component;
+
+/**
+ * Implementations enable lazy retrieval of a scope id associated with a request, i.e. an id (and presumably a context)
+ * do not have to be generated if the scope is never accessed. Identifiers are associated with the current request
+ * thread and keyed on scope type.
+ *
+ * @version $Rev$ $Date$
+ * @see org.apache.tuscany.spi.component.WorkContext
+ */
+public interface ScopeIdentifier {
+
+ /**
+ * Returns the scope id for the request.
+ */
+ Object getIdentifier();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java
new file mode 100644
index 0000000000..0b0a48cb99
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+/**
+ * An implementation of an {@link org.apache.tuscany.spi.component.WorkContext} that handles event-to-thread
+ * associations using an <code>InheritableThreadLocal</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class WorkContextImpl implements WorkContext {
+
+ private static final Object REMOTE_CONTEXT = new Object();
+ private static final Object MESSAGE_ID = new Object();
+ private static final Object CORRELATION_ID = new Object();
+
+ // TODO implement propagation strategy for creating new threads
+
+ //A map ( associated with the current thread) of scope identifiers keyed on the event context id type.
+ //The scope identifier may be a {@link ScopeIdentifier} or an opaque id
+
+ // [rfeng] We cannot use InheritableThreadLocal for message ids here since it's shared by parent and children
+ private ThreadLocal<Map<Object, Object>> workContext = new ThreadLocal<Map<Object, Object>>();
+
+ // [rfeng] Session id requires InheritableThreadLocal
+ private ThreadLocal<Map<Object, Object>> inheritableContext = new InheritableThreadLocal<Map<Object, Object>>();
+
+ public WorkContextImpl() {
+ super();
+ }
+
+ public Object getCurrentMessageId() {
+ Map<Object, Object> map = workContext.get();
+ if (map == null) {
+ return null;
+ }
+ return map.get(MESSAGE_ID);
+ }
+
+ public void setCurrentMessageId(Object messageId) {
+ Map<Object, Object> map = workContext.get();
+ if (map == null) {
+ map = new HashMap<Object, Object>();
+ workContext.set(map);
+ }
+ map.put(MESSAGE_ID, messageId);
+ }
+
+ public Object getCurrentCorrelationId() {
+ Map<Object, Object> map = workContext.get();
+ if (map == null) {
+ return null;
+ }
+ return map.get(CORRELATION_ID);
+ }
+
+ public void setCurrentCorrelationId(Object correlationId) {
+ Map<Object, Object> map = workContext.get();
+ if (map == null) {
+ map = new HashMap<Object, Object>();
+ workContext.set(map);
+ }
+ map.put(CORRELATION_ID, correlationId);
+ }
+
+ public CompositeComponent getRemoteComponent() {
+ Map<Object, Object> map = workContext.get();
+ if (map == null) {
+ return null;
+ }
+ return (CompositeComponent) map.get(REMOTE_CONTEXT);
+ }
+
+
+ public void setRemoteComponent(CompositeComponent component) {
+ Map<Object, Object> map = workContext.get();
+ if (map == null) {
+ map = new HashMap<Object, Object>();
+ workContext.set(map);
+ }
+ map.put(REMOTE_CONTEXT, component);
+ }
+
+ public Object getIdentifier(Object type) {
+ Map<Object, Object> map = inheritableContext.get();
+ if (map == null) {
+ return null;
+ }
+ Object currentId = map.get(type);
+ if (currentId instanceof ScopeIdentifier) {
+ currentId = ((ScopeIdentifier) currentId).getIdentifier();
+ // once we have accessed the id, replace the lazy wrapper
+ map.put(type, currentId);
+ }
+ return currentId;
+ }
+
+ public void setIdentifier(Object type, Object identifier) {
+ Map<Object, Object> map = inheritableContext.get();
+ if (map == null) {
+ map = new HashMap<Object, Object>();
+ inheritableContext.set(map);
+ }
+ map.put(type, identifier);
+ }
+
+ public void clearIdentifier(Object type) {
+ if (type == null) {
+ return;
+ }
+ Map map = inheritableContext.get();
+ if (map != null) {
+ map.remove(type);
+ }
+ }
+
+ public void clearIdentifiers() {
+ inheritableContext.remove();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java
new file mode 100644
index 0000000000..6df5b67dea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+import org.apache.tuscany.spi.event.Event;
+
+/**
+ * A basic implementation of a runtime event
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class AbstractEvent implements Event {
+
+ protected transient Object source;
+
+ public AbstractEvent(Object source) {
+ assert source != null : "Source id was null";
+ this.source = source;
+ }
+
+ public Object getSource() {
+ return source;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java
new file mode 100644
index 0000000000..762b917600
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Base implementation of a request event
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class AbstractRequestEvent extends AbstractEvent implements RequestEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ */
+ public AbstractRequestEvent(Object source) {
+ super(source);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java
new file mode 100644
index 0000000000..ce058404da
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.event.Event;
+
+/**
+ * Implemented by runtime events associated with a composite, e.g. lifecycle events
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface CompositeEvent extends Event {
+
+ CompositeComponent getComposite();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java
new file mode 100644
index 0000000000..9920a2febf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+/**
+ * Propagated when a composite starts
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class CompositeStart extends AbstractEvent implements CompositeEvent {
+
+ private CompositeComponent component;
+
+ /**
+ * Creates a module stop event
+ *
+ * @param source the source of the event
+ * @param component the composite component associated the module being stopped
+ */
+ public CompositeStart(Object source, CompositeComponent component) {
+ super(source);
+ this.component = component;
+ }
+
+ public CompositeComponent getComposite() {
+ return component;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java
new file mode 100644
index 0000000000..58be209783
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+/**
+ * Propagated when a composite stops
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class CompositeStop extends AbstractEvent implements CompositeEvent {
+
+ private CompositeComponent component;
+
+ /**
+ * Creates a module stop event
+ *
+ * @param source the source of the event
+ * @param component the composite component associated the module being stopped
+ */
+ public CompositeStop(Object source, CompositeComponent component) {
+ super(source);
+ this.component = component;
+ }
+
+ public CompositeComponent getComposite() {
+ return component;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java
new file mode 100644
index 0000000000..01bd769031
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Propagated when an HTTP-based request has ended.
+ *
+ * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$
+ */
+public class HttpRequestEnded extends HttpSessionEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the HTTP session being ended
+ */
+ public HttpRequestEnded(Object source, Object id) {
+ super(source, id);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java
new file mode 100644
index 0000000000..9d0ff80dd7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Propagated when an HTTP-based request has started
+ *
+ * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$
+ */
+public class HttpRequestStart extends HttpSessionEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the HTTP session being ended
+ */
+ public HttpRequestStart(Object source, Object id) {
+ super(source, id);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java
new file mode 100644
index 0000000000..7f2bebe94a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Propagated when an HTTP-based session is expired
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class HttpSessionEnd extends HttpSessionEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the HTTP session being ended
+ */
+ public HttpSessionEnd(Object source, Object id) {
+ super(source, id);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java
new file mode 100644
index 0000000000..ed245d0930
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * A base implementation of HTTP-based session events in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class HttpSessionEvent extends AbstractEvent {
+
+ private Object id;
+
+ public HttpSessionEvent(Object source, Object id) {
+ super(source);
+ assert id != null : "Session id was null";
+ this.id = id;
+ }
+
+
+ public Object getSource() {
+ return source;
+ }
+
+ public Object getId() {
+ return id;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java
new file mode 100644
index 0000000000..7f9c0fadea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Propagated when an HTTP-based session has started
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class HttpSessionStart extends HttpSessionEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ * @param id the id of the HTTP session being ended
+ */
+ public HttpSessionStart(Object source, Object id) {
+ super(source, id);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java
new file mode 100644
index 0000000000..25856e86f8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Propagated when a request completes or is ended
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class RequestEnd extends AbstractRequestEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ */
+ public RequestEnd(Object source) {
+ super(source);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java
new file mode 100644
index 0000000000..9a6d767236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Implemented by runtime events associated request
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface RequestEvent {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java
new file mode 100644
index 0000000000..466f52551a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+/**
+ * Propagated when a request is started in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class RequestStart extends AbstractRequestEvent {
+
+ /**
+ * Creates a new event
+ *
+ * @param source the source of the event
+ */
+ public RequestStart(Object source) {
+ super(source);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java
new file mode 100644
index 0000000000..50b0f927d8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.spi.AbstractLifecycle;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.TrueFilter;
+
+/**
+ * Implements functionality common to scope contexts.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractScopeContainer extends AbstractLifecycle implements ScopeContainer {
+ private static final EventFilter TRUE_FILTER = new TrueFilter();
+
+ // The event context the scope container is associated with
+ protected WorkContext workContext;
+ private final String name;
+ private Map<EventFilter, List<RuntimeEventListener>> listeners;
+
+ public AbstractScopeContainer(String name, WorkContext workContext) {
+ this.name = name;
+ this.workContext = workContext;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ public void addListener(RuntimeEventListener listener) {
+ addListener(TRUE_FILTER, listener);
+ }
+
+ public void removeListener(RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ for (List<RuntimeEventListener> currentList : getListeners().values()) {
+ for (RuntimeEventListener current : currentList) {
+ if (current == listener) {
+ currentList.remove(current);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ List<RuntimeEventListener> list = getListeners().get(filter);
+ if (list == null) {
+ list = new CopyOnWriteArrayList<RuntimeEventListener>();
+ listeners.put(filter, list);
+ }
+ list.add(listener);
+ }
+ }
+
+ public void publish(Event event) {
+ assert event != null : "Event object was null";
+ for (Map.Entry<EventFilter, List<RuntimeEventListener>> entry : getListeners().entrySet()) {
+ if (entry.getKey().match(event)) {
+ for (RuntimeEventListener listener : entry.getValue()) {
+ listener.onEvent(event);
+ }
+ }
+ }
+ }
+
+ public Object getInstance(AtomicComponent component) throws TargetException {
+ InstanceWrapper ctx = getInstanceWrapper(component);
+ if (ctx != null) {
+ if (ctx.getLifecycleState() == UNINITIALIZED) {
+ ctx.start();
+ }
+ return ctx.getInstance();
+ }
+ return null;
+ }
+
+ protected Map<EventFilter, List<RuntimeEventListener>> getListeners() {
+ if (listeners == null) {
+ listeners = new ConcurrentHashMap<EventFilter, List<RuntimeEventListener>>();
+ }
+ return listeners;
+ }
+
+ protected void checkInit() {
+ if (getLifecycleState() != RUNNING) {
+ throw new IllegalStateException("Scope not running [" + getLifecycleState() + "]");
+ }
+ }
+
+ protected WorkContext getWorkContext() {
+ return workContext;
+ }
+
+ public String toString() {
+ return "ScopeContainer [" + name + "] in state [" + super.toString() + ']';
+ }
+
+ protected abstract InstanceWrapper getInstanceWrapper(AtomicComponent component);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java
new file mode 100644
index 0000000000..ae197c3504
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Scope;
+
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+
+/**
+ * A scope context which manages atomic component instances keyed on HTTP session
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpSessionScopeContainer extends AbstractScopeContainer {
+
+ public static final Object HTTP_IDENTIFIER = new Object();
+
+ private final Map<AtomicComponent, Map<Object, InstanceWrapper>> contexts;
+ private final Map<Object, List<InstanceWrapper>> destroyQueues;
+
+ public HttpSessionScopeContainer() {
+ this(null);
+ }
+
+ public HttpSessionScopeContainer(WorkContext workContext) {
+ super("Session Scope", workContext);
+ contexts = new ConcurrentHashMap<AtomicComponent, Map<Object, InstanceWrapper>>();
+ destroyQueues = new ConcurrentHashMap<Object, List<InstanceWrapper>>();
+ }
+
+ public Scope getScope() {
+ return Scope.SESSION;
+ }
+
+ public void onEvent(Event event) {
+ checkInit();
+ if (event instanceof HttpSessionStart) {
+ Object key = ((HttpSessionStart) event).getId();
+ workContext.setIdentifier(HTTP_IDENTIFIER, key);
+ for (Map.Entry<AtomicComponent, Map<Object, InstanceWrapper>> entry : contexts.entrySet()) {
+ if (entry.getKey().isEagerInit()) {
+
+ getInstance(entry.getKey(), key);
+ }
+ }
+ } else if (event instanceof HttpSessionEnd) {
+ Object key = ((HttpSessionEnd) event).getId();
+ shutdownInstances(key);
+ workContext.clearIdentifier(key);
+ }
+ }
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
+ }
+ lifecycleState = RUNNING;
+ }
+
+ public synchronized void stop() {
+ contexts.clear();
+ synchronized (destroyQueues) {
+ destroyQueues.clear();
+ }
+ lifecycleState = STOPPED;
+ }
+
+ public void register(AtomicComponent component) {
+ contexts.put(component, new ConcurrentHashMap<Object, InstanceWrapper>());
+ component.addListener(this);
+
+ }
+
+ protected InstanceWrapper getInstanceWrapper(AtomicComponent component) throws TargetException {
+ Object key = workContext.getIdentifier(HTTP_IDENTIFIER);
+ assert key != null : "HTTP session key not bound in work component";
+ return getInstance(component, key);
+ }
+
+ private InstanceWrapper getInstance(AtomicComponent component, Object key) {
+ Map<Object, InstanceWrapper> wrappers = contexts.get(component);
+ InstanceWrapper ctx = wrappers.get(key);
+ if (ctx == null) {
+ ctx = new InstanceWrapperImpl(component, component.createInstance());
+ ctx.start();
+ wrappers.put(key, ctx);
+ List<InstanceWrapper> destroyQueue = destroyQueues.get(key);
+ if (destroyQueue == null) {
+ destroyQueue = new ArrayList<InstanceWrapper>();
+ destroyQueues.put(key, destroyQueue);
+ }
+ synchronized (destroyQueue) {
+ destroyQueue.add(ctx);
+ }
+ }
+ return ctx;
+
+ }
+
+ private void shutdownInstances(Object key) {
+ List<InstanceWrapper> destroyQueue = destroyQueues.remove(key);
+ if (destroyQueue != null) {
+ for (Map<Object, InstanceWrapper> map : contexts.values()) {
+ map.remove(key);
+ }
+ ListIterator<InstanceWrapper> iter = destroyQueue.listIterator(destroyQueue.size());
+ synchronized (destroyQueue) {
+ while (iter.hasPrevious()) {
+ try {
+ iter.previous().stop();
+ } catch (TargetException e) {
+ // TODO send a monitoring event
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java
new file mode 100644
index 0000000000..6901c429f1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.model.Scope;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Creates a new HTTP session scope context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class HttpSessionScopeObjectFactory implements ObjectFactory<HttpSessionScopeContainer> {
+
+ public HttpSessionScopeObjectFactory(@Autowire ScopeRegistry registry) {
+ registry.registerFactory(Scope.SESSION, this);
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+
+ public HttpSessionScopeContainer getInstance() throws ObjectCreationException {
+ return new HttpSessionScopeContainer();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java
new file mode 100644
index 0000000000..88fbcd2c7c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.Lifecycle;
+
+/**
+ * Provides lifecycle management for an implementation instance associated with an {@link
+ * org.apache.tuscany.spi.component.AtomicComponent} for use by the atomic context's associated {@link
+ * org.apache.tuscany.spi.component.ScopeContainer}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InstanceWrapper extends Lifecycle {
+
+ Object getInstance();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java
new file mode 100644
index 0000000000..f8c1b6490f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.AbstractLifecycle;
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+
+/**
+ * Default implementation of an <code>InstanceWrapper</code>
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class InstanceWrapperImpl extends AbstractLifecycle implements InstanceWrapper {
+
+ private Object instance;
+ private AtomicComponent component;
+
+ public InstanceWrapperImpl(AtomicComponent component, Object instance) {
+ assert component != null;
+ assert instance != null;
+ this.component = component;
+ this.instance = instance;
+ }
+
+ public Object getInstance() {
+ checkInit();
+ return instance;
+ }
+
+ public void start() throws CoreRuntimeException {
+ try {
+ component.init(instance);
+ lifecycleState = RUNNING;
+ } catch (RuntimeException e) {
+ lifecycleState = ERROR;
+ throw e;
+ }
+ }
+
+ public void stop() throws CoreRuntimeException {
+ checkInit();
+ component.destroy(instance);
+ }
+
+ protected void checkInit() {
+ if (getLifecycleState() != RUNNING) {
+ throw new IllegalStateException("Scope not running [" + getLifecycleState() + "]");
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java
new file mode 100644
index 0000000000..6458b9f12a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeContainer.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.spi.AbstractLifecycle;
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Scope;
+
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+
+/**
+ * A scope context which manages atomic component instances keyed by module
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeContainer extends AbstractScopeContainer {
+
+ private static final InstanceWrapper EMPTY = new EmptyWrapper();
+ private static final ComponentInitComparator COMPARATOR = new ComponentInitComparator();
+
+ private final Map<AtomicComponent, InstanceWrapper> instanceWrappers;
+
+ // the queue of instanceWrappers to destroy, in the order that their instances were created
+ private final List<InstanceWrapper> destroyQueue;
+
+ public ModuleScopeContainer() {
+ this(null);
+ }
+
+ public ModuleScopeContainer(WorkContext workContext) {
+ super("Module Scope", workContext);
+ instanceWrappers = new ConcurrentHashMap<AtomicComponent, InstanceWrapper>();
+ destroyQueue = new ArrayList<InstanceWrapper>();
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public void onEvent(Event event) {
+ checkInit();
+ if (event instanceof CompositeStart) {
+ eagerInitComponents();
+ lifecycleState = RUNNING;
+ } else if (event instanceof CompositeStop) {
+ shutdownContexts();
+ }
+ }
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
+ }
+ lifecycleState = RUNNING;
+ }
+
+ public synchronized void stop() {
+ checkInit();
+ instanceWrappers.clear();
+ synchronized (destroyQueue) {
+ destroyQueue.clear();
+ }
+ lifecycleState = STOPPED;
+ }
+
+ /**
+ * Notifies instanceWrappers of a shutdown in reverse order to which they were started
+ */
+ private void shutdownContexts() {
+ if (destroyQueue.size() == 0) {
+ return;
+ }
+ synchronized (destroyQueue) {
+ // shutdown destroyable instances in reverse instantiation order
+ ListIterator<InstanceWrapper> iter = destroyQueue.listIterator(destroyQueue.size());
+ while (iter.hasPrevious()) {
+ iter.previous().stop();
+ }
+ destroyQueue.clear();
+ }
+ }
+
+ public void register(AtomicComponent component) {
+ checkInit();
+ instanceWrappers.put(component, EMPTY);
+ }
+
+ protected InstanceWrapper getInstanceWrapper(AtomicComponent component) throws TargetException {
+ checkInit();
+ InstanceWrapper ctx = instanceWrappers.get(component);
+ assert ctx != null : "Component not registered with scope: " + component;
+ if (ctx == EMPTY) {
+ ctx = new InstanceWrapperImpl(component, component.createInstance());
+ ctx.start();
+ instanceWrappers.put(component, ctx);
+ synchronized (destroyQueue) {
+ destroyQueue.add(ctx);
+ }
+ }
+ return ctx;
+ }
+
+ private void eagerInitComponents() throws CoreRuntimeException {
+ List<AtomicComponent> componentList = new ArrayList<AtomicComponent>(instanceWrappers.keySet());
+ Collections.sort(componentList, COMPARATOR);
+ // start each group
+ for (AtomicComponent component : componentList) {
+ if (component.getInitLevel() <= 0) {
+ // Don't eagerly init
+ continue;
+ }
+ // the instance could have been created from a depth-first traversal
+ InstanceWrapper ctx = instanceWrappers.get(component);
+ if (ctx == EMPTY) {
+ ctx = new InstanceWrapperImpl(component, component.createInstance());
+ ctx.start();
+ instanceWrappers.put(component, ctx);
+ destroyQueue.add(ctx);
+ }
+ }
+ }
+
+ private static class ComponentInitComparator implements Comparator<AtomicComponent> {
+ public int compare(AtomicComponent o1, AtomicComponent o2) {
+ return o1.getInitLevel() - o2.getInitLevel();
+ }
+ }
+
+ private static class EmptyWrapper extends AbstractLifecycle implements InstanceWrapper {
+ public Object getInstance() {
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactory.java
new file mode 100644
index 0000000000..c73edbfda6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactory.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Creates a new module scope context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ModuleScopeObjectFactory implements ObjectFactory<ModuleScopeContainer> {
+
+ public ModuleScopeObjectFactory(@Autowire ScopeRegistry registry) {
+ registry.registerFactory(Scope.MODULE, this);
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public ModuleScopeContainer getInstance() throws ObjectCreationException {
+ return new ModuleScopeContainer();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java
new file mode 100644
index 0000000000..23ab4b4100
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Scope;
+
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+
+/**
+ * A scope context which manages atomic component instances keyed on the current request context
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeContainer extends AbstractScopeContainer {
+
+ private final Map<AtomicComponent, Map<Thread, InstanceWrapper>> contexts;
+ private final Map<Thread, List<InstanceWrapper>> destroyQueues;
+
+ public RequestScopeContainer() {
+ this(null);
+ }
+
+ public RequestScopeContainer(WorkContext workContext) {
+ super("Request Scope", workContext);
+ contexts = new ConcurrentHashMap<AtomicComponent, Map<Thread, InstanceWrapper>>();
+ destroyQueues = new ConcurrentHashMap<Thread, List<InstanceWrapper>>();
+ }
+
+ public Scope getScope() {
+ return Scope.REQUEST;
+ }
+
+ public void onEvent(Event event) {
+ checkInit();
+ if (event instanceof RequestStart) {
+ for (Map.Entry<AtomicComponent, Map<Thread, InstanceWrapper>> entry : contexts.entrySet()) {
+ if (entry.getKey().isEagerInit()) {
+ getInstance(entry.getKey());
+ }
+ }
+ } else if (event instanceof RequestEnd) {
+ shutdownInstances(Thread.currentThread());
+ }
+ }
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
+ }
+ lifecycleState = RUNNING;
+ }
+
+ public synchronized void stop() {
+ contexts.clear();
+ synchronized (destroyQueues) {
+ destroyQueues.clear();
+ }
+ lifecycleState = STOPPED;
+ }
+
+ public void register(AtomicComponent component) {
+ contexts.put(component, new ConcurrentHashMap<Thread, InstanceWrapper>());
+ }
+
+ protected InstanceWrapper getInstanceWrapper(AtomicComponent component) throws TargetException {
+ Map<Thread, InstanceWrapper> instanceContextMap = contexts.get(component);
+ assert instanceContextMap != null : "Atomic component not registered";
+ InstanceWrapper ctx = instanceContextMap.get(Thread.currentThread());
+ if (ctx == null) {
+ ctx = new InstanceWrapperImpl(component, component.createInstance());
+ ctx.start();
+ instanceContextMap.put(Thread.currentThread(), ctx);
+ List<InstanceWrapper> destroyQueue = destroyQueues.get(Thread.currentThread());
+ if (destroyQueue == null) {
+ destroyQueue = new ArrayList<InstanceWrapper>();
+ destroyQueues.put(Thread.currentThread(), destroyQueue);
+ }
+ synchronized (destroyQueue) {
+ destroyQueue.add(ctx);
+ }
+ }
+ return ctx;
+ }
+
+ private void shutdownInstances(Thread key) {
+ List<InstanceWrapper> destroyQueue = destroyQueues.remove(key);
+ if (destroyQueue != null && destroyQueue.size() > 0) {
+ Thread thread = Thread.currentThread();
+ for (Map<Thread, InstanceWrapper> map : contexts.values()) {
+ map.remove(thread);
+ }
+ ListIterator<InstanceWrapper> iter = destroyQueue.listIterator(destroyQueue.size());
+ synchronized (destroyQueue) {
+ while (iter.hasPrevious()) {
+ try {
+ iter.previous().stop();
+ } catch (TargetException e) {
+ // TODO send a monitoring event
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java
new file mode 100644
index 0000000000..727e76e340
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Creates a new request scope context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class RequestScopeObjectFactory implements ObjectFactory<RequestScopeContainer> {
+
+ public RequestScopeContainer getInstance() throws ObjectCreationException {
+ return new RequestScopeContainer();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
new file mode 100644
index 0000000000..91faf3e777
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeNotFoundException;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * The default implementation of a scope registry
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeRegistryImpl implements ScopeRegistry {
+
+ private final Map<Scope, ScopeContainer> scopeCache =
+ new ConcurrentHashMap<Scope, ScopeContainer>();
+ private final Map<Scope, ObjectFactory<? extends ScopeContainer>> factoryCache =
+ new ConcurrentHashMap<Scope, ObjectFactory<? extends ScopeContainer>>();
+ private WorkContext workContext;
+
+ public ScopeRegistryImpl(WorkContext workContext) {
+ assert workContext != null;
+ this.workContext = workContext;
+ }
+
+ // TODO remove and replace with CDI
+ public ScopeRegistryImpl() {
+ }
+
+ @Autowire
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ public ScopeContainer getScopeContainer(Scope scope) {
+ assert Scope.MODULE != scope : "Cannot get MODULE scope from the registry";
+ ScopeContainer container = scopeCache.get(scope);
+ if (container == null) {
+ ObjectFactory<? extends ScopeContainer> factory = factoryCache.get(scope);
+ if (factory == null) {
+ ScopeNotFoundException e = new ScopeNotFoundException("Scope object factory not registered for scope");
+ e.setIdentifier(scope.getScope());
+
+ throw e;
+ }
+ container = factory.getInstance();
+ container.setWorkContext(workContext);
+ container.start();
+ scopeCache.put(scope, container);
+ }
+ return container;
+ }
+
+ public <T extends ScopeContainer> void registerFactory(Scope scope, ObjectFactory<T> factory) {
+ factoryCache.put(scope, factory);
+ }
+
+ public void deregisterFactory(Scope scope) {
+ factoryCache.remove(scope);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java
new file mode 100644
index 0000000000..edc3b69241
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * A scope context which manages stateless atomic component instances in a non-pooled fashion
+ *
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeContainer extends AbstractScopeContainer {
+
+ public StatelessScopeContainer() {
+ this(null);
+ }
+
+ public StatelessScopeContainer(WorkContext workContext) {
+ super("Stateless scope", workContext);
+ }
+
+ public Scope getScope() {
+ return Scope.STATELESS;
+ }
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
+ }
+ lifecycleState = RUNNING;
+ }
+
+ public synchronized void stop() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
+ }
+ lifecycleState = STOPPED;
+ }
+
+ public void onEvent(Event event) {
+ }
+
+ public void register(AtomicComponent component) {
+ checkInit();
+ }
+
+ protected InstanceWrapper getInstanceWrapper(AtomicComponent component) throws TargetException {
+ InstanceWrapper ctx = new InstanceWrapperImpl(component, component.createInstance());
+ ctx.start();
+ return ctx;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java
new file mode 100644
index 0000000000..446f57b11a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Creates a new stateless scope context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class StatelessScopeObjectFactory implements ObjectFactory<StatelessScopeContainer> {
+
+ public StatelessScopeObjectFactory(@Autowire ScopeRegistry registry) {
+ registry.registerFactory(Scope.STATELESS, this);
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public StatelessScopeContainer getInstance() throws ObjectCreationException {
+ return new StatelessScopeContainer();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java
new file mode 100644
index 0000000000..d7627d11b1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+
+/**
+ * An interceptor to transform data accross databindings on the wire
+ */
+public class DataBindingInteceptor implements Interceptor {
+ private Interceptor next;
+
+ private CompositeComponent compositeComponent;
+
+ private Operation<?> sourceOperation;
+
+ private Operation<?> targetOperation;
+
+ private Mediator mediator;
+
+ public DataBindingInteceptor(RuntimeWire sourceWire, Operation<?> sourceOperation, RuntimeWire targetWire,
+ Operation<?> targetOperation) {
+ super();
+ // this.sourceWire = sourceWire;
+ this.sourceOperation = sourceOperation;
+ // this.targetWire = targetWire;
+ this.targetOperation = targetOperation;
+ this.compositeComponent = (CompositeComponent) sourceWire.getContainer().getParent();
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.wire.Interceptor#getNext()
+ */
+ public Interceptor getNext() {
+ return next;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.wire.Interceptor#invoke(org.apache.tuscany.spi.wire.Message)
+ */
+ public Message invoke(Message msg) {
+ Object input = transform(msg.getBody(), sourceOperation.getInputType(), targetOperation.getInputType());
+ msg.setBody(input);
+ Message resultMsg = next.invoke(msg);
+ Object result = resultMsg.getBody();
+ // FIXME: How to deal with faults?
+ if (resultMsg.isFault()) {
+ // We need to figure out what fault type it is and then transform it back the source fault type
+ throw new InvocationRuntimeException((Throwable) result);
+ } else if (result != null) {
+ // FIXME: Should we fix the Operation model so that getOutputType returns DataType<DataType<T>>?
+ DataType<DataType> targetType =
+ new DataType<DataType>("idl:output", Object.class, targetOperation.getOutputType());
+
+ targetType.setMetadata(Operation.class.getName(), targetOperation.getOutputType().getMetadata(
+ Operation.class.getName()));
+ DataType<DataType> sourceType =
+ new DataType<DataType>("idl:output", Object.class, sourceOperation.getOutputType());
+ sourceType.setMetadata(Operation.class.getName(), sourceOperation.getOutputType().getMetadata(
+ Operation.class.getName()));
+
+ result = transform(result, targetType, sourceType);
+ resultMsg.setBody(result);
+ }
+ return resultMsg;
+ }
+
+ private Object transform(Object source, DataType sourceType, DataType targetType) {
+ if (source == null) {
+ // Shortcut for null value
+ return null;
+ }
+ if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+ return source;
+ }
+ Map<Class<?>, Object> metadata = new HashMap<Class<?>, Object>();
+ metadata.put(CompositeComponent.class, compositeComponent);
+ return mediator.mediate(source, sourceType, targetType, metadata);
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.wire.Interceptor#isOptimizable()
+ */
+ public boolean isOptimizable() {
+ return false;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.wire.Interceptor#setNext(org.apache.tuscany.spi.wire.Interceptor)
+ */
+ public void setNext(Interceptor next) {
+ this.next = next;
+ }
+
+ /**
+ * @param mediator the mediator to set
+ */
+ public void setMediator(Mediator mediator) {
+ this.mediator = mediator;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java
new file mode 100644
index 0000000000..9e4b4abfed
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.tuscany.api.annotation.DataContext;
+import org.apache.tuscany.api.annotation.DataType;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorExtension;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * The databinding annotation processor for java interfaces
+ */
+public class DataBindingJavaInterfaceProcessor extends JavaInterfaceProcessorExtension {
+
+ private static final String SIMPLE_JAVA_OBJECTS = "java.lang.Object";
+
+ private static final Class[] SIMPLE_JAVA_TYPES =
+ {Byte.class, Character.class, Short.class, Integer.class, Long.class, Float.class, Double.class,
+ Date.class, Calendar.class, GregorianCalendar.class, Duration.class, XMLGregorianCalendar.class};
+
+ private static final Set<Class> SIMPLE_TYPE_SET = new HashSet<Class>(Arrays.asList(SIMPLE_JAVA_TYPES));
+
+ public void visitInterface(Class<?> clazz, Class<?> callbackClass, JavaServiceContract contract)
+ throws InvalidServiceContractException {
+ Map<String, Operation<Type>> operations = contract.getOperations();
+ processInterface(clazz, contract, operations);
+ if (callbackClass != null) {
+ Map<String, Operation<Type>> callbackOperations = contract.getCallbackOperations();
+ processInterface(callbackClass, contract, callbackOperations);
+ }
+ }
+
+ private void processInterface(Class<?> clazz,
+ JavaServiceContract contract,
+ Map<String, Operation<Type>> operations) {
+ DataType interfaceDataType = clazz.getAnnotation(DataType.class);
+ if (interfaceDataType != null) {
+ contract.setDataBinding(interfaceDataType.name());
+ // FIXME: [rfeng] Keep data context as metadata?
+ for (DataContext c : interfaceDataType.context()) {
+ contract.setMetaData(c.key(), c.value());
+ }
+ }
+ for (Method method : clazz.getMethods()) {
+ Operation<?> operation = operations.get(method.getName());
+ DataType operationDataType = method.getAnnotation(DataType.class);
+
+ if (operationDataType != null) {
+ operation.setDataBinding(operationDataType.name());
+ // FIXME: [rfeng] Keep data context as metadata?
+ for (DataContext c : operationDataType.context()) {
+ operation.setMetaData(c.key(), c.value());
+ }
+ }
+
+ String dataBinding = operation.getDataBinding();
+
+ // FIXME: We need a better way to identify simple java types
+ for (org.apache.tuscany.spi.model.DataType<?> d : operation.getInputType().getLogical()) {
+ adjustSimpleType(d, dataBinding);
+ }
+ if (operation.getOutputType() != null) {
+ adjustSimpleType(operation.getOutputType(), dataBinding);
+ }
+ for (org.apache.tuscany.spi.model.DataType<?> d : operation.getFaultTypes()) {
+ adjustSimpleType(d, dataBinding);
+ }
+ }
+ }
+
+ private void adjustSimpleType(org.apache.tuscany.spi.model.DataType<?> dataType, String dataBinding) {
+ Type type = dataType.getPhysical();
+ if (!(type instanceof Class)) {
+ return;
+ }
+ Class cls = (Class)dataType.getPhysical();
+ if (cls.isPrimitive() || SIMPLE_TYPE_SET.contains(cls)) {
+ dataType.setDataBinding(SIMPLE_JAVA_OBJECTS);
+ } else if (cls == String.class && (dataBinding == null || !dataBinding.equals(String.class.getName()))) {
+ // Identify the String as a simple type
+ dataType.setDataBinding(SIMPLE_JAVA_OBJECTS);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java
new file mode 100644
index 0000000000..f2ff257e7e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * The default implementation of a data binding registry
+ */
+public class DataBindingRegistryImpl implements DataBindingRegistry {
+ private final Map<String, DataBinding> bindings = new HashMap<String, DataBinding>();
+
+ public DataBinding getDataBinding(String id) {
+ if (id == null) {
+ return null;
+ }
+ return bindings.get(id.toLowerCase());
+ }
+
+ public void register(DataBinding dataBinding) {
+ bindings.put(dataBinding.getName().toLowerCase(), dataBinding);
+ }
+
+ public DataBinding unregister(String id) {
+ if (id == null) {
+ return null;
+ }
+ return bindings.remove(id.toLowerCase());
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public DataType introspectType(Class<?> javaType) {
+ DataType dataType = null;
+ for (DataBinding binding : bindings.values()) {
+ dataType = binding.introspect(javaType);
+ if (dataType != null) {
+ return dataType;
+ }
+ }
+ return null;
+ }
+
+ public DataType introspectType(Object value) {
+ DataType dataType = null;
+ for (DataBinding binding : bindings.values()) {
+ dataType = binding.introspect(value);
+ if (dataType != null) {
+ return dataType;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java
new file mode 100644
index 0000000000..947887b460
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.WirePostProcessorExtension;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * This processor is responsible to add an interceptor to invocation chain if
+ * the source and target operations have different databinding requirements
+ */
+public class DataBindingWirePostProcessor extends WirePostProcessorExtension {
+ private Mediator mediator;
+
+ @Constructor({"mediator"})
+ public DataBindingWirePostProcessor(@Autowire Mediator mediator) {
+ super();
+ this.mediator = mediator;
+ }
+
+ public void process(OutboundWire source, InboundWire target) {
+ Map<Operation<?>, OutboundInvocationChain> chains = source.getInvocationChains();
+ for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : chains.entrySet()) {
+ Operation<?> sourceOperation = entry.getKey();
+ Operation<?> targetOperation =
+ getTargetOperation(target.getInvocationChains().keySet(), sourceOperation.getName());
+ String sourceDataBinding = getDataBinding(sourceOperation);
+ String targetDataBinding = getDataBinding(targetOperation);
+ if (sourceDataBinding == null || targetDataBinding == null
+ || !sourceDataBinding.equals(targetDataBinding)) {
+ // Add the interceptor to the source side because multiple
+ // references can be wired
+ // to the same service
+ DataBindingInteceptor interceptor =
+ new DataBindingInteceptor(source, sourceOperation, target, targetOperation);
+ interceptor.setMediator(mediator);
+ entry.getValue().addInterceptor(0, interceptor);
+ }
+ }
+
+ // Check if there's a callback
+ Map callbackOperations = source.getServiceContract().getCallbackOperations();
+ if (callbackOperations == null || callbackOperations.isEmpty()) {
+ return;
+ }
+ Object targetAddress = source.getContainer().getName();
+ Map<Operation<?>, OutboundInvocationChain> callbackChains =
+ target.getSourceCallbackInvocationChains(targetAddress);
+ for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : callbackChains.entrySet()) {
+ Operation<?> sourceOperation = entry.getKey();
+ Operation<?> targetOperation =
+ getTargetOperation(source.getTargetCallbackInvocationChains().keySet(), sourceOperation
+ .getName());
+ String sourceDataBinding = getDataBinding(sourceOperation);
+ String targetDataBinding = getDataBinding(targetOperation);
+ if (sourceDataBinding == null || targetDataBinding == null
+ || !sourceDataBinding.equals(targetDataBinding)) {
+ // Add the interceptor to the source side because multiple
+ // references can be wired
+ // to the same service
+ DataBindingInteceptor interceptor =
+ new DataBindingInteceptor(source, sourceOperation, target, targetOperation);
+ interceptor.setMediator(mediator);
+ entry.getValue().addInterceptor(0, interceptor);
+ }
+ }
+ }
+
+ public void process(InboundWire source, OutboundWire target) {
+ SCAObject container = source.getContainer();
+ // Either Service or Reference
+ boolean isReference = container instanceof Reference;
+
+ Map<Operation<?>, InboundInvocationChain> chains = source.getInvocationChains();
+ for (Map.Entry<Operation<?>, InboundInvocationChain> entry : chains.entrySet()) {
+ Operation<?> sourceOperation = entry.getKey();
+ Operation<?> targetOperation =
+ getTargetOperation(target.getInvocationChains().keySet(), sourceOperation.getName());
+ String sourceDataBinding = getDataBinding(sourceOperation);
+ String targetDataBinding = getDataBinding(targetOperation);
+ if (sourceDataBinding == null || targetDataBinding == null
+ || !sourceDataBinding.equals(targetDataBinding)) {
+ // Add the interceptor to the source side
+ DataBindingInteceptor interceptor =
+ new DataBindingInteceptor(source, sourceOperation, target, targetOperation);
+ interceptor.setMediator(mediator);
+ if (isReference) {
+ // FIXME: We need a better way to position the interceptors
+ target.getInvocationChains().get(targetOperation).addInterceptor(0, interceptor);
+ Interceptor tail = entry.getValue().getTailInterceptor();
+ if (tail != null) {
+ // HACK to relink the bridging interceptor
+ tail.setNext(interceptor);
+ }
+ } else {
+ entry.getValue().addInterceptor(0, interceptor);
+ }
+
+ }
+ }
+ }
+
+ private Operation getTargetOperation(Set<Operation<?>> operations, String operationName) {
+ for (Operation<?> op : operations) {
+ if (op.getName().equals(operationName)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ private String getDataBinding(Operation<?> operation) {
+ String dataBinding = operation.getDataBinding();
+ if (dataBinding == null) {
+ ServiceContract<?> serviceContract = operation.getServiceContract();
+ dataBinding = serviceContract.getDataBinding();
+ }
+ return dataBinding;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java
new file mode 100644
index 0000000000..8b3296a017
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * The StAX loader for data type
+ */
+public class DataTypeLoader extends LoaderExtension<DataType> {
+ public static final QName DATA_BINDING =
+ new QName("http://incubator.apache.org/tuscany/xmlns/databinding/1.0-incubator-M2", "databinding");
+
+ @Constructor({"registry"})
+ public DataTypeLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public QName getXMLType() {
+ return DATA_BINDING;
+ }
+
+ public DataType load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ assert DATA_BINDING.equals(reader.getName());
+ String name = reader.getAttributeValue(null, "name");
+ LoaderUtil.skipToEndElement(reader);
+ if (name == null) {
+ throw new InvalidValueException("The 'name' attrbiute is required");
+ }
+ DataType dataType = new DataType<Class>(name, Object.class, Object.class);
+ return dataType;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java
new file mode 100755
index 0000000000..02adf5860c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Directed, weighted graph
+ *
+ * @param <V> The type of vertex object
+ * @param <E> The type of edge object
+ */
+public class DirectedGraph<V, E> {
+ private final Map<V, Vertex> vertices = new HashMap<V, Vertex>();
+
+ /**
+ * Key for the shortest path cache
+ */
+ private final class VertexPair {
+ private Vertex source;
+
+ private Vertex target;
+
+ /**
+ * @param source
+ * @param target
+ */
+ private VertexPair(Vertex source, Vertex target) {
+ super();
+ this.source = source;
+ this.target = target;
+ }
+
+ public boolean equals(Object object) {
+ if (!VertexPair.class.isInstance(object)) {
+ return false;
+ }
+ VertexPair pair = (VertexPair)object;
+ return source == pair.source && target == pair.target;
+ }
+
+ public int hashCode() {
+ int x = source == null ? 0 : source.hashCode();
+ int y = target == null ? 0 : target.hashCode();
+ return x ^ y;
+ }
+
+ }
+
+ private final Map<VertexPair, Path> paths = new HashMap<VertexPair, Path>();
+
+ /**
+ * Vertex of a graph
+ */
+ public final class Vertex {
+ private V value;
+
+ // TODO: Do we want to support multiple edges for a vertex pair? If so,
+ // we should use a List instead of Map
+ private Map<Vertex, Edge> outEdges = new HashMap<Vertex, Edge>();
+
+ private Vertex(V value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return "(" + value + ")";
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public Map<Vertex, Edge> getOutEdges() {
+ return outEdges;
+ }
+
+ }
+
+ /**
+ * An Edge connects two vertices in one direction
+ */
+ public final class Edge {
+ private Vertex sourceVertex;
+
+ private Vertex targetVertex;
+
+ private E value;
+
+ private int weight;
+
+ public Edge(Vertex source, Vertex target, E value, int weight) {
+ this.sourceVertex = source;
+ this.targetVertex = target;
+ this.value = value;
+ this.weight = weight;
+ }
+
+ public String toString() {
+ return sourceVertex + "->" + targetVertex + "[" + value + "," + weight + "]";
+ }
+
+ public E getValue() {
+ return value;
+ }
+
+ public void setValue(E value) {
+ this.value = value;
+ }
+
+ public Vertex getTargetVertex() {
+ return targetVertex;
+ }
+
+ public void setTargetVertex(Vertex vertex) {
+ this.targetVertex = vertex;
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public void setWeight(int weight) {
+ this.weight = weight;
+ }
+
+ public Vertex getSourceVertex() {
+ return sourceVertex;
+ }
+
+ public void setSourceVertex(Vertex sourceVertex) {
+ this.sourceVertex = sourceVertex;
+ }
+ }
+
+ private final class Node implements Comparable<Node> {
+
+ private long distance = Integer.MAX_VALUE;
+
+ private Node previous; // NOPMD by rfeng on 9/26/06 9:17 PM
+
+ private Vertex vertex; // NOPMD by rfeng on 9/26/06 9:17 PM
+
+ private Node(Vertex vertex) {
+ this.vertex = vertex;
+ }
+
+ public int compareTo(Node o) {
+ return (distance > o.distance) ? 1 : ((distance == o.distance) ? 0 : -1);
+ }
+ }
+
+ public void addEdge(V source, V target, E edgeValue, int weight) {
+ Vertex s = getVertex(source);
+ if (s == null) {
+ s = new Vertex(source);
+ vertices.put(source, s);
+ }
+ Vertex t = getVertex(target);
+ if (t == null) {
+ t = new Vertex(target);
+ vertices.put(target, t);
+ }
+ Edge edge = new Edge(s, t, edgeValue, weight);
+ s.outEdges.put(t, edge);
+ }
+
+ public Vertex getVertex(V source) {
+ Vertex s = vertices.get(source);
+ return s;
+ }
+
+ public boolean removeEdge(V source, V target) {
+ Vertex s = getVertex(source);
+ if (s == null) {
+ return false;
+ }
+
+ Vertex t = getVertex(target);
+ if (t == null) {
+ return false;
+ }
+
+ return s.outEdges.remove(t) != null;
+
+ }
+
+ public Edge getEdge(Vertex source, Vertex target) {
+ return source.outEdges.get(target);
+ }
+
+ public Edge getEdge(V source, V target) {
+ return getEdge(getVertex(source), getVertex(target));
+ }
+
+ /**
+ * Get the shortes path from the source vertex to the target vertex using
+ * Dijkstra's algorithm. If there's no path, null will be returned. If the
+ * source is the same as the target, it returns a path with empty edges with
+ * weight 0.
+ *
+ * @param sourceValue The value identifies the source
+ * @param targetValue The value identifies the target
+ * @return The shortest path
+ */
+ public Path getShortestPath(V sourceValue, V targetValue) {
+ Vertex source = getVertex(sourceValue);
+ if (source == null) {
+ return null;
+ }
+ Vertex target = getVertex(targetValue);
+ if (target == null) {
+ return null;
+ }
+
+ VertexPair pair = new VertexPair(source, target);
+ if (paths.containsKey(pair)) {
+ return paths.get(pair);
+ }
+
+ // HACK: To support same vertex
+ if (source == target) {
+ Path path = new Path();
+ Edge edge = getEdge(source, target);
+ if (edge != null) {
+ path.addEdge(edge);
+ }
+ paths.put(pair, path);
+ return path;
+ }
+
+ Map<Vertex, Node> nodes = new HashMap<Vertex, Node>();
+ for (Vertex v : vertices.values()) {
+ Node node = new Node(v);
+ if (v == source) {
+ node.distance = 0;
+ }
+ nodes.put(v, node);
+ }
+
+ Set<Node> otherNodes = new HashSet<Node>(nodes.values());
+ Set<Node> nodesOnPath = new HashSet<Node>();
+ while (!otherNodes.isEmpty()) {
+ Node nextNode = extractMin(otherNodes);
+ if (nextNode.vertex == target) {
+ Path path = getPath(nextNode);
+ paths.put(pair, path); // Cache it
+ return path;
+ }
+ nodesOnPath.add(nextNode);
+ for (Edge edge : nextNode.vertex.outEdges.values()) {
+ Node adjacentNode = nodes.get(edge.targetVertex);
+ if (nextNode.distance + edge.weight < adjacentNode.distance) {
+ adjacentNode.distance = nextNode.distance + edge.weight;
+ adjacentNode.previous = nextNode;
+ }
+ }
+ }
+ paths.put(pair, null); // Cache it
+ return null;
+ }
+
+ /**
+ * Searches for the vertex u in the vertex set Q that has the least d[u]
+ * value. That vertex is removed from the set Q and returned to the user.
+ *
+ * @param nodes
+ * @return
+ */
+ private Node extractMin(Set<Node> nodes) {
+ Node node = Collections.min(nodes);
+ nodes.remove(node);
+ return node;
+ }
+
+ /**
+ * The path between two vertices
+ */
+ public final class Path {
+ private List<Edge> edges = new LinkedList<Edge>();
+
+ private int weight;
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public List<Edge> getEdges() {
+ return edges;
+ }
+
+ public void addEdge(Edge edge) {
+ edges.add(0, edge);
+ weight += edge.weight;
+ }
+
+ public String toString() {
+ return edges + ", " + weight;
+ }
+ }
+
+ private Path getPath(Node t) {
+ if (t.distance == Integer.MAX_VALUE) {
+ return null;
+ }
+ Path path = new Path();
+ Node u = t;
+ while (u.previous != null) {
+ Edge edge = getEdge(u.previous.vertex, u.vertex);
+ path.addEdge(edge);
+ u = u.previous;
+ }
+ return path;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ for (Vertex v : vertices.values()) {
+ sb.append(v.outEdges.values()).append("\n");
+ }
+ return sb.toString();
+ }
+
+ public Map<V, Vertex> getVertices() {
+ return vertices;
+ }
+
+ public void addGraph(DirectedGraph<V, E> otherGraph) {
+ for (Vertex v : otherGraph.vertices.values()) {
+ for (Edge e : v.outEdges.values()) {
+ addEdge(e.sourceVertex.value, e.targetVertex.value, e.value, e.weight);
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java
new file mode 100644
index 0000000000..81cf3a9e3d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.WrapperInfo;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is a special transformer to transform the input from one IDL to the
+ * other one
+ */
+@Service(Transformer.class)
+public class Input2InputTransformer extends TransformerExtension<Object[], Object[]> implements
+ PullTransformer<Object[], Object[]> {
+
+ private static final String IDL_INPUT = "idl:input";
+
+ protected DataBindingRegistry dataBindingRegistry;
+
+ protected Mediator mediator;
+
+ public Input2InputTransformer() {
+ super();
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return IDL_INPUT;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return IDL_INPUT;
+ }
+
+ /**
+ * @param mediator the mediator to set
+ */
+ @Autowire
+ public void setMediator(Mediator mediator) {
+ this.mediator = mediator;
+ }
+
+ /**
+ * @param dataBindingRegistry the dataBindingRegistry to set
+ */
+ @Autowire
+ public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) {
+ this.dataBindingRegistry = dataBindingRegistry;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType()
+ */
+ @Override
+ protected Class getSourceType() {
+ return Object[].class;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType()
+ */
+ @Override
+ protected Class getTargetType() {
+ return Object[].class;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.Transformer#getWeight()
+ */
+ public int getWeight() {
+ return 10000;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] transform(Object[] source, TransformationContext context) {
+ DataType<List<DataType<?>>> sourceType = context.getSourceDataType();
+ Operation<?> sourceOp = (Operation<?>)sourceType.getMetadata(Operation.class.getName());
+ boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle();
+
+ WrapperHandler sourceWrapperHandler = null;
+ if (sourceWrapped) {
+ sourceWrapperHandler = getWapperHandler(sourceType.getLogical().get(0).getDataBinding(), true);
+ }
+
+ DataType<List<DataType<QName>>> targetType = context.getTargetDataType();
+ Operation<?> targetOp = (Operation<?>)targetType.getMetadata(Operation.class.getName());
+ boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle();
+ WrapperHandler targetWrapperHandler = null;
+ if (targetWrapped) {
+ targetWrapperHandler = getWapperHandler(targetType.getLogical().get(0).getDataBinding(), true);
+ }
+
+ if ((!sourceWrapped) && targetWrapped) {
+ // Unwrapped --> Wrapped
+ WrapperInfo wrapper = targetOp.getWrapper();
+ ElementInfo wrapperElement = wrapper.getInputWrapperElement();
+
+ // If the source can be wrapped, wrapped it first
+ if (sourceWrapperHandler != null) {
+ Object sourceWrapper = sourceWrapperHandler.create(wrapperElement, context);
+ for (int i = 0; i < source.length; i++) {
+ ElementInfo argElement = wrapper.getInputChildElements().get(i);
+ sourceWrapperHandler.setChild(sourceWrapper, i, argElement, source[0]);
+ }
+ }
+ Object targetWrapper = targetWrapperHandler.create(wrapperElement, context);
+ if (source == null) {
+ return new Object[] {targetWrapper};
+ }
+ List<DataType<QName>> argTypes = wrapper.getUnwrappedInputType().getLogical();
+
+ for (int i = 0; i < source.length; i++) {
+ ElementInfo argElement = wrapper.getInputChildElements().get(i);
+ DataType<QName> argType = argTypes.get(i);
+ Object child = source[i];
+ child =
+ mediator.mediate(source[i], sourceType.getLogical().get(i), argType, context
+ .getMetadata());
+ targetWrapperHandler.setChild(targetWrapper, i, argElement, child);
+ }
+ return new Object[] {targetWrapper};
+ } else if (sourceWrapped && (!targetWrapped)) {
+ // Wrapped to Unwrapped
+ Object sourceWrapper = source[0];
+ List<ElementInfo> childElements = sourceOp.getWrapper().getInputChildElements();
+ Object[] target = new Object[childElements.size()];
+
+ targetWrapperHandler = getWapperHandler(targetType.getLogical().get(0).getDataBinding(), false);
+ if (targetWrapperHandler != null) {
+ ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
+ // Object targetWrapper =
+ // targetWrapperHandler.create(wrapperElement, context);
+ DataType<QName> targetWrapperType =
+ new DataType<QName>(targetType.getLogical().get(0).getDataBinding(), Object.class,
+ wrapperElement.getQName());
+ Object targetWrapper =
+ mediator.mediate(sourceWrapper,
+ sourceType.getLogical().get(0),
+ targetWrapperType,
+ context.getMetadata());
+ for (int i = 0; i < childElements.size(); i++) {
+ ElementInfo childElement = childElements.get(i);
+ target[i] = targetWrapperHandler.getChild(targetWrapper, i, childElement);
+ }
+ } else {
+ for (int i = 0; i < childElements.size(); i++) {
+ ElementInfo childElement = childElements.get(i);
+ Object child = sourceWrapperHandler.getChild(sourceWrapper, i, childElement);
+ DataType<QName> childType =
+ sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i);
+ target[i] =
+ mediator.mediate(child, childType, targetType.getLogical().get(i), context
+ .getMetadata());
+ }
+ }
+ return target;
+ } else {
+ // Assuming wrapper to wrapper conversion can be handled here as
+ // well
+ Object[] newArgs = new Object[source.length];
+ for (int i = 0; i < source.length; i++) {
+ Object child =
+ mediator.mediate(source[i], sourceType.getLogical().get(i), targetType.getLogical()
+ .get(i), context.getMetadata());
+ newArgs[i] = child;
+ }
+ return newArgs;
+ }
+ }
+
+ private WrapperHandler getWapperHandler(String dataBindingId, boolean required) {
+ DataBinding dataBinding = dataBindingRegistry.getDataBinding(dataBindingId);
+ WrapperHandler wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
+ if (wrapperHandler == null && required) {
+ throw new TransformationException(
+ "No wrapper handler is provided for databinding: " + dataBindingId);
+ }
+ return wrapperHandler;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java
new file mode 100644
index 0000000000..f8b38de806
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.DataPipe;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Default Mediator implementation
+ */
+@Scope("MODULE")
+public class MediatorImpl implements Mediator {
+
+ private DataBindingRegistry dataBindingRegistry;
+
+ private TransformerRegistry transformerRegistry;
+
+ @Autowire
+ public void setTransformerRegistry(TransformerRegistry transformerRegistry) {
+ this.transformerRegistry = transformerRegistry;
+ }
+
+ /**
+ * @param dataBindingRegistry the dataBindingRegistry to set
+ */
+ @Autowire
+ public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) {
+ this.dataBindingRegistry = dataBindingRegistry;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.Mediator#mediate(java.lang.Object,
+ * org.apache.tuscany.spi.model.DataType,
+ * org.apache.tuscany.spi.model.DataType, Map)
+ */
+ @SuppressWarnings("unchecked")
+ public Object mediate(Object source,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map<Class<?>, Object> metadata) {
+ if (source == null) {
+ // Shortcut for null value
+ return null;
+ }
+ if (sourceDataType == null) {
+ sourceDataType = dataBindingRegistry.introspectType(source);
+ }
+ if (sourceDataType == null) {
+ return source;
+ } else if (sourceDataType.equals(targetDataType)) {
+ return source;
+ }
+
+ List<Transformer> path = getTransformerChain(sourceDataType, targetDataType);
+
+ Object result = source;
+ int size = path.size();
+ int i = 0;
+ while (i < size) {
+ Transformer transformer = path.get(i);
+ TransformationContext context =
+ createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
+ // the source and target type
+ if (transformer instanceof PullTransformer) {
+ // For intermediate node, set data type to null
+ result = ((PullTransformer)transformer).transform(result, context);
+ } else if (transformer instanceof PushTransformer) {
+ DataPipe dataPipe = (i < size - 1) ? (DataPipe)path.get(++i) : null;
+ ((PushTransformer)transformer).transform(result, dataPipe.getSink(), context);
+ result = dataPipe.getResult();
+ }
+ i++;
+ }
+
+ return result;
+ }
+
+ private TransformationContext createTransformationContext(DataType sourceDataType,
+ DataType targetDataType,
+ int size,
+ int index,
+ Transformer transformer,
+ Map<Class<?>, Object> metadata) {
+ DataType sourceType =
+ (index == 0) ? sourceDataType : new DataType<Object>(transformer.getSourceDataBinding(),
+ Object.class, null);
+ DataType targetType =
+ (index == size - 1) ? targetDataType : new DataType<Object>(transformer.getTargetDataBinding(),
+ Object.class, null);
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ TransformationContext context =
+ new TransformationContextImpl(sourceType, targetType, classLoader, metadata);
+ return context;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void mediate(Object source,
+ Object target,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map<Class<?>, Object> metadata) {
+ if (source == null) {
+ // Shortcut for null value
+ return;
+ }
+ if (sourceDataType == null) {
+ sourceDataType = dataBindingRegistry.introspectType(source);
+ }
+ if (sourceDataType == null) {
+ return;
+ } else if (sourceDataType.equals(targetDataType)) {
+ return;
+ }
+
+ List<Transformer> path = getTransformerChain(sourceDataType, targetDataType);
+ Object result = source;
+ int size = path.size();
+ for (int i = 0; i < size; i++) {
+ Transformer transformer = path.get(i);
+ TransformationContext context =
+ createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata);
+
+ if (transformer instanceof PullTransformer) {
+ result = ((PullTransformer)transformer).transform(result, context);
+ } else if (transformer instanceof PushTransformer) {
+ DataPipe dataPipe = (i < size - 1) ? (DataPipe)path.get(++i) : null;
+ Object sink = dataPipe != null ? dataPipe.getSink() : target;
+ ((PushTransformer)transformer).transform(result, sink, context);
+ result = (dataPipe != null) ? dataPipe.getResult() : null;
+ }
+ }
+ }
+
+ private List<Transformer> getTransformerChain(DataType sourceDataType, DataType targetDataType) {
+ String sourceId = sourceDataType.getDataBinding();
+ String targetId = targetDataType.getDataBinding();
+ List<Transformer> path = transformerRegistry.getTransformerChain(sourceId, targetId);
+ if (path == null) {
+ TransformationException ex = new TransformationException("No path found for the transformation");
+ ex.addContextName("Source: " + sourceId);
+ ex.addContextName("Target: " + targetId);
+ throw ex;
+ }
+ return path;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java
new file mode 100644
index 0000000000..f0405ca313
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.WrapperInfo;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ */
+@Service(Transformer.class)
+public class Output2OutputTransformer extends TransformerExtension<Object, Object> implements
+ PullTransformer<Object, Object> {
+ private static final String IDL_OUTPUT = "idl:output";
+
+ protected DataBindingRegistry dataBindingRegistry;
+
+ protected Mediator mediator;
+
+ /**
+ * @param wrapperHandler
+ */
+ public Output2OutputTransformer() {
+ super();
+ }
+
+ /**
+ * @param mediator the mediator to set
+ */
+ @Autowire
+ public void setMediator(Mediator mediator) {
+ this.mediator = mediator;
+ }
+
+ /**
+ * @param dataBindingRegistry the dataBindingRegistry to set
+ */
+ @Autowire
+ public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) {
+ this.dataBindingRegistry = dataBindingRegistry;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return IDL_OUTPUT;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return IDL_OUTPUT;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType()
+ */
+ @Override
+ protected Class getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType()
+ */
+ @Override
+ protected Class getTargetType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.Transformer#getWeight()
+ */
+ public int getWeight() {
+ return 10;
+ }
+
+ private WrapperHandler getWapperHandler(Operation<?> operation) {
+ String dataBindingId;
+ dataBindingId = operation.getDataBinding();
+ DataBinding dataBinding = dataBindingRegistry.getDataBinding(dataBindingId);
+ WrapperHandler wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
+ if (wrapperHandler == null) {
+ throw new TransformationException(
+ "No wrapper handler is provided for databinding: " + dataBindingId);
+ }
+ return wrapperHandler;
+ }
+
+ private WrapperHandler getWapperHandler(String dataBindingId) {
+ DataBinding dataBinding = dataBindingRegistry.getDataBinding(dataBindingId);
+ return dataBinding == null ? null : dataBinding.getWrapperHandler();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object transform(Object response, TransformationContext context) {
+ try {
+ DataType<DataType> sourceType = context.getSourceDataType();
+ Operation<?> sourceOp = (Operation<?>)sourceType.getMetadata(Operation.class.getName());
+ boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle();
+ WrapperHandler sourceWrapperHandler = null;
+ if (sourceWrapped) {
+ sourceWrapperHandler = getWapperHandler(sourceOp);
+ }
+
+ DataType<DataType> targetType = context.getTargetDataType();
+ Operation<?> targetOp = (Operation<?>)targetType.getMetadata(Operation.class.getName());
+ boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle();
+ WrapperHandler targetWrapperHandler = null;
+ if (targetWrapped) {
+ targetWrapperHandler = getWapperHandler(targetOp);
+ }
+
+ if ((!sourceWrapped) && targetWrapped) {
+ // Unwrapped --> Wrapped
+ WrapperInfo wrapper = targetOp.getWrapper();
+ Object targetWrapper =
+ targetWrapperHandler.create(wrapper.getOutputWrapperElement(), context);
+ if (response == null) {
+ return targetWrapper;
+ }
+
+ ElementInfo argElement = wrapper.getOutputChildElements().get(0);
+ DataType<QName> argType = wrapper.getUnwrappedOutputType();
+ Object child = response;
+ child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata());
+ targetWrapperHandler.setChild(targetWrapper, 0, argElement, child);
+ return targetWrapper;
+ } else if (sourceWrapped && (!targetWrapped)) {
+ // Wrapped to Unwrapped
+ Object sourceWrapper = response;
+ List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements();
+ ElementInfo childElement = childElements.get(0);
+
+ targetWrapperHandler = getWapperHandler(targetType.getLogical().getDataBinding());
+ if (targetWrapperHandler != null) {
+ ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
+ // Object targetWrapper =
+ // targetWrapperHandler.create(wrapperElement, context);
+ DataType<QName> targetWrapperType =
+ new DataType<QName>(targetType.getLogical().getDataBinding(), Object.class,
+ wrapperElement.getQName());
+ Object targetWrapper =
+ mediator.mediate(sourceWrapper, sourceType.getLogical(), targetWrapperType, context
+ .getMetadata());
+ return targetWrapperHandler.getChild(targetWrapper, 0, childElement);
+ } else {
+ Object child = sourceWrapperHandler.getChild(sourceWrapper, 0, childElement);
+ DataType<?> childType = sourceOp.getWrapper().getUnwrappedOutputType();
+ return mediator.mediate(child, childType, targetType.getLogical(), context.getMetadata());
+ }
+ } else {
+ // FIXME: Do we want to handle wrapped to wrapped?
+ return mediator.mediate(response, sourceType.getLogical(), targetType.getLogical(), context
+ .getMetadata());
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java
new file mode 100755
index 0000000000..388ea710a7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import org.apache.tuscany.spi.databinding.DataPipe;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+
+/**
+ * A utility class to connect PushTransformer and DataPipe to create a
+ * PullTransformer
+ *
+ * @param <S> Source type
+ * @param <I> Intermidate type
+ * @param <R> Result type
+ */
+public class PipedTransformer<S, I, R> implements PullTransformer<S, R> {
+ private PushTransformer<S, I> pusher;
+
+ private DataPipe<I, R> pipe;
+
+ /**
+ * @param pumper
+ * @param pipe
+ */
+ public PipedTransformer(PushTransformer<S, I> pumper, DataPipe<I, R> pipe) {
+ super();
+ this.pusher = pumper;
+ this.pipe = pipe;
+ }
+
+ public R transform(S source, TransformationContext context) {
+ pusher.transform(source, pipe.getSink(), context);
+ return pipe.getResult();
+ }
+
+ public String getSourceDataBinding() {
+ return pusher.getSourceDataBinding();
+ }
+
+ public String getTargetDataBinding() {
+ return pipe.getTargetDataBinding();
+ }
+
+ public int getWeight() {
+ return pusher.getWeight() + pipe.getWeight();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java
new file mode 100644
index 0000000000..9d56ab5353
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Simple databinding represented by a base java type. A SCDL property className
+ * is used to customize this component.
+ * <p>
+ * The following illustrates how a simple data binding can be registered as a
+ * SCA component.
+ * <p>
+ * &lt;component name="databinding.MyDataBinding"&gt;<br>
+ * &nbsp;&nbsp;&lt;system:implementation.java
+ * class="org.apache.tuscany.databinding.impl.SimpleDataBinding"/&gt;<br>
+ * &nbsp;&nbsp;&lt;property name="className"&gt;my.Type&lt;/property&gt;<br>
+ * &lt/component&gt;
+ */
+public class SimpleDataBinding extends DataBindingExtension {
+
+ public SimpleDataBinding(@Property(name = "className") String className) throws MissingResourceException {
+ super(resolve(className));
+ }
+
+ private static Class<?> resolve(String className) throws MissingResourceException {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ return Class.forName(className, false, classLoader);
+ } catch (ClassNotFoundException e) {
+ classLoader = SimpleDataBinding.class.getClassLoader();
+ try {
+ return Class.forName(className, false, classLoader);
+ } catch (ClassNotFoundException e1) {
+ MissingResourceException mre = new MissingResourceException(className, e1);
+ throw mre;
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java
new file mode 100755
index 0000000000..47f340097b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+
+public class TransformationContextImpl implements TransformationContext {
+ private DataType sourceDataType;
+
+ private DataType targetDataType;
+
+ private final Map<Class<?>, Object> metadata = new HashMap<Class<?>, Object>();
+
+ private WeakReference<ClassLoader> classLoaderRef;
+
+ public TransformationContextImpl() {
+ super();
+ setClassLoader(Thread.currentThread().getContextClassLoader());
+ }
+
+ public TransformationContextImpl(DataType sourceDataType,
+ DataType targetDataType,
+ ClassLoader classLoader,
+ Map<Class<?>, Object> metadata) {
+ super();
+ this.sourceDataType = sourceDataType;
+ this.targetDataType = targetDataType;
+ setClassLoader(classLoader);
+ if (metadata != null) {
+ this.metadata.putAll(metadata);
+ }
+ }
+
+ public DataType getSourceDataType() {
+ return sourceDataType;
+ }
+
+ public DataType getTargetDataType() {
+ return targetDataType;
+ }
+
+ public void setSourceDataType(DataType sourceDataType) {
+ this.sourceDataType = sourceDataType;
+ }
+
+ public void setTargetDataType(DataType targetDataType) {
+ this.targetDataType = targetDataType;
+ }
+
+ public final void setClassLoader(ClassLoader classLoader) {
+ this.classLoaderRef = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoaderRef.get();
+ }
+
+ public Map<Class<?>, Object> getMetadata() {
+ return metadata;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java
new file mode 100755
index 0000000000..5cbd931cb0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.osoa.sca.annotations.Init;
+
+public class TransformerRegistryImpl implements TransformerRegistry {
+
+ private final DirectedGraph<Object, Transformer> graph = new DirectedGraph<Object, Transformer>();
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public void registerTransformer(String sourceType, String resultType, int weight, Transformer transformer) {
+ graph.addEdge(sourceType, resultType, transformer, weight);
+ }
+
+ public void registerTransformer(Transformer transformer) {
+ graph.addEdge(transformer.getSourceDataBinding(),
+ transformer.getTargetDataBinding(),
+ transformer,
+ transformer.getWeight());
+ }
+
+ public boolean unregisterTransformer(String sourceType, String resultType) {
+ return graph.removeEdge(sourceType, resultType);
+ }
+
+ public Transformer getTransformer(String sourceType, String resultType) {
+ DirectedGraph<Object, Transformer>.Edge edge = graph.getEdge(sourceType, resultType);
+ return (edge == null) ? null : edge.getValue();
+ }
+
+ public List<Transformer> getTransformerChain(String sourceType, String resultType) {
+ List<Transformer> transformers = new ArrayList<Transformer>();
+ DirectedGraph<Object, Transformer>.Path path = graph.getShortestPath(sourceType, resultType);
+ if (path == null) {
+ return null;
+ }
+ for (DirectedGraph<Object, Transformer>.Edge edge : path.getEdges()) {
+ transformers.add(edge.getValue());
+ }
+ return transformers;
+ }
+
+ public String toString() {
+ return graph.toString();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java
new file mode 100644
index 0000000000..9fc1cc5152
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.w3c.dom.Node;
+
+/**
+ * DOM DataBinding
+ */
+public class DOMDataBinding extends DataBindingExtension {
+ public static final String NAME = Node.class.getName();
+
+ public DOMDataBinding() {
+ super(Node.class);
+ }
+
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return new DOMWrapperHandler();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java
new file mode 100644
index 0000000000..0373ebcdfe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class DOMWrapperHandler implements WrapperHandler<Node> {
+
+ private Document document;
+
+ public DOMWrapperHandler() {
+ super();
+ try {
+ this.document = DOMHelper.newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Node create(ElementInfo element, TransformationContext context) {
+ QName name = element.getQName();
+ return DOMHelper.createElement(document, name);
+ }
+
+ public Object getChild(Node wrapper, int i, ElementInfo element) {
+ int index = 0;
+ NodeList nodes = wrapper.getChildNodes();
+ for (int j = 0; j < nodes.getLength(); j++) {
+ Node node = nodes.item(j);
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+ if (index != i) {
+ index++;
+ } else {
+ QName name = DOMHelper.getQName(node);
+ if (name.equals(element.getQName())) {
+ return node;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setChild(Node wrapper, int i, ElementInfo childElement, Object value) {
+ Node node = (Node) value;
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ node = ((Document) node).getDocumentElement();
+ }
+ wrapper.appendChild(wrapper.getOwnerDocument().importNode(node, true));
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java
new file mode 100644
index 0000000000..5a12cc72cb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java
@@ -0,0 +1,1410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.tuscany.core.databinding.xml.StAXHelper.XMLFragmentStreamReader;
+
+public class DOMXMLStreamReader implements XMLFragmentStreamReader {
+ protected static class DelegatingNamespaceContext implements NamespaceContext {
+ private int counter;
+
+ private NamespaceContext parent;
+
+ private Map<String, String> prefixToNamespaceMapping = new HashMap<String, String>();
+
+ public DelegatingNamespaceContext(NamespaceContext parent) {
+ super();
+ this.parent = parent;
+
+ prefixToNamespaceMapping.put("xml", "http://www.w3.org/XML/1998/namespace");
+ prefixToNamespaceMapping.put("xmlns", "http://www.w3.org/2000/xmlns/");
+ prefixToNamespaceMapping.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
+ }
+
+ public synchronized QName createQName(String nsURI, String name) {
+ String prefix = nsURI != null ? (String) getPrefix(nsURI) : null;
+ if (prefix == null && nsURI != null && !nsURI.equals("")) {
+ prefix = "p" + (counter++);
+ }
+ if (prefix == null) {
+ prefix = "";
+ }
+ if (nsURI != null) {
+ prefixToNamespaceMapping.put(prefix, nsURI);
+ }
+ return new QName(nsURI, name, prefix);
+ }
+
+ public String getNamespaceURI(String prefix) {
+ if (prefix == null) {
+ throw new IllegalArgumentException("Prefix is null");
+ }
+
+ String ns = (String) prefixToNamespaceMapping.get(prefix);
+ if (ns != null) {
+ return ns;
+ } else if (parent != null) {
+ return parent.getNamespaceURI(prefix);
+ } else {
+ return null;
+ }
+ }
+
+ public String getPrefix(String nsURI) {
+ if (nsURI == null) {
+ throw new IllegalArgumentException("Namespace is null");
+ }
+ for (Map.Entry<String, String> entry1 : prefixToNamespaceMapping.entrySet()) {
+ Map.Entry entry = entry1;
+ if (entry.getValue().equals(nsURI)) {
+ return (String) entry.getKey();
+ }
+ }
+ if (parent != null) {
+ return parent.getPrefix(nsURI);
+ } else {
+ return null;
+ }
+ }
+
+ public Iterator getPrefixes(String nsURI) {
+ List<String> prefixList = new ArrayList<String>();
+ for (Map.Entry<String, String> entry : prefixToNamespaceMapping.entrySet()) {
+ if (entry.getValue().equals(nsURI)) {
+ prefixList.add(entry.getKey());
+ }
+ }
+ if (parent != null) {
+ for (Iterator i = parent.getPrefixes(nsURI); i.hasNext();) {
+ prefixList.add((String) i.next());
+ }
+ }
+ return prefixList.iterator();
+ }
+
+ public void registerMapping(String prefix, String nsURI) {
+ prefixToNamespaceMapping.put(prefix, nsURI);
+ }
+
+ public void removeMapping(String prefix) {
+ prefixToNamespaceMapping.remove(prefix);
+ }
+
+ public void setParent(NamespaceContext parent) {
+ this.parent = parent;
+ }
+ }
+
+ protected static class NameValuePair implements Map.Entry {
+ private Object key;
+
+ private Object value;
+
+ public NameValuePair(Object key, Object value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object value) {
+ Object v = this.value;
+ this.value = value;
+ return v;
+ }
+
+ }
+
+ protected static class SimpleElementStreamReader implements XMLFragmentStreamReader {
+
+ private static final int END_ELEMENT_STATE = 2;
+
+ private static final int START_ELEMENT_STATE = 0;
+
+ private static final int START_ELEMENT_STATE_WITH_NULL = 3;
+
+ private static final int TEXT_STATE = 1;
+
+ private static final QName XSI_NIL_QNAME =
+ new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi");
+
+ private QName name;
+
+ private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext(null);
+
+ private int state = START_ELEMENT_STATE;
+
+ private String value;
+
+ public SimpleElementStreamReader(QName name, String value) {
+ this.name = name;
+ this.value = value;
+ if (value == null) {
+ state = START_ELEMENT_STATE_WITH_NULL;
+ }
+ }
+
+ public void close() throws XMLStreamException {
+ // Do nothing - we've nothing to free here
+ }
+
+ public int getAttributeCount() {
+ if (state == START_ELEMENT_STATE_WITH_NULL) {
+ return 1;
+ }
+ if (state == START_ELEMENT_STATE) {
+ return 0;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getAttributeLocalName(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return XSI_NIL_QNAME.getLocalPart();
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public QName getAttributeName(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return XSI_NIL_QNAME;
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeNamespace(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return XSI_NIL_QNAME.getNamespaceURI();
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return XSI_NIL_QNAME.getPrefix();
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ return null; // not implemented
+ }
+
+ public String getAttributeValue(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) {
+ return "true";
+ }
+ if (state == START_ELEMENT_STATE) {
+ return null;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeValue(String string, String string1) {
+ if (state == TEXT_STATE) {
+ // todo something
+ return null;
+ } else {
+ return null;
+ }
+
+ }
+
+ public String getCharacterEncodingScheme() {
+ return null;
+ }
+
+ public String getElementText() throws XMLStreamException {
+ if (state == START_ELEMENT) {
+ // move to the end state and return the value
+ state = END_ELEMENT_STATE;
+ return value;
+ } else {
+ throw new XMLStreamException();
+ }
+
+ }
+
+ public String getEncoding() {
+ return "UTF-8";
+ }
+
+ public int getEventType() {
+ switch (state) {
+ case START_ELEMENT_STATE:
+ case START_ELEMENT_STATE_WITH_NULL:
+ return START_ELEMENT;
+ case END_ELEMENT_STATE:
+ return END_ELEMENT;
+ case TEXT_STATE:
+ return CHARACTERS;
+ default:
+ throw new UnsupportedOperationException();
+ // we've no idea what this is!!!!!
+ }
+
+ }
+
+ public String getLocalName() {
+ if (state != TEXT_STATE) {
+ return name.getLocalPart();
+ } else {
+ return null;
+ }
+ }
+
+ public Location getLocation() {
+ return new Location() {
+ public int getCharacterOffset() {
+ return 0;
+ }
+
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public String getPublicId() {
+ return null;
+ }
+
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public QName getName() {
+ if (state != TEXT_STATE) {
+ return name;
+ } else {
+ return null;
+ }
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return this.namespaceContext;
+ }
+
+ public int getNamespaceCount() {
+ if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent()) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+ }
+
+ public String getNamespacePrefix(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) {
+ return XSI_NIL_QNAME.getPrefix();
+ } else {
+ return null;
+ }
+ }
+
+ public String getNamespaceURI() {
+ if (state != TEXT_STATE) {
+ return name.getNamespaceURI();
+ } else {
+ return null;
+ }
+
+ }
+
+ public String getNamespaceURI(int i) {
+ if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) {
+ return XSI_NIL_QNAME.getNamespaceURI();
+ } else {
+ return null;
+ }
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ public String getPIData() {
+ return null;
+ }
+
+ public String getPITarget() {
+ return null;
+ }
+
+ public String getPrefix() {
+ if (state != TEXT_STATE) {
+ return name.getPrefix();
+ } else {
+ return null;
+ }
+ }
+
+ public Object getProperty(String key) throws IllegalArgumentException {
+ return null;
+ }
+
+ public String getText() {
+ if (state == TEXT_STATE) {
+ return value;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (state == TEXT_STATE) {
+ return value.toCharArray();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ // not implemented
+ throw new UnsupportedOperationException();
+ }
+
+ public int getTextLength() {
+ if (state == TEXT_STATE) {
+ return value.length();
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public int getTextStart() {
+ if (state == TEXT_STATE) {
+ return 0;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getVersion() {
+ return null; // todo 1.0 ?
+ }
+
+ public boolean hasName() {
+ return state != TEXT_STATE;
+
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ return state != END_ELEMENT_STATE;
+ }
+
+ public boolean hasText() {
+ return state == TEXT_STATE;
+ }
+
+ public void init() {
+ // just add the current elements namespace and prefix to the this
+ // elements nscontext
+ registerNamespace(name.getPrefix(), name.getNamespaceURI());
+
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ return false; // no attribs here
+ }
+
+ public boolean isCharacters() {
+ return state == TEXT_STATE;
+ }
+
+ public boolean isEndElement() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public boolean isEndOfFragment() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public boolean isStandalone() {
+ return false;
+ }
+
+ public boolean isStartElement() {
+ return state == START_ELEMENT_STATE || state == START_ELEMENT_STATE_WITH_NULL;
+ }
+
+ public boolean isWhiteSpace() {
+ return false; // no whitespaces here
+ }
+
+ /**
+ * Test whether the xsi namespace is present
+ *
+ * @return
+ */
+ private boolean isXsiNamespacePresent() {
+ return namespaceContext.getNamespaceURI(XSI_NIL_QNAME.getPrefix()) != null;
+ }
+
+ public int next() throws XMLStreamException {
+ switch (state) {
+ case START_ELEMENT_STATE:
+ state = TEXT_STATE;
+ return CHARACTERS;
+ case START_ELEMENT_STATE_WITH_NULL:
+ state = END_ELEMENT_STATE;
+ return END_ELEMENT;
+ case END_ELEMENT_STATE:
+ // oops, not supposed to happen!
+ throw new XMLStreamException("end already reached!");
+ case TEXT_STATE:
+ state = END_ELEMENT_STATE;
+ return END_ELEMENT;
+ default:
+ throw new XMLStreamException("unknown event type!");
+ }
+ }
+
+ public int nextTag() throws XMLStreamException {
+ return 0; // todo
+ }
+
+ /**
+ * @param prefix
+ * @param uri
+ */
+ private void registerNamespace(String prefix, String uri) {
+ // todo - need to fix this up to cater for cases where
+ // namespaces are having no prefixes
+ if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) {
+ // this namespace is not there. Need to declare it
+ namespaceContext.registerMapping(prefix, uri);
+ }
+ }
+
+ public void require(int i, String string, String string1) throws XMLStreamException {
+ // not implemented
+ }
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ this.namespaceContext.setParent(nsContext);
+ }
+
+ public boolean standaloneSet() {
+ return false;
+ }
+
+ }
+
+ private static final int DELEGATED_STATE = 2;
+
+ private static final int END_ELEMENT_STATE = 1;
+
+ // states for this pullparser - it can only have three states
+ private static final int START_ELEMENT_STATE = 0;
+
+ private static final int TEXT_STATE = 3;
+
+ private Map.Entry[] attributes;
+
+ // reference to the child reader
+ private XMLFragmentStreamReader childReader;
+
+ // current property index
+ private int currentPropertyIndex;
+
+ private Map<String, String> declaredNamespaceMap = new HashMap<String, String>();
+
+ private QName elementQName;
+
+ // we always create a new namespace context
+ private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext(null);
+
+ private Map.Entry[] properties;
+
+ private Element rootElement;
+
+ private String rootElementName;
+
+ private String rootElementURI;
+
+ // integer field that keeps the state of this
+ // parser.
+ private int state = START_ELEMENT_STATE;
+
+ public DOMXMLStreamReader(Node node) {
+ switch (node.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ this.rootElement = ((Document) node).getDocumentElement();
+ break;
+ case Node.ELEMENT_NODE:
+ this.rootElement = (Element) node;
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal Node");
+ }
+ this.rootElementName = rootElement.getLocalName();
+ this.rootElementURI = rootElement.getNamespaceURI();
+
+ declaredNamespaceMap.put("xml", "http://www.w3.org/XML/1998/namespace");
+ declaredNamespaceMap.put("xmlns", "http://www.w3.org/2000/xmlns/");
+ declaredNamespaceMap.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
+
+ populateProperties();
+ }
+
+ /*
+ * we need to pass in a namespace context since when delegated, we've no
+ * idea of the current namespace context. So it needs to be passed on here!
+ */
+ protected DOMXMLStreamReader(QName elementQName, Map.Entry[] properties, Map.Entry[] attributes) {
+ // validate the lengths, since both the arrays are supposed
+ // to have
+ this.properties = properties;
+ this.elementQName = elementQName;
+ this.attributes = attributes;
+
+ }
+
+ public void close() throws XMLStreamException {
+ // do nothing here - we have no resources to free
+ }
+
+ public int getAttributeCount() {
+ return (state == DELEGATED_STATE) ? childReader.getAttributeCount()
+ : ((attributes != null) && (state == START_ELEMENT_STATE) ? attributes.length : 0);
+ }
+
+ public String getAttributeLocalName(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeLocalName(i);
+ } else if (state == START_ELEMENT_STATE) {
+ QName name = getAttributeName(i);
+ if (name == null) {
+ return null;
+ } else {
+ return name.getLocalPart();
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * @param i
+ * @return
+ */
+ public QName getAttributeName(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeName(i);
+ } else if (state == START_ELEMENT_STATE) {
+ if (attributes == null) {
+ return null;
+ } else {
+ if ((i >= (attributes.length)) || i < 0) { // out of range
+ return null;
+ } else {
+ // get the attribute pointer
+ Object attribPointer = attributes[i].getKey();
+ // case one - attrib name is null
+ // this should be the pointer to the OMAttribute then
+ if (attribPointer instanceof String) {
+ return new QName((String) attribPointer);
+ } else if (attribPointer instanceof QName) {
+ return (QName) attribPointer;
+ } else {
+ return null;
+ }
+ }
+ }
+ } else {
+ throw new IllegalStateException(); // as per the api contract
+ }
+
+ }
+
+ public String getAttributeNamespace(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeNamespace(i);
+ } else if (state == START_ELEMENT_STATE) {
+ QName name = getAttributeName(i);
+ if (name == null) {
+ return null;
+ } else {
+ return name.getNamespaceURI();
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributePrefix(i);
+ } else if (state == START_ELEMENT_STATE) {
+ QName name = getAttributeName(i);
+ if (name == null) {
+ return null;
+ } else {
+ return name.getPrefix();
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ return null; // not supported
+ }
+
+ public String getAttributeValue(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getAttributeValue(i);
+ } else if (state == START_ELEMENT_STATE) {
+ if (attributes == null) {
+ return null;
+ } else {
+ if ((i >= (attributes.length)) || i < 0) { // out of range
+ return null;
+ } else {
+ // get the attribute pointer
+ Object attribPointer = attributes[i].getKey();
+ Object omAttribObj = attributes[i].getValue();
+ // case one - attrib name is null
+ // this should be the pointer to the OMAttribute then
+ if (attribPointer instanceof String) {
+ return (String) omAttribObj;
+ } else if (attribPointer instanceof QName) {
+ return (String) omAttribObj;
+ } else {
+ return null;
+ }
+ }
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getAttributeValue(String nsUri, String localName) {
+
+ int attribCount = getAttributeCount();
+ String returnValue = null;
+ QName attribQualifiedName;
+ for (int i = 0; i < attribCount; i++) {
+ attribQualifiedName = getAttributeName(i);
+ if (nsUri == null) {
+ if (localName.equals(attribQualifiedName.getLocalPart())) {
+ returnValue = getAttributeValue(i);
+ break;
+ }
+ } else {
+ if (localName.equals(attribQualifiedName.getLocalPart()) && nsUri.equals(attribQualifiedName
+ .getNamespaceURI())) {
+ returnValue = getAttributeValue(i);
+ break;
+ }
+ }
+
+ }
+
+ return returnValue;
+ }
+
+ public String getCharacterEncodingScheme() {
+ return null; // todo - should we return something for this ?
+ }
+
+ /**
+ * todo implement the right contract for this
+ *
+ * @return
+ * @throws XMLStreamException
+ */
+ public String getElementText() throws XMLStreamException {
+ if (state == DELEGATED_STATE) {
+ return childReader.getElementText();
+ } else {
+ return null;
+ }
+
+ }
+
+ public String getEncoding() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getEncoding();
+ } else {
+ // we've no idea what the encoding is going to be in this case
+ // perhaps we ought to return some constant here, which the user
+ // might
+ // have access to change!
+ return null;
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // / attribute handling
+ // /////////////////////////////////////////////////////////////////////////
+
+ public int getEventType() {
+ if (state == START_ELEMENT_STATE) {
+ return START_ELEMENT;
+ } else if (state == END_ELEMENT_STATE) {
+ return END_ELEMENT;
+ } else { // this is the delegated state
+ return childReader.getEventType();
+ }
+
+ }
+
+ public String getLocalName() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getLocalName();
+ } else if (state != TEXT_STATE) {
+ return elementQName.getLocalPart();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * @return
+ */
+ public Location getLocation() {
+ // return a default location
+ return new Location() {
+ public int getCharacterOffset() {
+ return 0;
+ }
+
+ public int getColumnNumber() {
+ return 0;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public String getPublicId() {
+ return null;
+ }
+
+ public String getSystemId() {
+ return null;
+ }
+ };
+ }
+
+ public QName getName() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getName();
+ } else if (state != TEXT_STATE) {
+ return elementQName;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceContext();
+ } else {
+ return namespaceContext;
+ }
+
+ }
+
+ public int getNamespaceCount() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceCount();
+ } else {
+ return declaredNamespaceMap.size();
+ }
+ }
+
+ /**
+ * @param i
+ * @return
+ */
+ public String getNamespacePrefix(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespacePrefix(i);
+ } else if (state != TEXT_STATE) {
+ // order the prefixes
+ String[] prefixes = makePrefixArray();
+ if ((i >= prefixes.length) || (i < 0)) {
+ return null;
+ } else {
+ return prefixes[i];
+ }
+
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ public String getNamespaceURI() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceURI();
+ } else if (state == TEXT_STATE) {
+ return null;
+ } else {
+ return elementQName.getNamespaceURI();
+ }
+ }
+
+ public String getNamespaceURI(int i) {
+ if (state == DELEGATED_STATE) {
+ return childReader.getNamespaceURI(i);
+ } else if (state != TEXT_STATE) {
+ String namespacePrefix = getNamespacePrefix(i);
+ return namespacePrefix == null ? null : (String) declaredNamespaceMap.get(namespacePrefix);
+ } else {
+ throw new IllegalStateException();
+ }
+
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // //////////// end of attribute handling
+ // /////////////////////////////////////////////////////////////////////////
+
+ // //////////////////////////////////////////////////////////////////////////
+ // //////////// namespace handling
+ // //////////////////////////////////////////////////////////////////////////
+
+ public String getNamespaceURI(String prefix) {
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ public String getPIData() {
+ throw new UnsupportedOperationException("Yet to be implemented !!");
+ }
+
+ public String getPITarget() {
+ throw new UnsupportedOperationException("Yet to be implemented !!");
+ }
+
+ public String getPrefix() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getPrefix();
+ } else if (state == TEXT_STATE) {
+ return null;
+ } else {
+ return elementQName.getPrefix();
+ }
+ }
+
+ /**
+ * @param key
+ * @return
+ * @throws IllegalArgumentException
+ */
+ public Object getProperty(String key) throws IllegalArgumentException {
+ if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) {
+ return null;
+ } else if (state == TEXT_STATE) {
+ return null;
+ } else if (state == DELEGATED_STATE) {
+ return childReader.getProperty(key);
+ } else {
+ return null;
+ }
+
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // /////// end of namespace handling
+ // /////////////////////////////////////////////////////////////////////////
+
+ public String getText() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getText();
+ } else if (state == TEXT_STATE) {
+ return (String) properties[currentPropertyIndex - 1].getValue();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextCharacters();
+ } else if (state == TEXT_STATE) {
+ return properties[currentPropertyIndex - 1].getValue() == null ? new char[0]
+ : ((String) properties[currentPropertyIndex - 1].getValue()).toCharArray();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextCharacters(i, chars, i1, i2);
+ } else if (state == TEXT_STATE) {
+ // todo - implement this
+ return 0;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextLength();
+ } else if (state == TEXT_STATE) {
+ return 0; // assume text always starts at 0
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextStart() {
+ if (state == DELEGATED_STATE) {
+ return childReader.getTextStart();
+ } else if (state == TEXT_STATE) {
+ return 0; // assume text always starts at 0
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getVersion() {
+ return null;
+ }
+
+ public boolean hasName() {
+ // since this parser always has a name, the hasname
+ // has to return true if we are still navigating this element
+ // if not we should ask the child reader for it.
+ if (state == DELEGATED_STATE) {
+ return childReader.hasName();
+ } else {
+ return state != TEXT_STATE;
+ }
+ }
+
+ /**
+ * @return
+ * @throws XMLStreamException
+ */
+ public boolean hasNext() throws XMLStreamException {
+ if (state == DELEGATED_STATE) {
+ if (childReader.isEndOfFragment()) {
+ // the child reader is done. We shouldn't be getting the
+ // hasnext result from the child pullparser then
+ return true;
+ } else {
+ return childReader.hasNext();
+ }
+ } else {
+ return state == START_ELEMENT_STATE || state == TEXT_STATE;
+
+ }
+ }
+
+ /**
+ * check the validity of this implementation
+ *
+ * @return
+ */
+ public boolean hasText() {
+ if (state == DELEGATED_STATE) {
+ return childReader.hasText();
+ } else {
+ return state == TEXT_STATE;
+ }
+ }
+
+ /**
+ * we need to split out the calling to the populate namespaces seperately since this needs to be done *after*
+ * setting the parent namespace context. We cannot assume it will happen at construction!
+ */
+ public void init() {
+ // here we have an extra issue to attend to. we need to look at the
+ // prefixes and uris (the combination) and populate a hashmap of
+ // namespaces. The hashmap of namespaces will be used to serve the
+ // namespace context
+
+ populateNamespaceContext();
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ return false; // not supported
+ }
+
+ public boolean isCharacters() {
+ if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) {
+ return false;
+ }
+ return childReader.isCharacters();
+ }
+
+ public boolean isEndElement() {
+ if (state == START_ELEMENT_STATE) {
+ return false;
+ } else if (state == END_ELEMENT_STATE) {
+ return true;
+ }
+ return childReader.isEndElement();
+ }
+
+ /**
+ * are we done ?
+ *
+ * @return
+ */
+ public boolean isEndOfFragment() {
+ return state == END_ELEMENT_STATE;
+ }
+
+ public boolean isStandalone() {
+ return true;
+ }
+
+ public boolean isStartElement() {
+ if (state == START_ELEMENT_STATE) {
+ return true;
+ } else if (state == END_ELEMENT_STATE) {
+ return false;
+ }
+ return childReader.isStartElement();
+ }
+
+ public boolean isWhiteSpace() {
+ if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) {
+ return false;
+ }
+ return childReader.isWhiteSpace();
+ }
+
+ /**
+ * Get the prefix list from the hastable and take that into an array
+ *
+ * @return
+ */
+ private String[] makePrefixArray() {
+ String[] prefixes =
+ (String[]) declaredNamespaceMap.keySet().toArray(new String[declaredNamespaceMap.size()]);
+ Arrays.sort(prefixes);
+ return prefixes;
+ }
+
+ public int next() throws XMLStreamException {
+ return updateStatus();
+ }
+
+ /**
+ * todo implement this
+ *
+ * @return
+ * @throws XMLStreamException
+ */
+ public int nextTag() throws XMLStreamException {
+ return 0;
+ }
+
+ // /////////////////////////////////////////////////////////////////////////
+ // / Other utility methods
+ // ////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Populates a namespace context
+ */
+ private void populateNamespaceContext() {
+
+ // first add the current element namespace to the namespace context
+ // declare it if not found
+ registerNamespace(elementQName.getPrefix(), elementQName.getNamespaceURI());
+
+ // traverse through the attributes and populate the namespace context
+ // the attrib list can be of many combinations
+ // the valid combinations are
+ // String - String
+ // QName - QName
+ // null - OMAttribute
+
+ if (attributes != null) {
+ for (int i = 0; i < attributes.length; i++) { // jump in two
+ Object attribName = attributes[i].getKey();
+ if (attribName instanceof String) {
+ // ignore this case - Nothing to do
+ } else if (attribName instanceof QName) {
+ QName attribQName = (QName) attribName;
+ registerNamespace(attribQName.getPrefix(), attribQName.getNamespaceURI());
+
+ }
+ }
+ }
+
+ }
+
+ public final void populateProperties() {
+ if (properties != null) {
+ return;
+ }
+ if (elementQName == null) {
+ elementQName = namespaceContext.createQName(this.rootElementURI, this.rootElementName);
+ } else {
+ elementQName =
+ namespaceContext.createQName(elementQName.getNamespaceURI(), elementQName.getLocalPart());
+ }
+
+ List<Object> elementList = new ArrayList<Object>();
+ List<Object> attributeList = new ArrayList<Object>();
+ NamedNodeMap nodeMap = rootElement.getAttributes();
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ Attr attr = (Attr) nodeMap.item(i);
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attr.getNamespaceURI())) {
+ // Skip xmlns:xxx
+ registerNamespace(attr.getLocalName(), attr.getValue());
+ continue;
+ }
+ QName attrName = new QName(attr.getNamespaceURI(), attr.getLocalName());
+ NameValuePair pair = new NameValuePair(attrName, attr.getValue());
+ attributeList.add(pair);
+ }
+ NodeList nodeList = rootElement.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ switch (node.getNodeType()) {
+ case Node.TEXT_NODE:
+ case Node.CDATA_SECTION_NODE:
+ NameValuePair pair = new NameValuePair(ELEMENT_TEXT, ((CharacterData) node).getData());
+ elementList.add(pair);
+ break;
+
+ case Node.ELEMENT_NODE:
+ Element element = (Element) node;
+ QName elementName = new QName(element.getNamespaceURI(), element.getLocalName());
+ pair = new NameValuePair(elementName, new DOMXMLStreamReader(element));
+ elementList.add(pair);
+ break;
+ }
+ }
+ properties = elementList.toArray(new Map.Entry[elementList.size()]);
+ attributes = attributeList.toArray(new Map.Entry[attributeList.size()]);
+ }
+
+ /**
+ * A convenient method to reuse the properties
+ *
+ * @return event to be thrown
+ * @throws XMLStreamException
+ */
+ private int processProperties() throws XMLStreamException {
+ // move to the next property depending on the current property
+ // index
+ Object propPointer = properties[currentPropertyIndex].getKey();
+ QName propertyQName = null;
+ boolean textFound = false;
+ if (propPointer == null) {
+ throw new XMLStreamException("property key cannot be null!");
+ } else if (propPointer instanceof String) {
+ // propPointer being a String has a special case
+ // that is it can be a the special constant ELEMENT_TEXT that
+ // says this text event
+ if (ELEMENT_TEXT.equals(propPointer)) {
+ textFound = true;
+ } else {
+ propertyQName = new QName((String) propPointer);
+ }
+ } else if (propPointer instanceof QName) {
+ propertyQName = (QName) propPointer;
+ } else {
+ // oops - we've no idea what kind of key this is
+ throw new XMLStreamException("unidentified property key!!!" + propPointer);
+ }
+
+ // ok! we got the key. Now look at the value
+ Object propertyValue = properties[currentPropertyIndex].getValue();
+ // cater for the special case now
+ if (textFound) {
+ // no delegation here - make the parser null and immediately
+ // return with the event characters
+ childReader = null;
+ state = TEXT_STATE;
+ currentPropertyIndex++;
+ return CHARACTERS;
+ } else if (propertyValue == null || propertyValue instanceof String) {
+ // strings are handled by the NameValuePairStreamReader
+ childReader = new SimpleElementStreamReader(propertyQName, (String) propertyValue);
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ } else if (propertyValue instanceof DOMXMLStreamReader) {
+ // ADBbean has it's own method to get a reader
+ XMLFragmentStreamReader reader = (DOMXMLStreamReader) propertyValue;
+ // we know for sure that this is an ADB XMLStreamreader.
+ // However we need to make sure that it is compatible
+ childReader = reader;
+ childReader.setParentNamespaceContext(this.namespaceContext);
+ childReader.init();
+ } else {
+ // all special possiblilities has been tried! Let's treat
+ // the thing as a bean and try generating events from it
+ throw new UnsupportedOperationException("Not supported");
+ // childReader = new
+ // WrappingXMLStreamReader(BeanUtil.getPullParser(propertyValue,
+ // propertyQName));
+ // we cannot register the namespace context here
+ }
+
+ // set the state here
+ state = DELEGATED_STATE;
+ // we are done with the delegation
+ // increment the property index
+ currentPropertyIndex++;
+ return childReader.getEventType();
+ }
+
+ /**
+ * @param prefix
+ * @param uri
+ */
+ private void registerNamespace(String prefix, String uri) {
+ if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) {
+ namespaceContext.registerMapping(prefix, uri);
+ declaredNamespaceMap.put(prefix, uri);
+ }
+ }
+
+ public void require(int i, String string, String string1) throws XMLStreamException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * add the namespace context
+ */
+
+ public void setParentNamespaceContext(NamespaceContext nsContext) {
+ // register the namespace context passed in to this
+ this.namespaceContext.setParent(nsContext);
+
+ }
+
+ public boolean standaloneSet() {
+ return true;
+ }
+
+ /**
+ * By far this should be the most important method in this class this method changes the state of the parser
+ * according to the change in the
+ */
+ private int updateStatus() throws XMLStreamException {
+ int returnEvent = -1; // invalid state is the default state
+ switch (state) {
+ case START_ELEMENT_STATE:
+ // current element is start element. We should be looking at the
+ // property list and making a pullparser for the property value
+ if (properties == null || properties.length == 0) {
+ // no properties - move to the end element state
+ // straightaway
+ state = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ } else {
+ // there are properties. now we should delegate this task to
+ // a
+ // child reader depending on the property type
+ returnEvent = processProperties();
+
+ }
+ break;
+ case END_ELEMENT_STATE:
+ // we've reached the end element already. If the user tries to
+ // push
+ // further ahead then it is an exception
+ throw new XMLStreamException("Trying to go beyond the end of the pullparser");
+
+ case DELEGATED_STATE:
+ if (childReader.isEndOfFragment()) {
+ // we've reached the end!
+ if (currentPropertyIndex > (properties.length - 1)) {
+ state = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ } else {
+ returnEvent = processProperties();
+ }
+ } else {
+ returnEvent = childReader.next();
+ }
+ break;
+
+ case TEXT_STATE:
+ // if there are any more event we should be delegating to
+ // processProperties. if not we just return an end element
+ if (currentPropertyIndex > (properties.length - 1)) {
+ state = END_ELEMENT_STATE;
+ returnEvent = END_ELEMENT;
+ } else {
+ returnEvent = processProperties();
+ }
+ break;
+ }
+ return returnEvent;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java
new file mode 100644
index 0000000000..e9757fa13c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+/**
+ * Push DOM InputSource to Node
+ */
+@Service(Transformer.class)
+public class InputSource2Node extends TransformerExtension<InputSource, Node> implements
+ PullTransformer<InputSource, Node> {
+ private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ public Node transform(InputSource source, TransformationContext context) {
+ try {
+ Source streamSource = new StreamSource(source.getCharacterStream());
+ DOMResult result = new DOMResult();
+ TRANSFORMER.transform(streamSource, result, context);
+ return result.getNode();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return InputSource.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java
new file mode 100644
index 0000000000..be78a07ede
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Push InputSource to SAX
+ */
+@Service(Transformer.class)
+public class InputSource2SAX extends TransformerExtension<InputSource, ContentHandler> implements
+ PushTransformer<InputSource, ContentHandler> {
+
+ public void transform(InputSource source, ContentHandler target, TransformationContext context) {
+ try {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+ reader.setContentHandler(target);
+ reader.parse(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return InputSource.class;
+ }
+
+ public Class getTargetType() {
+ return ContentHandler.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java
new file mode 100644
index 0000000000..e103c82b33
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXSource;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+/**
+ * Push DOM InputSource to Node
+ */
+@Service(Transformer.class)
+public class InputStream2Node extends TransformerExtension<InputStream, Node> implements
+ PullTransformer<InputStream, Node> {
+ private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ public Node transform(InputStream source, TransformationContext context) {
+ try {
+ Source streamSource = new SAXSource(new InputSource(source));
+ DOMResult result = new DOMResult();
+ TRANSFORMER.transform(streamSource, result, context);
+ return result.getNode();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return InputStream.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java
new file mode 100644
index 0000000000..d74863ea95
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.InputStream;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Push InputStream to SAX
+ */
+@Service(Transformer.class)
+public class InputStream2SAX extends TransformerExtension<InputStream, ContentHandler> implements
+ PushTransformer<InputStream, ContentHandler> {
+ public void transform(InputStream source, ContentHandler target, TransformationContext context) {
+ try {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setContentHandler(target);
+ reader.parse(new InputSource(source));
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return InputStream.class;
+ }
+
+ public Class getTargetType() {
+ return ContentHandler.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java
new file mode 100644
index 0000000000..ec0560e878
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.SimpleType2JavaTransformer;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Transformer to convert data from an simple Node to Java Object
+ */
+@Service(Transformer.class)
+public class Node2Object extends SimpleType2JavaTransformer<Node> {
+
+ public Node2Object() {
+ super(null);
+ }
+
+ @Override
+ protected String getText(Node source) {
+ if (source instanceof Document) {
+ source = ((Document)source).getDocumentElement();
+ }
+ return source.getTextContent();
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java
new file mode 100644
index 0000000000..34fbdf8c6f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.OutputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+/**
+ * Push DOM Node to OutputStream
+ */
+@Service(Transformer.class)
+public class Node2OutputStream extends TransformerExtension<Node, OutputStream> implements
+ PushTransformer<Node, OutputStream> {
+ private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ public void transform(Node source, OutputStream writer, TransformationContext context) {
+ try {
+ Source domSource = new DOMSource(source);
+ Result result = new StreamResult(writer);
+ TRANSFORMER.transform(domSource, result, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public Class getTargetType() {
+ return OutputStream.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java
new file mode 100755
index 0000000000..92378e96a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.StringWriter;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+/**
+ * Transform DOM Node to XML String
+ */
+@Service(org.apache.tuscany.spi.databinding.Transformer.class)
+public class Node2String extends TransformerExtension<Node, String> implements PullTransformer<Node, String> {
+ private static final Node2Writer TRANSFORMER = new Node2Writer();
+
+ public String transform(Node source, TransformationContext context) {
+ try {
+ StringWriter writer = new StringWriter();
+ TRANSFORMER.transform(source, writer, context);
+ return writer.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public Class getTargetType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java
new file mode 100644
index 0000000000..96328fdd2f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.Writer;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+/**
+ * Push DOM Node to Writer
+ */
+@Service(Transformer.class)
+public class Node2Writer extends TransformerExtension<Node, Writer> implements PushTransformer<Node, Writer> {
+ private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ public void transform(Node source, Writer writer, TransformationContext context) {
+ try {
+ Source domSource = new DOMSource(source);
+ Result result = new StreamResult(writer);
+ TRANSFORMER.transform(domSource, result, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public Class getTargetType() {
+ return Writer.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java
new file mode 100644
index 0000000000..bff9051e01
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.core.databinding.xml.StAXHelper.XMLDocumentStreamReader;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+/**
+ * Transform DOM Node to XML XMLStreamReader
+ */
+@Service(Transformer.class)
+public class Node2XMLStreamReader extends TransformerExtension<Node, XMLStreamReader> implements
+ PullTransformer<Node, XMLStreamReader> {
+
+ public XMLStreamReader transform(Node source, TransformationContext context) {
+ try {
+ DOMXMLStreamReader reader = new DOMXMLStreamReader(source);
+ return new XMLDocumentStreamReader(reader);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java
new file mode 100644
index 0000000000..7f472ba4ff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.databinding.extension.Java2SimpleTypeTransformer;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * Transformer to convert data from a simple java object to Node
+ */
+@Service(Transformer.class)
+public class Object2Node extends Java2SimpleTypeTransformer<Node> {
+
+ private Document factory;
+
+ public Object2Node() {
+ super(null);
+ try {
+ factory = DOMHelper.newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ protected Node createElement(ElementInfo element, String text, TransformationContext context) {
+ QName name = element.getQName();
+ Node root = DOMHelper.createElement(factory, name);
+ root.appendChild(factory.createTextNode(text));
+ return root;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java
new file mode 100644
index 0000000000..02de055c35
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.Reader;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+/**
+ * Push DOM Reader to Node
+ */
+@Service(Transformer.class)
+public class Reader2Node extends TransformerExtension<Reader, Node> implements PullTransformer<Reader, Node> {
+ private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ public Node transform(Reader source, TransformationContext context) {
+ try {
+ Source streamSource = new StreamSource(source);
+ DOMResult result = new DOMResult();
+ TRANSFORMER.transform(streamSource, result, context);
+ return result.getNode();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Reader.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java
new file mode 100644
index 0000000000..0a4504b3de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.Reader;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+
+/**
+ * Transform XML string to SAX
+ */
+@Service(Transformer.class)
+public class Reader2SAX extends TransformerExtension<Reader, ContentHandler> implements
+ PushTransformer<Reader, ContentHandler> {
+ public void transform(Reader source, ContentHandler target, TransformationContext context) {
+ try {
+ new InputSource2SAX().transform(new InputSource(source), target, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Reader.class;
+ }
+
+ public Class getTargetType() {
+ return ContentHandler.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java
new file mode 100644
index 0000000000..8f8f0f952e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * SAX2DOM adapter
+ */
+public class SAX2DOM implements ContentHandler, LexicalHandler {
+ public static final String EMPTYSTRING = "";
+ public static final String XML_PREFIX = "xml";
+ public static final String XMLNS_PREFIX = "xmlns";
+ public static final String XMLNS_STRING = "xmlns:";
+ public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
+
+ private Node root;
+
+ private Document document;
+
+ private Node nextSibling;
+
+ private Stack<Node> nodeStk = new Stack<Node>();
+
+ private List<String> namespaceDecls;
+
+ private Node lastSibling;
+
+ public SAX2DOM() throws ParserConfigurationException {
+ this.document = DOMHelper.newDocument();
+ this.root = document;
+ }
+
+ public SAX2DOM(Node root, Node nextSibling) throws ParserConfigurationException {
+ this.root = root;
+ if (root instanceof Document) {
+ this.document = (Document)root;
+ } else if (root != null) {
+ this.document = root.getOwnerDocument();
+ } else {
+ this.document = DOMHelper.newDocument();
+ this.root = document;
+ }
+
+ this.nextSibling = nextSibling;
+ }
+
+ public SAX2DOM(Node root) throws ParserConfigurationException {
+ this(root, null);
+ }
+
+ public Node getDOM() {
+ return root;
+ }
+
+ public void characters(char[] ch, int start, int length) {
+ final Node last = (Node)nodeStk.peek();
+
+ // No text nodes can be children of root (DOM006 exception)
+ if (last != document) {
+ final String text = new String(ch, start, length);
+ if (lastSibling != null && lastSibling.getNodeType() == Node.TEXT_NODE) {
+ ((Text)lastSibling).appendData(text);
+ } else if (last == root && nextSibling != null) {
+ lastSibling = last.insertBefore(document.createTextNode(text), nextSibling);
+ } else {
+ lastSibling = last.appendChild(document.createTextNode(text));
+ }
+
+ }
+ }
+
+ public void startDocument() {
+ nodeStk.push(root);
+ }
+
+ public void endDocument() {
+ nodeStk.pop();
+ }
+
+ public void startElement(String namespace, String localName, String qName, Attributes attrs) {
+ final Element tmp = (Element)document.createElementNS(namespace, qName);
+
+ // Add namespace declarations first
+ if (namespaceDecls != null) {
+ final int nDecls = namespaceDecls.size();
+ for (int i = 0; i < nDecls; i++) {
+ final String prefix = (String)namespaceDecls.get(i++);
+
+ if (prefix == null || prefix.equals(EMPTYSTRING)) {
+ tmp.setAttributeNS(XMLNS_URI, XMLNS_PREFIX, (String)namespaceDecls.get(i));
+ } else {
+ tmp.setAttributeNS(XMLNS_URI, XMLNS_STRING + prefix, (String)namespaceDecls.get(i));
+ }
+ }
+ namespaceDecls.clear();
+ }
+
+ // Add attributes to element
+ final int nattrs = attrs.getLength();
+ for (int i = 0; i < nattrs; i++) {
+ if (attrs.getLocalName(i) == null) {
+ tmp.setAttribute(attrs.getQName(i), attrs.getValue(i));
+ } else {
+ tmp.setAttributeNS(attrs.getURI(i), attrs.getQName(i), attrs.getValue(i));
+ }
+ }
+
+ // Append this new node onto current stack node
+ Node last = (Node)nodeStk.peek();
+
+ // If the SAX2DOM is created with a non-null next sibling node,
+ // insert the result nodes before the next sibling under the root.
+ if (last == root && nextSibling != null) {
+ last.insertBefore(tmp, nextSibling);
+ } else {
+ last.appendChild(tmp);
+ }
+
+ // Push this node onto stack
+ nodeStk.push(tmp);
+ lastSibling = null;
+ }
+
+ public void endElement(String namespace, String localName, String qName) {
+ nodeStk.pop();
+ lastSibling = null;
+ }
+
+ public void startPrefixMapping(String prefix, String uri) {
+ if (namespaceDecls == null) {
+ namespaceDecls = new ArrayList<String>(2);
+ }
+ namespaceDecls.add(prefix);
+ namespaceDecls.add(uri);
+ }
+
+ public void endPrefixMapping(String prefix) {
+ // do nothing
+ }
+
+ /**
+ * This class is only used internally so this method should never be called.
+ */
+ public void ignorableWhitespace(char[] ch, int start, int length) {
+ }
+
+ /**
+ * adds processing instruction node to DOM.
+ */
+ public void processingInstruction(String target, String data) {
+ final Node last = (Node)nodeStk.peek();
+ ProcessingInstruction pi = document.createProcessingInstruction(target, data);
+ if (pi != null) {
+ if (last == root && nextSibling != null) {
+ last.insertBefore(pi, nextSibling);
+ } else {
+ last.appendChild(pi);
+ }
+
+ lastSibling = pi;
+ }
+ }
+
+ /**
+ * This class is only used internally so this method should never be called.
+ */
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ /**
+ * This class is only used internally so this method should never be called.
+ */
+ public void skippedEntity(String name) {
+ }
+
+ /**
+ * Lexical Handler method to create comment node in DOM tree.
+ */
+ public void comment(char[] ch, int start, int length) {
+ final Node last = (Node)nodeStk.peek();
+ Comment comment = document.createComment(new String(ch, start, length));
+ if (comment != null) {
+ if (last == root && nextSibling != null) {
+ last.insertBefore(comment, nextSibling);
+ } else {
+ last.appendChild(comment);
+ }
+
+ lastSibling = comment;
+ }
+ }
+
+ // Lexical Handler methods- not implemented
+ public void startCDATA() {
+ }
+
+ public void endCDATA() {
+ }
+
+ public void startEntity(java.lang.String name) {
+ }
+
+ public void endDTD() {
+ }
+
+ public void endEntity(String name) {
+ }
+
+ public void startDTD(String name, String publicId, String systemId) throws SAXException {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java
new file mode 100644
index 0000000000..79118b4a2c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tuscany.spi.databinding.DataPipe;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+
+@Service(Transformer.class)
+public class SAX2DOMPipe extends TransformerExtension<ContentHandler, Node> implements
+ DataPipe<ContentHandler, Node> {
+ private SAX2DOM pipe;
+
+ /**
+ *
+ */
+ public SAX2DOMPipe() {
+ super();
+ try {
+ this.pipe = new SAX2DOM();
+ } catch (ParserConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Node getResult() {
+ return pipe.getDOM();
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public ContentHandler getSink() {
+ return pipe;
+ }
+
+ public Class getSourceType() {
+ return ContentHandler.class;
+ }
+
+ public int getWeight() {
+ return 30;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java
new file mode 100755
index 0000000000..7db14efb39
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transform TrAX Source to Result
+ */
+@Service(org.apache.tuscany.spi.databinding.Transformer.class)
+public class Source2ResultTransformer extends TransformerExtension<Source, Result> implements
+ PushTransformer<Source, Result> {
+ private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
+
+ public void transform(Source source, Result result, TransformationContext context) {
+ try {
+ javax.xml.transform.Transformer transformer = FACTORY.newTransformer();
+ transformer.transform(source, result);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Source.class;
+ }
+
+ public Class getTargetType() {
+ return Result.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java
new file mode 100644
index 0000000000..63fa53edb4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * Adapter that converts from StAX to SAX event streams. Currently the following
+ * SAX events are not generated:
+ * <ul>
+ * <li>ignorableWhitespace</li>
+ * <li>skippedEntity</li>
+ * <ul>
+ * Also the following StAX events are not mapped:
+ * <ul>
+ * <li>CDATA</li>
+ * <li>COMMENT</li>
+ * <li>DTD</li>
+ * <li>ENTITY_DECLARATION</li>
+ * <li>ENTITY_REFERENCE</li>
+ * <li>NOTATION_DECLARATION</li>
+ * <li>SPACE</li>
+ * </ul>
+ * StAX ATTRIBUTE events are ignored but the equivalent attributes (derived from
+ * the START_ELEMENT event) are supplied in the SAX startElement event's
+ * Attributes parameter. If the adaptor is configured to pass namespace prefixes
+ * then namespace information will also be included in the Attributes; StAX
+ * NAMESPACE events are ignored. <p/> Another issue is namespace processing. If
+ * the reader is positioned at a sub-node, we cannot capture all the in-scope
+ * namespace bindings. Therefore we cannot re-create a proper SAX event stream
+ * from a StAX parser. <p/> For example <p/> &lt;a:root xmlns:a="foo"
+ * xmlns:b="bar"&gt;&lt;b:sub&gt;a:foo&lt;/b:sub&gt;&lt;/a:root&gt; <p/> And if
+ * you are handed a parser at &lt;b:sub&gt;, then your SAX events should look
+ * like: <p/> &lt;b:sub xmlns:a="foo" xmlns:b="bar"&gt;a:foo&lt;/b:sub&gt; <p/>
+ * not: <p/> &lt;b:sub&gt;a:foo&lt;/b:sub&gt; <p/> <p/> Proposal: we change the
+ * receiver of SAX events (SDOXMLResourceImpl) so that it uses NamespaceContext
+ * to resolve prefix (as opposed to record start/endPrefixMappings and use it
+ * for resolution.)
+ *
+ * @version $Rev$ $Date$
+ */
+public class StAX2SAXAdapter {
+ private final boolean namespacePrefixes;
+
+ /**
+ * Construct a new StAX to SAX adapter that will convert a StAX event stream
+ * into a SAX event stream.
+ *
+ * @param namespacePrefixes whether xmlns attributes should be included in
+ * startElement events;
+ */
+ public StAX2SAXAdapter(boolean namespacePrefixes) {
+ this.namespacePrefixes = namespacePrefixes;
+ }
+
+ /**
+ * Pull events from the StAX stream and dispatch to the SAX ContentHandler.
+ * The StAX stream would typically be located on a START_DOCUMENT or
+ * START_ELEMENT event and when this method returns it will be located on
+ * the associated END_DOCUMENT or END_ELEMENT event. Behaviour with other
+ * start events is undefined.
+ *
+ * @param reader StAX event source to read
+ * @param handler SAX ContentHandler for processing events
+ * @throws XMLStreamException if there was a problem reading the stream
+ * @throws SAXException passed through from the ContentHandler
+ */
+ public void parse(XMLStreamReader reader, ContentHandler handler) throws XMLStreamException, SAXException {
+ handler.setDocumentLocator(new LocatorAdaptor(reader.getLocation()));
+
+ // remembers the nest level of elements to know when we are done
+ int level = 0;
+ int event = reader.getEventType();
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_DOCUMENT:
+ level++;
+ handler.startDocument();
+ break;
+ case XMLStreamConstants.START_ELEMENT:
+ level++;
+ handleStartElement(reader, handler);
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ handler.processingInstruction(reader.getPITarget(), reader.getPIData());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ handler.characters(reader.getTextCharacters(), reader.getTextStart(), reader
+ .getTextLength());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ handleEndElement(reader, handler);
+ level--;
+ if (level == 0) {
+ return;
+ }
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ handler.endDocument();
+ return;
+ /*
+ * uncomment to handle all events rather than just mapped
+ * ones // StAX events that are not mapped to SAX case
+ * XMLStreamConstants.COMMENT: case
+ * XMLStreamConstants.SPACE: case
+ * XMLStreamConstants.ENTITY_REFERENCE: case
+ * XMLStreamConstants.DTD: case XMLStreamConstants.CDATA:
+ * case XMLStreamConstants.NOTATION_DECLARATION: case
+ * XMLStreamConstants.ENTITY_DECLARATION: break; // StAX
+ * events handled in START_ELEMENT case
+ * XMLStreamConstants.ATTRIBUTE: case
+ * XMLStreamConstants.NAMESPACE: break; default: throw new
+ * AssertionError("Unknown StAX event: " + event);
+ */
+ }
+ event = reader.next();
+ }
+ }
+
+ private void handleStartElement(XMLStreamReader reader, ContentHandler handler) throws SAXException {
+ // send startPrefixMapping events immediately before startElement event
+ int nsCount = reader.getNamespaceCount();
+ for (int i = 0; i < nsCount; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ if (prefix == null) { // true for default namespace
+ prefix = "";
+ }
+ handler.startPrefixMapping(prefix, reader.getNamespaceURI(i));
+ }
+
+ // fire startElement
+ QName qname = reader.getName();
+ String prefix = qname.getPrefix();
+ String rawname;
+ if (prefix == null || prefix.length() == 0) {
+ rawname = qname.getLocalPart();
+ } else {
+ rawname = prefix + ':' + qname.getLocalPart();
+ }
+ Attributes attrs = getAttributes(reader);
+ handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs);
+ }
+
+ private static void handleEndElement(XMLStreamReader reader, ContentHandler handler) throws SAXException {
+ // fire endElement
+ QName qname = reader.getName();
+ handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString());
+
+ // send endPrefixMapping events immediately after endElement event
+ // we send them in the opposite order to that returned but this is not
+ // actually required by SAX
+ int nsCount = reader.getNamespaceCount();
+ for (int i = nsCount - 1; i >= 0; i--) {
+ String prefix = reader.getNamespacePrefix(i);
+ if (prefix == null) { // true for default namespace
+ prefix = "";
+ }
+ handler.endPrefixMapping(prefix);
+ }
+ }
+
+ /**
+ * Get the attributes associated with the current START_ELEMENT event.
+ *
+ * @return the StAX attributes converted to org.xml.sax.Attributes
+ */
+ private Attributes getAttributes(XMLStreamReader reader) {
+ assert reader.getEventType() == XMLStreamConstants.START_ELEMENT;
+
+ AttributesImpl attrs = new AttributesImpl();
+
+ // add namespace declarations if required
+ if (namespacePrefixes) {
+ for (int i = 0; i < reader.getNamespaceCount(); i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String uri = reader.getNamespaceURI(i);
+ attrs.addAttribute(null, prefix, "xmlns:" + prefix, "CDATA", uri);
+ }
+ }
+
+ // Regular attributes
+ for (int i = 0; i < reader.getAttributeCount(); i++) {
+ String uri = reader.getAttributeNamespace(i);
+ if (uri == null) {
+ uri = "";
+ }
+ String localName = reader.getAttributeLocalName(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname;
+ if (prefix == null || prefix.length() == 0) {
+ qname = localName;
+ } else {
+ qname = prefix + ':' + localName;
+ }
+ String type = reader.getAttributeType(i);
+ String value = reader.getAttributeValue(i);
+
+ attrs.addAttribute(uri, localName, qname, type, value);
+ }
+
+ return attrs;
+ }
+
+ /**
+ * Adaptor for mapping Locator information.
+ */
+ private static final class LocatorAdaptor implements Locator {
+ private final Location location;
+
+ private LocatorAdaptor(Location location) {
+ this.location = location;
+ }
+
+ public int getColumnNumber() {
+ return location == null ? 0 : location.getColumnNumber();
+ }
+
+ public int getLineNumber() {
+ return location == null ? 0 : location.getLineNumber();
+ }
+
+ public String getPublicId() {
+ return location == null ? "" : location.getPublicId();
+ }
+
+ public String getSystemId() {
+ return location == null ? "" : location.getSystemId();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java
new file mode 100755
index 0000000000..db0eae165f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java
@@ -0,0 +1,820 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.NoSuchElementException;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+
+public final class StAXHelper {
+
+ private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory.newInstance();
+
+ private static final XMLOutputFactory OUTPUT_FACTORY = XMLOutputFactory.newInstance();
+
+ private StAXHelper() {
+ }
+
+ /**
+ * This class is derived from Apache Axis2 class
+ * org.apache.axis2.util.StreamWrapper</a>. It's used wrap a
+ * XMLStreamReader to create a XMLStreamReader representing a document and
+ * it will produce START_DOCUMENT, END_DOCUMENT events.
+ */
+ public static class XMLDocumentStreamReader implements XMLStreamReader {
+ private static final int STATE_COMPLETE_AT_NEXT = 2; // The wrapper
+ // will produce
+ // END_DOCUMENT
+
+ private static final int STATE_COMPLETED = 3; // Done
+
+ private static final int STATE_INIT = 0; // The wrapper will produce
+ // START_DOCUMENT
+
+ private static final int STATE_SWITCHED = 1; // The real reader will
+ // produce events
+
+ private XMLStreamReader realReader;
+
+ private int state = STATE_INIT;
+
+ public XMLDocumentStreamReader(XMLStreamReader realReader) {
+ if (realReader == null) {
+ throw new UnsupportedOperationException("Reader cannot be null");
+ }
+
+ this.realReader = realReader;
+
+ // If the real reader is positioned at START_DOCUMENT, always use
+ // the real reader
+ if (realReader.getEventType() == START_DOCUMENT) {
+ state = STATE_SWITCHED;
+ }
+ }
+
+ public void close() throws XMLStreamException {
+ realReader.close();
+ }
+
+ public int getAttributeCount() {
+ if (isDelegating()) {
+ return realReader.getAttributeCount();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeLocalName(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeLocalName(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public QName getAttributeName(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeName(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeNamespace(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeNamespace(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributePrefix(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributePrefix(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeType(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeType(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeValue(int i) {
+ if (isDelegating()) {
+ return realReader.getAttributeValue(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getAttributeValue(String s, String s1) {
+ if (isDelegating()) {
+ return realReader.getAttributeValue(s, s1);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getCharacterEncodingScheme() {
+ return realReader.getCharacterEncodingScheme();
+ }
+
+ public String getElementText() throws XMLStreamException {
+ if (isDelegating()) {
+ return realReader.getElementText();
+ } else {
+ throw new XMLStreamException();
+ }
+ }
+
+ public String getEncoding() {
+ return realReader.getEncoding();
+ }
+
+ public int getEventType() {
+ int event = -1;
+ switch (state) {
+ case STATE_SWITCHED:
+ case STATE_COMPLETE_AT_NEXT:
+ event = realReader.getEventType();
+ break;
+ case STATE_INIT:
+ event = START_DOCUMENT;
+ break;
+ case STATE_COMPLETED:
+ event = END_DOCUMENT;
+ break;
+ }
+ return event;
+ }
+
+ public String getLocalName() {
+ if (isDelegating()) {
+ return realReader.getLocalName();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public Location getLocation() {
+ if (isDelegating()) {
+ return realReader.getLocation();
+ } else {
+ return null;
+ }
+ }
+
+ public QName getName() {
+ if (isDelegating()) {
+ return realReader.getName();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return realReader.getNamespaceContext();
+ }
+
+ public int getNamespaceCount() {
+ if (isDelegating()) {
+ return realReader.getNamespaceCount();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespacePrefix(int i) {
+ if (isDelegating()) {
+ return realReader.getNamespacePrefix(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI() {
+ if (isDelegating()) {
+ return realReader.getNamespaceURI();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI(int i) {
+ if (isDelegating()) {
+ return realReader.getNamespaceURI(i);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getNamespaceURI(String s) {
+ if (isDelegating()) {
+ return realReader.getNamespaceURI(s);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPIData() {
+ if (isDelegating()) {
+ return realReader.getPIData();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPITarget() {
+ if (isDelegating()) {
+ return realReader.getPITarget();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getPrefix() {
+ if (isDelegating()) {
+ return realReader.getPrefix();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public Object getProperty(String s) throws IllegalArgumentException {
+ if (isDelegating()) {
+ return realReader.getProperty(s);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public String getText() {
+ if (isDelegating()) {
+ return realReader.getText();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public char[] getTextCharacters() {
+ if (isDelegating()) {
+ return realReader.getTextCharacters();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+ if (isDelegating()) {
+ return realReader.getTextCharacters(i, chars, i1, i2);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextLength() {
+ if (isDelegating()) {
+ return realReader.getTextLength();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getTextStart() {
+ if (isDelegating()) {
+ return realReader.getTextStart();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getVersion() {
+ if (isDelegating()) {
+ return realReader.getVersion();
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasName() {
+ if (isDelegating()) {
+ return realReader.hasName();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean hasNext() throws XMLStreamException {
+ if (state == STATE_COMPLETE_AT_NEXT) {
+ return true;
+ } else if (state == STATE_COMPLETED) {
+ return false;
+ } else if (state == STATE_SWITCHED) {
+ return realReader.hasNext();
+ } else {
+ return true;
+ }
+ }
+
+ public boolean hasText() {
+ if (isDelegating()) {
+ return realReader.hasText();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isAttributeSpecified(int i) {
+ if (isDelegating()) {
+ return realReader.isAttributeSpecified(i);
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isCharacters() {
+ if (isDelegating()) {
+ return realReader.isCharacters();
+ } else {
+ return false;
+ }
+ }
+
+ private boolean isDelegating() {
+ return state == STATE_SWITCHED || state == STATE_COMPLETE_AT_NEXT;
+ }
+
+ public boolean isEndElement() {
+ if (isDelegating()) {
+ return realReader.isEndElement();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isStandalone() {
+ if (isDelegating()) {
+ return realReader.isStandalone();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isStartElement() {
+ if (isDelegating()) {
+ return realReader.isStartElement();
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isWhiteSpace() {
+ if (isDelegating()) {
+ return realReader.isWhiteSpace();
+ } else {
+ return false;
+ }
+ }
+
+ public int next() throws XMLStreamException {
+ int returnEvent = -1;
+
+ switch (state) {
+ case STATE_SWITCHED:
+ returnEvent = realReader.next();
+ if (returnEvent == END_DOCUMENT) {
+ state = STATE_COMPLETED;
+ } else if (!realReader.hasNext()) {
+ state = STATE_COMPLETE_AT_NEXT;
+ }
+ break;
+ case STATE_INIT:
+ state = STATE_SWITCHED;
+ returnEvent = realReader.getEventType();
+ break;
+ case STATE_COMPLETE_AT_NEXT:
+ state = STATE_COMPLETED;
+ returnEvent = END_DOCUMENT;
+ break;
+ case STATE_COMPLETED:
+ // oops - no way we can go beyond this
+ throw new NoSuchElementException("End of stream has reached.");
+ default:
+ throw new UnsupportedOperationException();
+ }
+
+ return returnEvent;
+ }
+
+ public int nextTag() throws XMLStreamException {
+ if (isDelegating()) {
+ return realReader.nextTag();
+ } else {
+ throw new XMLStreamException();
+ }
+ }
+
+ public void require(int i, String s, String s1) throws XMLStreamException {
+ if (isDelegating()) {
+ realReader.require(i, s, s1);
+ }
+ }
+
+ public boolean standaloneSet() {
+ if (isDelegating()) {
+ return realReader.standaloneSet();
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public static interface XMLFragmentStreamReader extends XMLStreamReader {
+
+ // this will help to handle Text within the current element.
+ // user should pass the element text to the property list as this
+ // ELEMENT_TEXT as the key. This key deliberately has a space in it
+ // so that it is not a valid XML name
+ String ELEMENT_TEXT = "Element Text";
+
+ /**
+ * Initiate the parser - this will do whatever the needed tasks to
+ * initiate the parser and must be called before attempting any specific
+ * parsing using this parser
+ */
+ void init();
+
+ /**
+ * Extra method to query the state of the pullparser
+ *
+ * @return
+ */
+ boolean isEndOfFragment();
+
+ /**
+ * add the parent namespace context to this parser
+ */
+ void setParentNamespaceContext(NamespaceContext nsContext);
+ }
+
+ /**
+ * The XMLStreamSerializer pulls events from the XMLStreamReader and dumps
+ * into the XMLStreamWriter
+ */
+ public static class XMLStreamSerializer implements XMLStreamConstants {
+
+ public static final String NAMESPACE_PREFIX = "ns";
+
+ private static int namespaceSuffix = 0;
+
+ /*
+ * The behavior of the serializer is such that it returns when it
+ * encounters the starting element for the second time. The depth
+ * variable tracks the depth of the serilizer and tells it when to
+ * return. Note that it is assumed that this serialization starts on an
+ * Element.
+ */
+
+ /**
+ * Field depth
+ */
+ private int depth = 0;
+
+ /**
+ * Generates a unique namespace prefix that is not in the scope of the
+ * NamespaceContext
+ *
+ * @param nsCtxt
+ * @return string
+ */
+ private String generateUniquePrefix(NamespaceContext nsCtxt) {
+ String prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+ // null should be returned if the prefix is not bound!
+ while (nsCtxt.getNamespaceURI(prefix) != null) {
+ prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+ }
+
+ return prefix;
+ }
+
+ /**
+ * Method serialize.
+ *
+ * @param node
+ * @param writer
+ * @throws XMLStreamException
+ */
+ public void serialize(XMLStreamReader node, XMLStreamWriter writer) throws XMLStreamException {
+ serializeNode(node, writer);
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer)
+ throws XMLStreamException {
+ int count = reader.getAttributeCount();
+ String prefix = null;
+ String namespaceName = null;
+ String writerPrefix = null;
+ for (int i = 0; i < count; i++) {
+ prefix = reader.getAttributePrefix(i);
+ namespaceName = reader.getAttributeNamespace(i);
+ /*
+ * Due to parser implementations returning null as the namespace
+ * URI (for the empty namespace) we need to make sure that we
+ * deal with a namespace name that is not null. The best way to
+ * work around this issue is to set the namespace uri to "" if
+ * it is null
+ */
+ if (namespaceName == null) {
+ namespaceName = "";
+ }
+
+ writerPrefix = writer.getNamespaceContext().getPrefix(namespaceName);
+
+ if (!"".equals(namespaceName)) {
+ // prefix has already being declared but this particular
+ // attrib has a
+ // no prefix attached. So use the prefix provided by the
+ // writer
+ if (writerPrefix != null && (prefix == null || prefix.equals(""))) {
+ writer.writeAttribute(writerPrefix,
+ namespaceName,
+ reader.getAttributeLocalName(i),
+ reader.getAttributeValue(i));
+
+ // writer prefix is available but different from the
+ // current
+ // prefix of the attrib. We should be decalring the new
+ // prefix
+ // as a namespace declaration
+ } else if (prefix != null && !"".equals(prefix) && !prefix.equals(writerPrefix)) {
+ writer.writeNamespace(prefix, namespaceName);
+ writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+
+ // prefix is null (or empty), but the namespace name is
+ // valid! it has not
+ // being written previously also. So we need to generate
+ // a prefix
+ // here
+ } else if (prefix == null || prefix.equals("")) {
+ prefix = generateUniquePrefix(writer.getNamespaceContext());
+ writer.writeNamespace(prefix, namespaceName);
+ writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+ } else {
+ writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader
+ .getAttributeValue(i));
+ }
+ } else {
+ // empty namespace is equal to no namespace!
+ writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i));
+ }
+
+ }
+ }
+
+ /**
+ * Method serializeCData.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer)
+ throws XMLStreamException {
+ writer.writeCData(reader.getText());
+ }
+
+ /**
+ * Method serializeComment.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer)
+ throws XMLStreamException {
+ writer.writeComment(reader.getText());
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer)
+ throws XMLStreamException {
+ String prefix = reader.getPrefix();
+ String nameSpaceName = reader.getNamespaceURI();
+ if (nameSpaceName != null) {
+ String writerPrefix = writer.getPrefix(nameSpaceName);
+ if (writerPrefix != null) {
+ writer.writeStartElement(nameSpaceName, reader.getLocalName());
+ } else {
+ if (prefix != null) {
+ writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName);
+ writer.writeNamespace(prefix, nameSpaceName);
+ writer.setPrefix(prefix, nameSpaceName);
+ } else {
+ writer.writeStartElement(nameSpaceName, reader.getLocalName());
+ writer.writeDefaultNamespace(nameSpaceName);
+ writer.setDefaultNamespace(nameSpaceName);
+ }
+ }
+ } else {
+ writer.writeStartElement(reader.getLocalName());
+ }
+
+ // add the namespaces
+ int count = reader.getNamespaceCount();
+ String namespacePrefix;
+ for (int i = 0; i < count; i++) {
+ namespacePrefix = reader.getNamespacePrefix(i);
+ if (namespacePrefix != null && namespacePrefix.length() == 0) {
+ continue;
+ }
+
+ serializeNamespace(namespacePrefix, reader.getNamespaceURI(i), writer);
+ }
+
+ // add attributes
+ serializeAttributes(reader, writer);
+
+ }
+
+ /**
+ * Method serializeEndElement.
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeEndElement();
+ }
+
+ /**
+ * Method serializeNamespace.
+ *
+ * @param prefix
+ * @param uri
+ * @param writer
+ * @throws XMLStreamException
+ */
+ private void serializeNamespace(String prefix, String uri, XMLStreamWriter writer)
+ throws XMLStreamException {
+ String prefix1 = writer.getPrefix(uri);
+ if (prefix1 == null) {
+ writer.writeNamespace(prefix, uri);
+ writer.setPrefix(prefix, uri);
+ }
+ }
+
+ /**
+ * Method serializeNode.
+ *
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer)
+ throws XMLStreamException {
+ // TODO We get the StAXWriter at this point and uses it hereafter
+ // assuming that this is the only entry point
+ // to this class.
+ // If there can be other classes calling methodes of this we might
+ // need to change methode signatures to
+ // OMOutputer
+ while (reader.hasNext()) {
+ int event = reader.next();
+ if (event == START_ELEMENT) {
+ serializeElement(reader, writer);
+ depth++;
+ } else if (event == ATTRIBUTE) {
+ serializeAttributes(reader, writer);
+ } else if (event == CHARACTERS) {
+ serializeText(reader, writer);
+ } else if (event == COMMENT) {
+ serializeComment(reader, writer);
+ } else if (event == CDATA) {
+ serializeCData(reader, writer);
+ } else if (event == END_ELEMENT) {
+ serializeEndElement(writer);
+ depth--;
+ } else if (event == START_DOCUMENT) {
+ depth++; // if a start document is found then increment
+ // the depth
+ } else if (event == END_DOCUMENT) {
+ if (depth != 0) {
+ depth--; // for the end document - reduce the depth
+ }
+ try {
+ serializeEndElement(writer);
+ } catch (Exception e) {
+ // TODO: log exceptions
+ }
+ }
+ if (depth == 0) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * @param reader
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer)
+ throws XMLStreamException {
+ writer.writeCharacters(reader.getText());
+ }
+ }
+
+ public static XMLStreamReader createXMLStreamReader(InputStream inputStream) throws XMLStreamException {
+ XMLStreamReader streamReader = INPUT_FACTORY.createXMLStreamReader(inputStream);
+ return streamReader;
+ }
+
+ public static XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException {
+ XMLStreamReader streamReader = INPUT_FACTORY.createXMLStreamReader(reader);
+ return streamReader;
+ }
+
+ public static XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException {
+ XMLStreamReader reader = INPUT_FACTORY.createXMLStreamReader(source);
+ return reader;
+ }
+
+ public static XMLStreamReader createXMLStreamReader(String string) throws XMLStreamException {
+ StringReader reader = new StringReader(string);
+ return createXMLStreamReader(reader);
+ }
+
+ public static String save(XMLStreamReader reader) throws XMLStreamException {
+ StringWriter writer = new StringWriter();
+ save(reader, writer);
+ return writer.toString();
+ }
+
+ public static void save(XMLStreamReader reader, OutputStream outputStream) throws XMLStreamException {
+ XMLStreamSerializer serializer = new XMLStreamSerializer();
+ XMLStreamWriter streamWriter = OUTPUT_FACTORY.createXMLStreamWriter(outputStream);
+ serializer.serialize(reader, streamWriter);
+ streamWriter.flush();
+ }
+
+ public static void save(XMLStreamReader reader, Writer writer) throws XMLStreamException {
+ XMLStreamSerializer serializer = new XMLStreamSerializer();
+ XMLStreamWriter streamWriter = OUTPUT_FACTORY.createXMLStreamWriter(writer);
+ serializer.serialize(reader, streamWriter);
+ streamWriter.flush();
+ }
+
+ public static void save(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ XMLStreamSerializer serializer = new XMLStreamSerializer();
+ serializer.serialize(reader, writer);
+ writer.flush();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java
new file mode 100755
index 0000000000..d0b6ce07f2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.tuscany.spi.databinding.DataPipe;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class StreamDataPipe extends TransformerExtension<OutputStream, InputStream> implements
+ DataPipe<OutputStream, InputStream> {
+
+ private ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+ public InputStream getResult() {
+ return new ByteArrayInputStream(outputStream.toByteArray());
+ }
+
+ public Class getTargetType() {
+ return InputStream.class;
+ }
+
+ public int getWeight() {
+ return 50;
+ }
+
+ public OutputStream getSink() {
+ return outputStream;
+ }
+
+ public Class getSourceType() {
+ return OutputStream.class;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java
new file mode 100755
index 0000000000..3f878a07b9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+@Service(Transformer.class)
+public class String2Node extends TransformerExtension<String, Node> implements PullTransformer<String, Node> {
+
+ public Node transform(String source, TransformationContext context) {
+ try {
+ DocumentBuilder builder = DOMHelper.newDocumentBuilder();
+ InputSource inputSource = new InputSource(new StringReader(source));
+ return builder.parse(inputSource);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return String.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java
new file mode 100644
index 0000000000..50ea110b17
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.StringReader;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+
+/**
+ * Transform XML string to SAX
+ */
+@Service(Transformer.class)
+public class String2SAX extends TransformerExtension<String, ContentHandler> implements
+ PushTransformer<String, ContentHandler> {
+
+ public void transform(String source, ContentHandler target, TransformationContext context) {
+ try {
+ new InputSource2SAX().transform(new InputSource(new StringReader(source)), target, context);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return String.class;
+ }
+
+ public Class getTargetType() {
+ return ContentHandler.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java
new file mode 100755
index 0000000000..9793cc3f7e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class String2XMLStreamReader extends TransformerExtension<String, XMLStreamReader> implements
+ PullTransformer<String, XMLStreamReader> {
+
+ public XMLStreamReader transform(String source, TransformationContext context) {
+ try {
+ return StAXHelper.createXMLStreamReader(source);
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return String.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java
new file mode 100755
index 0000000000..c66d0fd934
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.tuscany.spi.databinding.DataPipe;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class Writer2ReaderDataPipe extends TransformerExtension<Writer, Reader> implements DataPipe<Writer, Reader> {
+
+ private StringWriter writer = new StringWriter();
+
+ public Reader getResult() {
+ return new StringReader(writer.toString());
+ }
+
+ public Class getTargetType() {
+ return Reader.class;
+ }
+
+ public int getWeight() {
+ return 50;
+ }
+
+ public Writer getSink() {
+ return writer;
+ }
+
+ public Class getSourceType() {
+ return Writer.class;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java
new file mode 100644
index 0000000000..6ecaa85be4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+/**
+ * Transform DOM Node to XML XMLStreamReader
+ */
+@Service(Transformer.class)
+public class XMLStreamReader2Node extends TransformerExtension<XMLStreamReader, Node> implements
+ PullTransformer<XMLStreamReader, Node> {
+ private SAX2DOMPipe pipe = new SAX2DOMPipe();
+
+ private XMLStreamReader2SAX stax2sax = new XMLStreamReader2SAX();
+
+ public Node transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ stax2sax.transform(source, pipe.getSink(), context);
+ return pipe.getResult();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java
new file mode 100644
index 0000000000..0c6f0b8df7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.xml.sax.ContentHandler;
+
+/**
+ * XMLStreamReader to SAX events
+ */
+@Service(Transformer.class)
+public class XMLStreamReader2SAX extends TransformerExtension<XMLStreamReader, ContentHandler> implements
+ PushTransformer<XMLStreamReader, ContentHandler> {
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PushTransformer#getSourceType()
+ */
+ public Class getTargetType() {
+ return ContentHandler.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PushTransformer#getSourceType()
+ */
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PushTransformer#getWeight()
+ */
+ public int getWeight() {
+ return 20;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PushTransformer#transform(java.lang.Object,
+ * java.lang.Object,
+ * org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public void transform(XMLStreamReader source, ContentHandler sink, TransformationContext context) {
+ StAX2SAXAdapter adapter = new StAX2SAXAdapter(false);
+ try {
+ adapter.parse(source, sink);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java
new file mode 100755
index 0000000000..85ac7b5af6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class XMLStreamReader2String extends TransformerExtension<XMLStreamReader, String> implements
+ PullTransformer<XMLStreamReader, String> {
+
+ public String transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ return StAXHelper.save(source);
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public Class getTargetType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java
new file mode 100644
index 0000000000..39e9362524
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+
+/**
+ * A DataBinding for the XML string
+ */
+public class XMLStringDataBinding extends DataBindingExtension {
+ public static final String NAME = String.class.getName();
+
+ public XMLStringDataBinding() {
+ super(NAME, String.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java
new file mode 100644
index 0000000000..c931cccde9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.deployer;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Base class for DeploymentContext implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractDeploymentContext implements DeploymentContext {
+ private final ClassLoader classLoader;
+ private final URL scdlLocation;
+ private final Map<String, Object> properties = new HashMap<String, Object>();
+
+ protected AbstractDeploymentContext(ClassLoader classLoader, URL scdlLocation) {
+ this.classLoader = classLoader;
+ this.scdlLocation = scdlLocation;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public URL getScdlLocation() {
+ return scdlLocation;
+ }
+
+ public Object getExtension(String name) {
+ return properties.get(name);
+ }
+
+ public void putExtension(String name, Object value) {
+ if (value == null) {
+ properties.remove(name);
+ } else {
+ properties.put(name, value);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java
new file mode 100644
index 0000000000..10bb5a4609
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.deployer;
+
+import java.net.URL;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * An holder that can be used during the load process to store information that is not part of the logical assembly
+ * model. This should be regarded as transient and references to this context should not be stored inside the model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ChildDeploymentContext extends AbstractDeploymentContext {
+ private final DeploymentContext parent;
+
+ /**
+ * Constructor specifying the loader for application resources.
+ *
+ * @param parent the parent of this context
+ * @param classLoader the loader for application resources
+ * @param scdlLocation the location of the SCDL being deployed
+ */
+ public ChildDeploymentContext(DeploymentContext parent, ClassLoader classLoader, URL scdlLocation) {
+ super(classLoader, scdlLocation);
+ assert parent != null;
+ this.parent = parent;
+ }
+
+ public DeploymentContext getParent() {
+ return parent;
+ }
+
+ public XMLInputFactory getXmlFactory() {
+ return parent.getXmlFactory();
+ }
+
+ public ScopeContainer getModuleScope() {
+ return parent.getModuleScope();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
new file mode 100644
index 0000000000..e5556292da
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.deployer;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.Builder;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.Loader;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+
+/**
+ * Default implementation of Deployer.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DeployerImpl implements Deployer {
+ private XMLInputFactory xmlFactory;
+ private Loader loader;
+ private Builder builder;
+
+ public DeployerImpl(XMLInputFactory xmlFactory, Loader loader, Builder builder) {
+ this.xmlFactory = xmlFactory;
+ this.loader = loader;
+ this.builder = builder;
+ }
+
+ public DeployerImpl() {
+ xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
+ }
+
+ @Autowire
+ public void setLoader(LoaderRegistry loader) {
+ this.loader = loader;
+ }
+
+ @Autowire
+ public void setBuilder(BuilderRegistry builder) {
+ this.builder = builder;
+ }
+
+ public <I extends Implementation<?>> Component deploy(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition)
+ throws LoaderException {
+ ScopeContainer moduleScope = new ModuleScopeContainer();
+ DeploymentContext deploymentContext = new RootDeploymentContext(null, xmlFactory, moduleScope, null);
+ try {
+ load(parent, componentDefinition, deploymentContext);
+ } catch (LoaderException e) {
+ e.addContextName(componentDefinition.getName());
+ throw e;
+ }
+ Component component = (Component) build(parent, componentDefinition, deploymentContext);
+ if (component instanceof CompositeComponent) {
+ CompositeComponent composite = (CompositeComponent) component;
+ composite.setScopeContainer(moduleScope);
+ }
+ component.prepare();
+ parent.register(component);
+ return component;
+ }
+
+ /**
+ * Load the componentDefinition type information for the componentDefinition being deployed. For a typical
+ * deployment this will result in the SCDL definition being loaded.
+ *
+ * @param componentDefinition the componentDefinition being deployed
+ * @param deploymentContext the current deployment context
+ */
+ protected <I extends Implementation<?>> void load(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition,
+ DeploymentContext deploymentContext) throws LoaderException {
+ loader.loadComponentType(parent, componentDefinition.getImplementation(), deploymentContext);
+ }
+
+ /**
+ * Build the runtime context for a loaded componentDefinition.
+ *
+ * @param parent the context that will be the parent of the new sub-context
+ * @param componentDefinition the componentDefinition being deployed
+ * @param deploymentContext the current deployment context
+ * @return the new runtime context
+ */
+ protected <I extends Implementation<?>> SCAObject build(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition,
+ DeploymentContext deploymentContext) {
+ return builder.build(parent, componentDefinition, deploymentContext);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java
new file mode 100644
index 0000000000..cc3ae86cc8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.deployer;
+
+import java.net.URL;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * A holder that can be used during the load process to store information that is not part of the logical assembly
+ * model. This should be regarded as transient and references to this context should not be stored inside the model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RootDeploymentContext extends AbstractDeploymentContext {
+ private final XMLInputFactory xmlFactory;
+ private final ScopeContainer moduleScope;
+
+ /**
+ * Constructor specifying the loader for application resources.
+ *
+ * @param classLoader the loader for application resources
+ * @param xmlFactory a factory that can be used to obtain an StAX XMLStreamReader
+ * @param moduleScope the scope context representing this deployment's MODULE scope
+ * @param scdlLocation the location of the SCDL being deployed
+ */
+ public RootDeploymentContext(ClassLoader classLoader,
+ XMLInputFactory xmlFactory,
+ ScopeContainer moduleScope,
+ URL scdlLocation) {
+ super(classLoader, scdlLocation);
+ this.xmlFactory = xmlFactory;
+ this.moduleScope = moduleScope;
+ }
+
+ public DeploymentContext getParent() {
+ return null;
+ }
+
+ public XMLInputFactory getXmlFactory() {
+ return xmlFactory;
+ }
+
+ public ScopeContainer getModuleScope() {
+ return moduleScope;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java
new file mode 100644
index 0000000000..45741e828b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.idl.java;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * Denotes an illegal callback interface
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class IllegalCallbackException extends InvalidServiceContractException {
+ public IllegalCallbackException() {
+ }
+
+ public IllegalCallbackException(String message) {
+ super(message);
+ }
+
+ public IllegalCallbackException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalCallbackException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java
new file mode 100644
index 0000000000..057928ed31
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.idl.java;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.ModelObject;
+
+import org.apache.tuscany.core.loader.StAXUtil;
+
+/**
+ * Loads a Java interface definition from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class InterfaceJavaLoader extends LoaderExtension<JavaServiceContract> {
+ public static final QName INTERFACE_JAVA = new QName(XML_NAMESPACE_1_0, "interface.java");
+
+ private final JavaInterfaceProcessorRegistry interfaceRegsitry;
+
+ @Constructor({"registry", "interfaceRegsitry"})
+ public InterfaceJavaLoader(@Autowire LoaderRegistry registry,
+ @Autowire JavaInterfaceProcessorRegistry interfaceRegistry) {
+ super(registry);
+ this.interfaceRegsitry = interfaceRegistry;
+ }
+
+ public QName getXMLType() {
+ return INTERFACE_JAVA;
+ }
+
+ public JavaServiceContract load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ assert INTERFACE_JAVA.equals(reader.getName());
+ InteractionScope interactionScope = StAXUtil.interactionScope(reader.getAttributeValue(null, "scope"));
+ String name = reader.getAttributeValue(null, "interface");
+ if (name == null) {
+ // allow "class" as well as seems to be a common mistake
+ name = reader.getAttributeValue(null, "class");
+ }
+ if (name == null) {
+ throw new InvalidValueException("interface name not supplied");
+ }
+ Class<?> interfaceClass = LoaderUtil.loadClass(name, deploymentContext.getClassLoader());
+
+ name = reader.getAttributeValue(null, "callbackInterface");
+ Class<?> callbackClass = (name != null) ? LoaderUtil.loadClass(name, deploymentContext.getClassLoader()) : null;
+
+ Map<Class<?>, ModelObject> extensions = new HashMap<Class<?>, ModelObject>();
+ while (true) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ ModelObject mo = registry.load(parent, reader, deploymentContext);
+ if (mo != null) {
+ extensions.put(mo.getClass(), mo);
+ }
+ } else if (event == XMLStreamConstants.END_ELEMENT && reader.getName().equals(INTERFACE_JAVA)) {
+ break;
+ }
+ }
+ JavaServiceContract serviceContract;
+ try {
+ serviceContract = interfaceRegsitry.introspect(interfaceClass, callbackClass);
+ } catch (InvalidServiceContractException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(interfaceClass.getName());
+ throw le;
+ }
+
+ // Set databinding from the SCDL extension <databinding>
+ DataType<?> dataType = (DataType<?>) extensions.get(DataType.class);
+ if (dataType != null) {
+ serviceContract.setDataBinding(dataType.getDataBinding());
+ }
+ serviceContract.getExtensions().putAll(extensions);
+
+ serviceContract.setInteractionScope(interactionScope);
+ return serviceContract;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
new file mode 100644
index 0000000000..b0df6d0844
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.idl.java;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.OverloadedOperationException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessor;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.Operation;
+
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+
+/**
+ * Default implementation of an InterfaceJavaIntrospector.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceProcessorRegistryImpl implements JavaInterfaceProcessorRegistry {
+
+ public static final String IDL_INPUT = "idl:input";
+ private static final String UNKNOWN_DATABINDING = null;
+
+ private List<JavaInterfaceProcessor> processors = new ArrayList<JavaInterfaceProcessor>();
+
+ public JavaInterfaceProcessorRegistryImpl() {
+ }
+
+ public void registerProcessor(JavaInterfaceProcessor processor) {
+ processors.add(processor);
+ }
+
+ public void unregisterProcessor(JavaInterfaceProcessor processor) {
+ processors.remove(processor);
+ }
+
+ public <T> JavaServiceContract introspect(Class<T> type) throws InvalidServiceContractException {
+ Class<?> callbackClass = null;
+ Callback callback = type.getAnnotation(Callback.class);
+ if (callback != null && !Void.class.equals(callback.value())) {
+ callbackClass = callback.value();
+ } else if (callback != null && Void.class.equals(callback.value())) {
+ IllegalCallbackException e = new IllegalCallbackException("No callback interface specified on annotation");
+ e.setIdentifier(type.getName());
+ throw e;
+ }
+ return introspect(type, callbackClass);
+ }
+
+ public <I, C> JavaServiceContract introspect(Class<I> type, Class<C> callback)
+ throws InvalidServiceContractException {
+ JavaServiceContract contract = new JavaServiceContract();
+ contract.setInterfaceName(getBaseName(type));
+ contract.setInterfaceClass(type);
+ boolean remotable = type.isAnnotationPresent(Remotable.class);
+ contract.setRemotable(remotable);
+ contract.setOperations(getOperations(type, remotable));
+
+ if (callback != null) {
+ contract.setCallbackName(getBaseName(callback));
+ contract.setCallbackClass(callback);
+ contract.setCallbackOperations(getOperations(callback, remotable));
+ }
+
+ Scope interactionScope = type.getAnnotation(Scope.class);
+ if (interactionScope == null) {
+ contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
+ } else {
+ if ("CONVERSATIONAL".equalsIgnoreCase(interactionScope.value())) {
+ contract.setInteractionScope(InteractionScope.CONVERSATIONAL);
+ } else {
+ contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
+ }
+ }
+ for (JavaInterfaceProcessor processor : processors) {
+ processor.visitInterface(type, callback, contract);
+ }
+ return contract;
+ }
+
+ private <T> Map<String, Operation<Type>> getOperations(Class<T> type, boolean remotable)
+ throws OverloadedOperationException {
+ Method[] methods = type.getMethods();
+ Map<String, Operation<Type>> operations = new HashMap<String, Operation<Type>>(methods.length);
+ for (Method method : methods) {
+ String name = method.getName();
+ if (remotable && operations.containsKey(name)) {
+ throw new OverloadedOperationException(method.toString());
+ }
+
+ Type returnType = method.getGenericReturnType();
+ Type[] paramTypes = method.getGenericParameterTypes();
+ Type[] faultTypes = method.getGenericExceptionTypes();
+ boolean nonBlocking = method.isAnnotationPresent(OneWay.class);
+
+ DataType<Type> returnDataType = new DataType<Type>(UNKNOWN_DATABINDING, returnType, returnType);
+ List<DataType<Type>> paramDataTypes = new ArrayList<DataType<Type>>(paramTypes.length);
+ for (Type paramType : paramTypes) {
+ paramDataTypes.add(new DataType<Type>(UNKNOWN_DATABINDING, paramType, paramType));
+ }
+ List<DataType<Type>> faultDataTypes = new ArrayList<DataType<Type>>(faultTypes.length);
+ for (Type faultType : faultTypes) {
+ faultDataTypes.add(new DataType<Type>(UNKNOWN_DATABINDING, faultType, faultType));
+ }
+
+ DataType<List<DataType<Type>>> inputType =
+ new DataType<List<DataType<Type>>>(IDL_INPUT, Object[].class, paramDataTypes);
+ Operation<Type> operation =
+ new Operation<Type>(name, inputType, returnDataType, faultDataTypes, nonBlocking, UNKNOWN_DATABINDING);
+ operations.put(name, operation);
+ }
+ return operations;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java
new file mode 100644
index 0000000000..3dd1328b6a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessor;
+import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+
+/**
+ * Default implementation of the <code>IntrospectionRegistry</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntrospectionRegistryImpl implements IntrospectionRegistry {
+
+ private Monitor monitor;
+ private List<ImplementationProcessor> cache = new ArrayList<ImplementationProcessor>();
+
+ public IntrospectionRegistryImpl() {
+ }
+
+ public IntrospectionRegistryImpl(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ @org.apache.tuscany.api.annotation.Monitor
+ public void setMonitor(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ public void registerProcessor(ImplementationProcessor processor) {
+ monitor.register(processor);
+ cache.add(processor);
+ }
+
+ public void unregisterProcessor(ImplementationProcessor processor) {
+ monitor.unregister(processor);
+ cache.remove(processor);
+ }
+
+ public PojoComponentType introspect(CompositeComponent parent, Class<?> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference,
+ JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ for (ImplementationProcessor processor : cache) {
+ processor.visitClass(parent, clazz, type, context);
+ }
+
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ for (ImplementationProcessor processor : cache) {
+ processor.visitConstructor(parent, constructor, type, context);
+ }
+ }
+
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz);
+ for (Method method : methods) {
+ for (ImplementationProcessor processor : cache) {
+ processor.visitMethod(parent, method, type, context);
+ }
+ }
+
+ Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz);
+ for (Field field : fields) {
+ for (ImplementationProcessor processor : cache) {
+ processor.visitField(parent, field, type, context);
+ }
+ }
+
+ Class superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ visitSuperClass(parent, superClass, type, context);
+ }
+
+ for (ImplementationProcessor processor : cache) {
+ processor.visitEnd(parent, clazz, type, context);
+ }
+ return type;
+ }
+
+ private void visitSuperClass(CompositeComponent parent,
+ Class<?> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ if (!Object.class.equals(clazz)) {
+ for (ImplementationProcessor processor : cache) {
+ processor.visitSuperClass(parent, clazz, type, context);
+ }
+ clazz = clazz.getSuperclass();
+ if (clazz != null) {
+ visitSuperClass(parent, clazz, type, context);
+ }
+ }
+ }
+
+ public static interface Monitor {
+ void register(ImplementationProcessor processor);
+
+ void unregister(ImplementationProcessor processor);
+
+ void processing(ImplementationProcessor processor);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java
new file mode 100644
index 0000000000..cfa5284efe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+
+import org.apache.tuscany.core.injection.ArrayMultiplicityObjectFactory;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.InvalidAccessorException;
+import org.apache.tuscany.core.injection.ListMultiplicityObjectFactory;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.NoAccessorException;
+import org.apache.tuscany.core.injection.ObjectCallbackException;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Base implementation of an {@link org.apache.tuscany.spi.component.AtomicComponent} whose type is a Java class
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class PojoAtomicComponent extends AtomicComponentExtension {
+
+ protected EventInvoker<Object> initInvoker;
+ protected EventInvoker<Object> destroyInvoker;
+ protected PojoObjectFactory<?> instanceFactory;
+ protected List<String> constructorParamNames;
+ protected List<Class<?>> serviceInterfaces;
+ protected Map<String, Member> referenceSites;
+ protected Map<String, Member> propertySites;
+ protected Map<String, Member> callbackSites;
+ protected List<Injector<Object>> injectors;
+
+ public PojoAtomicComponent(String name, PojoConfiguration configuration) {
+ super(name,
+ configuration.getParent(),
+ configuration.getScopeContainer(),
+ configuration.getWireService(),
+ configuration.getWorkContext(),
+ configuration.getScheduler(),
+ configuration.getInitLevel());
+ assert configuration.getInstanceFactory() != null : "Object factory was null";
+ initInvoker = configuration.getInitInvoker();
+ destroyInvoker = configuration.getDestroyInvoker();
+ instanceFactory = configuration.getInstanceFactory();
+ constructorParamNames = configuration.getConstructorParamNames();
+ serviceInterfaces = configuration.getServiceInterfaces();
+ injectors = new ArrayList<Injector<Object>>();
+ referenceSites = configuration.getReferenceSite() != null ? configuration.getReferenceSite()
+ : new HashMap<String, Member>();
+ propertySites = configuration.getPropertySites() != null ? configuration.getPropertySites()
+ : new HashMap<String, Member>();
+ callbackSites = configuration.getCallbackSite() != null ? configuration.getCallbackSite()
+ : new HashMap<String, Member>();
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return serviceInterfaces;
+ }
+
+ public void init(Object instance) throws TargetException {
+ if (initInvoker != null) {
+ try {
+ initInvoker.invokeEvent(instance);
+ } catch (ObjectCallbackException e) {
+ TargetException t = new TargetException("Error initializing component instance", e);
+ t.setIdentifier(getName());
+ throw t;
+ }
+ }
+ }
+
+ public void destroy(Object instance) throws TargetException {
+ if (destroyInvoker != null) {
+ try {
+ destroyInvoker.invokeEvent(instance);
+ } catch (ObjectCallbackException e) {
+ TargetException t = new TargetException("Error destroying component instance", e);
+ t.setIdentifier(getName());
+ throw t;
+ }
+ }
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ return scopeContainer.getInstance(this);
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ Object instance = instanceFactory.getInstance();
+ // inject the instance with properties and references
+ for (Injector<Object> injector : injectors) {
+ injector.inject(instance);
+ }
+ return instance;
+ }
+
+ public void addPropertyFactory(String name, ObjectFactory<?> factory) {
+ Member member = propertySites.get(name);
+ if (member instanceof Field) {
+ injectors.add(new FieldInjector<Object>((Field) member, factory));
+ } else if (member instanceof Method) {
+ injectors.add(new MethodInjector<Object>((Method) member, factory));
+ }
+ // cycle through constructor param names as well
+ for (int i = 0; i < constructorParamNames.size(); i++) {
+ if (name.equals(constructorParamNames.get(i))) {
+ ObjectFactory[] initializerFactories = instanceFactory.getInitializerFactories();
+ initializerFactories[i] = factory;
+ break;
+ }
+ }
+ //FIXME throw an error if no injection site found
+ }
+
+ protected void onReferenceWire(OutboundWire wire) {
+ String name = wire.getReferenceName();
+ Member member = referenceSites.get(name);
+ if (member != null) {
+ injectors.add(createInjector(member, wire));
+ }
+ // cycle through constructor param names as well
+ for (int i = 0; i < constructorParamNames.size(); i++) {
+ if (name.equals(constructorParamNames.get(i))) {
+ ObjectFactory[] initializerFactories = instanceFactory.getInitializerFactories();
+ initializerFactories[i] = createWireFactory(wire);
+ break;
+ }
+ }
+ //TODO error if ref not set on constructor or ref site
+ }
+
+ public void onReferenceWires(Class<?> multiplicityClass, List<OutboundWire> wires) {
+ assert wires.size() > 0 : "Wires were empty";
+ String referenceName = wires.get(0).getReferenceName();
+ Member member = referenceSites.get(referenceName);
+ if (member == null) {
+ if (constructorParamNames.contains(referenceName)) {
+ // injected on the constructor
+
+ } else {
+ throw new NoAccessorException(referenceName);
+ }
+ }
+ injectors.add(createMultiplicityInjector(member, multiplicityClass, wires));
+ //TODO multiplicity for constructor injection
+ }
+
+ protected Injector<Object> createInjector(Member member, RuntimeWire wire) {
+ ObjectFactory<?> factory = createWireFactory(wire);
+ if (member instanceof Field) {
+ return new FieldInjector<Object>((Field) member, factory);
+ } else if (member instanceof Method) {
+ return new MethodInjector<Object>((Method) member, factory);
+ } else {
+ InvalidAccessorException e = new InvalidAccessorException("Member must be a field or method");
+ e.setIdentifier(member.getName());
+ throw e;
+ }
+ }
+
+ protected Injector<Object> createMultiplicityInjector(Member member,
+ Class<?> interfaceType,
+ List<OutboundWire> wireFactories) {
+ List<ObjectFactory<?>> factories = new ArrayList<ObjectFactory<?>>();
+ for (OutboundWire wire : wireFactories) {
+ factories.add(createWireFactory(wire));
+ }
+ if (member instanceof Field) {
+ Field field = (Field) member;
+ if (field.getType().isArray()) {
+ return new FieldInjector<Object>(field, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new FieldInjector<Object>(field, new ListMultiplicityObjectFactory(factories));
+ }
+ } else if (member instanceof Method) {
+ Method method = (Method) member;
+ if (method.getParameterTypes()[0].isArray()) {
+ return new MethodInjector<Object>(method, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new MethodInjector<Object>(method, new ListMultiplicityObjectFactory(factories));
+ }
+ } else {
+ InvalidAccessorException e = new InvalidAccessorException("Member must be a field or method");
+ e.setIdentifier(member.getName());
+ throw e;
+ }
+ }
+
+ protected abstract ObjectFactory<?> createWireFactory(RuntimeWire wire);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java
new file mode 100644
index 0000000000..6a8c80fb05
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation;
+
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Encapsulates confuration for a Java-based atomic component
+ *
+ * @version $Rev$ $Date$
+ */
+public class PojoConfiguration {
+
+ private CompositeComponent parent;
+ private ScopeContainer scopeContainer;
+ private PojoObjectFactory<?> instanceFactory;
+ private List<String> constructorParamNames = new ArrayList<String>();
+ private int initLevel;
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+ private List<Injector> propertyInjectors = new ArrayList<Injector>();
+ private Map<String, Member> referenceSites = new HashMap<String, Member>();
+ private Map<String, Member> propertySites = new HashMap<String, Member>();
+ private Map<String, Member> callbackSites = new HashMap<String, Member>();
+ private List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>();
+ private WireService wireService;
+ private WorkContext workContext;
+ private WorkScheduler scheduler;
+
+ public CompositeComponent getParent() {
+ return parent;
+ }
+
+ public void setParent(CompositeComponent parent) {
+ this.parent = parent;
+ }
+
+ public ScopeContainer getScopeContainer() {
+ return scopeContainer;
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ this.scopeContainer = scopeContainer;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return serviceInterfaces;
+ }
+
+ public void addServiceInterface(Class<?> serviceInterface) {
+ serviceInterfaces.add(serviceInterface);
+ }
+
+ public PojoObjectFactory<?> getInstanceFactory() {
+ return instanceFactory;
+ }
+
+ public void setInstanceFactory(PojoObjectFactory<?> objectFactory) {
+ this.instanceFactory = objectFactory;
+ }
+
+ public List<String> getConstructorParamNames() {
+ return constructorParamNames;
+ }
+
+ public void setConstructorParamNames(List<String> names) {
+ constructorParamNames = names;
+ }
+
+ public void addConstructorParamName(String name) {
+ constructorParamNames.add(name);
+ }
+
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ public void setInitLevel(int initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ public EventInvoker<Object> getInitInvoker() {
+ return initInvoker;
+ }
+
+ public void setInitInvoker(EventInvoker<Object> initInvoker) {
+ this.initInvoker = initInvoker;
+ }
+
+ public EventInvoker<Object> getDestroyInvoker() {
+ return destroyInvoker;
+ }
+
+ public void setDestroyInvoker(EventInvoker<Object> destroyInvoker) {
+ this.destroyInvoker = destroyInvoker;
+ }
+
+ public List<Injector> getPropertyInjectors() {
+ return propertyInjectors;
+ }
+
+ public void addPropertyInjector(Injector injector) {
+ propertyInjectors.add(injector);
+ }
+
+ public Map<String, Member> getReferenceSite() {
+ return referenceSites;
+ }
+
+ public void addReferenceSite(String name, Member member) {
+ referenceSites.put(name, member);
+ }
+
+ public Map<String, Member> getCallbackSite() {
+ return callbackSites;
+ }
+
+ public void addCallbackSite(String name, Member member) {
+ callbackSites.put(name, member);
+ }
+
+ public Map<String, Member> getPropertySites() {
+ return propertySites;
+ }
+
+ public void addPropertySite(String name, Member member) {
+ propertySites.put(name, member);
+ }
+
+ public WireService getWireService() {
+ return wireService;
+ }
+
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ public WorkContext getWorkContext() {
+ return workContext;
+ }
+
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ public WorkScheduler getScheduler() {
+ return scheduler;
+ }
+
+ public void setScheduler(WorkScheduler scheduler) {
+ this.scheduler = scheduler;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java
new file mode 100644
index 0000000000..7949bf4a71
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ObjectRegistrationException;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.extension.CompositeComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import org.apache.tuscany.core.component.ComponentInitException;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.implementation.system.component.SystemSingletonAtomicComponent;
+
+/**
+ * The base implementation of a composite context
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractCompositeComponent extends CompositeComponentExtension {
+
+ public static final int DEFAULT_WAIT = 1000 * 60;
+
+ // Blocking latch to ensure the module is initialized exactly once prior to servicing requests
+ protected CountDownLatch initializeLatch = new CountDownLatch(1);
+
+ protected final Object lock = new Object();
+
+ // Indicates whether the module context has been initialized
+ protected boolean initialized;
+
+ protected ScopeContainer scopeContainer;
+
+
+ /**
+ * @param name the name of the SCA composite
+ * @param parent the SCA composite parent
+ * @param connector
+ * @param propertyValues the values of this composite's Properties
+ */
+ public AbstractCompositeComponent(String name,
+ CompositeComponent parent,
+ Connector connector,
+ Map<String, Document> propertyValues) {
+ super(name, parent, connector, propertyValues);
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ assert this.scopeContainer == null;
+ this.scopeContainer = scopeContainer;
+ addListener(scopeContainer);
+ }
+
+ public <S, I extends S> void registerJavaObject(String name, Class<S> service, I instance)
+ throws ObjectRegistrationException {
+ register(new SystemSingletonAtomicComponent<S, I>(name, this, service, instance));
+ }
+
+ public void start() {
+ synchronized (lock) {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Composite not in UNINITIALIZED state");
+ }
+
+ if (scopeContainer != null) {
+ scopeContainer.start();
+ }
+ for (SCAObject child : systemChildren.values()) {
+ child.start();
+ }
+ for (SCAObject child : children.values()) {
+ child.start();
+ }
+ initializeLatch.countDown();
+ initialized = true;
+ lifecycleState = INITIALIZED;
+ }
+ publish(new CompositeStart(this, this));
+ }
+
+ public void stop() {
+ if (lifecycleState == STOPPED) {
+ return;
+ }
+
+ publish(new CompositeStop(this, this));
+ for (SCAObject child : children.values()) {
+ child.stop();
+ }
+ for (SCAObject child : systemChildren.values()) {
+ child.stop();
+ }
+ if (scopeContainer != null) {
+ scopeContainer.stop();
+ }
+
+ // need to block a start until reset is complete
+ initializeLatch = new CountDownLatch(2);
+ lifecycleState = STOPPING;
+ initialized = false;
+ // allow initialized to be called
+ initializeLatch.countDown();
+ lifecycleState = STOPPED;
+ }
+
+ public void publish(Event event) {
+ if (lifecycleState == STOPPED) {
+ return;
+ }
+ checkInit();
+ super.publish(event);
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return null;
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ return null;
+ }
+
+
+ /**
+ * Blocks until the module context has been initialized
+ */
+ protected void checkInit() {
+ if (!initialized) {
+ try {
+ /* block until the module has initialized */
+ boolean success = initializeLatch.await(AbstractCompositeComponent.DEFAULT_WAIT,
+ TimeUnit.MILLISECONDS);
+ if (!success) {
+ throw new ComponentInitException("Timeout waiting for context to initialize");
+ }
+ } catch (InterruptedException e) { // should not happen
+ }
+ }
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java
new file mode 100644
index 0000000000..5ef666be76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeReferenceTargetInvoker.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Base class for dispatching to a Composite Reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractCompositeReferenceTargetInvoker implements TargetInvoker {
+
+ protected Operation operation;
+ protected boolean cacheable;
+
+ public AbstractCompositeReferenceTargetInvoker(Operation operation) {
+ assert operation != null : "Operation method cannot be null";
+ this.operation = operation;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable(); // we only need to check if the scopes are correct
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ Object[] args;
+ if (payload != null && !payload.getClass().isArray()) {
+ args = new Object[]{payload};
+ } else {
+ args = (Object[]) payload;
+ }
+ try {
+ AbstractOperationOutboundInvocationHandler invocationHandler = getInvocationHandler();
+ return invocationHandler.invoke(operation, args);
+ } catch (Throwable t) {
+ throw new InvocationTargetException(t);
+ }
+ }
+
+ @Override
+ public AbstractCompositeReferenceTargetInvoker clone() throws CloneNotSupportedException {
+ return (AbstractCompositeReferenceTargetInvoker) super.clone();
+ }
+
+ protected abstract AbstractOperationOutboundInvocationHandler getInvocationHandler();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java
new file mode 100644
index 0000000000..2ccc3ec729
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractOperationOutboundInvocationHandler.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractOperationOutboundInvocationHandler
+ extends AbstractOutboundInvocationHandler {
+
+ public abstract Object invoke(Operation operation, Object[] args) throws Throwable;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBindlessBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBindlessBuilder.java
new file mode 100644
index 0000000000..c0466465cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBindlessBuilder.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BindlessBuilder;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * The default implementation f a {@link BindlessBuilder} for a composite
+ */
+public class CompositeBindlessBuilder implements BindlessBuilder {
+
+ protected BuilderRegistry builderRegistry;
+ protected WireService wireService;
+ protected WorkContext workContext;
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry registry) {
+ this.builderRegistry = registry;
+ }
+
+ @Autowire
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ @Autowire
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ builderRegistry.register(this);
+ }
+
+ public Service build(CompositeComponent parent,
+ BindlessServiceDefinition definition,
+ DeploymentContext deploymentContext) {
+ return new CompositeService(definition.getName(),
+ definition.getServiceContract().getInterfaceClass(),
+ parent,
+ wireService,
+ workContext);
+ }
+
+ public Reference build(CompositeComponent parent,
+ ReferenceDefinition definition,
+ DeploymentContext deploymentContext) {
+ return new CompositeReference(definition.getName(),
+ parent,
+ wireService,
+ definition.getServiceContract(),
+ workContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java
new file mode 100644
index 0000000000..dccfc636c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Instantiates a composite component from an assembly definition
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeBuilder extends ComponentBuilderExtension<CompositeImplementation> {
+
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<CompositeImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+ CompositeImplementation implementation = componentDefinition.getImplementation();
+ CompositeComponentType<?, ?, ?> componentType = implementation.getComponentType();
+
+ // create lists of all components, services and references in this composite
+ List<ComponentDefinition<? extends Implementation<?>>> allComponents =
+ new ArrayList<ComponentDefinition<? extends Implementation<?>>>();
+ allComponents.addAll(componentType.getComponents().values());
+
+ List<BoundServiceDefinition<? extends Binding>> allBoundServices =
+ new ArrayList<BoundServiceDefinition<? extends Binding>>();
+ List<BindlessServiceDefinition> allBindlessServices = new ArrayList<BindlessServiceDefinition>();
+ for (ServiceDefinition serviceDefinition : componentType.getServices().values()) {
+ if (serviceDefinition instanceof BoundServiceDefinition) {
+ BoundServiceDefinition<? extends Binding> boundService =
+ (BoundServiceDefinition<? extends Binding>) serviceDefinition;
+ allBoundServices.add(boundService);
+ } else if (serviceDefinition instanceof BindlessServiceDefinition) {
+ allBindlessServices.add((BindlessServiceDefinition) serviceDefinition);
+ }
+ }
+
+ // FIXME is this right?
+ List<BoundReferenceDefinition<? extends Binding>> allBoundReferences =
+ new ArrayList<BoundReferenceDefinition<? extends Binding>>();
+ List<ReferenceDefinition> allTargetlessReferences = new ArrayList<ReferenceDefinition>();
+
+ for (Object referenceTarget : componentType.getReferences().values()) {
+ if (referenceTarget instanceof BoundReferenceDefinition<?>) {
+ allBoundReferences.add((BoundReferenceDefinition<? extends Binding>) referenceTarget);
+ } else if (referenceTarget instanceof ReferenceDefinition) {
+ allTargetlessReferences.add((ReferenceDefinition) referenceTarget);
+ }
+ }
+
+ String name = componentDefinition.getName();
+ CompositeComponentImpl component = new CompositeComponentImpl(name, parent, connector, null);
+ for (BoundReferenceDefinition<? extends Binding> referenceDefinition : allBoundReferences) {
+ component.register(builderRegistry.build(component, referenceDefinition, deploymentContext));
+ }
+ for (BindlessServiceDefinition bindlessServiceDef : allBindlessServices) {
+ component.register(builderRegistry.build(component, bindlessServiceDef, deploymentContext));
+ }
+ for (ComponentDefinition<? extends Implementation<?>> child : allComponents) {
+ component.register(builderRegistry.build(component, child, deploymentContext));
+ }
+ for (BoundServiceDefinition<? extends Binding> serviceDefinition : allBoundServices) {
+ component.register(builderRegistry.build(component, serviceDefinition, deploymentContext));
+ }
+ for (ReferenceDefinition targetlessReferenceDef : allTargetlessReferences) {
+ component.register(builderRegistry.build(component, targetlessReferenceDef, deploymentContext));
+ }
+
+ // HACK: [rfeng] We need a better way to propagate model extensions to SCAObject.
+ component.getExtensions().putAll(componentType.getExtensions());
+
+ return component;
+ }
+
+ protected Class<CompositeImplementation> getImplementationType() {
+ return CompositeImplementation.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java
new file mode 100644
index 0000000000..d7833c8707
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+/**
+ * The standard implementation of a composite component. Autowiring is performed by delegating to the parent composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentImpl extends AbstractCompositeComponent {
+ private String uri;
+
+ public CompositeComponentImpl(String name,
+ CompositeComponent parent,
+ Connector connector,
+ Map<String, Document> propertyValues) {
+ this(name, null, parent, connector, propertyValues);
+ }
+
+ /**
+ * Constructor specifying name and URI.
+ *
+ * @param name the name of this Component
+ * @param uri the unique identifier for this component
+ * @param parent this component's parent
+ * @param connector
+ * @param propertyValues this composite's Property values
+ */
+ public CompositeComponentImpl(String name,
+ String uri,
+ CompositeComponent parent,
+ Connector connector,
+ Map<String, Document> propertyValues) {
+ super(name, parent, connector, propertyValues);
+ this.uri = uri;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java
new file mode 100644
index 0000000000..cac1b231c6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.CompositeClassLoader;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+
+import org.apache.tuscany.core.deployer.ChildDeploymentContext;
+
+/**
+ * Loads a composite component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentTypeLoader extends ComponentTypeLoaderExtension<CompositeImplementation> {
+ public CompositeComponentTypeLoader() {
+ }
+
+ public CompositeComponentTypeLoader(LoaderRegistry loaderRegistry) {
+ super(loaderRegistry);
+ }
+
+ protected Class<CompositeImplementation> getImplementationClass() {
+ return CompositeImplementation.class;
+ }
+
+ public void load(CompositeComponent parent, CompositeImplementation implementation,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+ URL scdlLocation = implementation.getScdlLocation();
+ ClassLoader cl = new CompositeClassLoader(implementation.getClassLoader());
+ deploymentContext = new ChildDeploymentContext(deploymentContext, cl, scdlLocation);
+ CompositeComponentType componentType = loadFromSidefile(parent, scdlLocation, deploymentContext);
+ implementation.setComponentType(componentType);
+ }
+
+ protected CompositeComponentType loadFromSidefile(CompositeComponent parent,
+ URL url,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+ return loaderRegistry.load(parent, url, CompositeComponentType.class, deploymentContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java
new file mode 100644
index 0000000000..312d06cbd2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.core.property.PropertyHelper;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.CompositeClassLoader;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Include;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+
+/**
+ * Loads a composite component definition from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeLoader extends LoaderExtension<CompositeComponentType> {
+ public static final QName COMPOSITE = new QName(XML_NAMESPACE_1_0, "composite");
+
+ private final ArtifactRepository artifactRepository;
+
+ public CompositeLoader(@Autowire LoaderRegistry registry,
+ @Autowire ArtifactRepository artifactRepository) {
+ super(registry);
+ this.artifactRepository = artifactRepository;
+ }
+
+ public QName getXMLType() {
+ return COMPOSITE;
+ }
+
+ public CompositeComponentType load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ CompositeComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> composite =
+ new CompositeComponentType<ServiceDefinition, ReferenceDefinition, Property<?>>();
+ composite.setName(reader.getAttributeValue(null, "name"));
+ boolean done = false;
+ while (!done) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ ModelObject o = registry.load(parent, reader, deploymentContext);
+ if (o instanceof ServiceDefinition) {
+ composite.add((ServiceDefinition) o);
+ } else if (o instanceof ReferenceDefinition) {
+ composite.add((ReferenceDefinition) o);
+ } else if (o instanceof Property<?>) {
+ composite.add((Property<?>) o);
+ } else if (o instanceof ComponentDefinition<?>) {
+ composite.add((ComponentDefinition<? extends Implementation<?>>) o);
+ } else if (o instanceof Include) {
+ composite.add((Include) o);
+ } else if (o instanceof Dependency) {
+ Artifact artifact = ((Dependency) o).getArtifact();
+ if (artifactRepository != null) {
+ // default to jar type if not specified
+ if (artifact.getType() == null) {
+ artifact.setType("jar");
+ }
+ artifactRepository.resolve(artifact);
+ }
+ if (artifact.getUrl() != null) {
+ ClassLoader classLoader = deploymentContext.getClassLoader();
+ if (classLoader instanceof CompositeClassLoader) {
+ CompositeClassLoader ccl = (CompositeClassLoader)classLoader;
+ for (URL dep : artifact.getUrls()) {
+ ccl.addURL(dep);
+ }
+ }
+ }
+ } else {
+ // HACK: [rfeng] Add as an unknown model extension
+ if (o != null) {
+ composite.getExtensions().put(o.getClass(), o);
+ }
+ }
+ reader.next();
+ break;
+ case END_ELEMENT:
+ if (COMPOSITE.equals(reader.getName())) {
+ done = true;
+ break;
+ }
+ }
+ }
+ for (ComponentDefinition<? extends Implementation<?>> c : composite.getComponents().values()) {
+ PropertyHelper.processProperties(composite, c, deploymentContext);
+ }
+ return composite;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java
new file mode 100644
index 0000000000..60f91ec073
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReference.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * A bindless reference to a target service in the parent composite
+ */
+public class CompositeReference extends ReferenceExtension {
+
+ private WorkContext workContext;
+
+ public CompositeReference(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ ServiceContract contract,
+ WorkContext workContext) {
+ super(name, contract.getInterfaceClass(), parent, wireService);
+ this.workContext = workContext;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return new CompositeReferenceTargetInvoker(operation, inboundWire, outboundWire, workContext);
+ }
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
+ return new CompositeReferenceCallbackTargetInvoker(operation, inboundWire, workContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java
new file mode 100644
index 0000000000..5301e024dc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvoker.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ *
+ */
+public class CompositeReferenceCallbackTargetInvoker extends AbstractCompositeReferenceTargetInvoker {
+
+ private InboundWire inboundWire;
+ private WorkContext workContext;
+
+ public CompositeReferenceCallbackTargetInvoker(Operation operation, InboundWire inboundWire, WorkContext context) {
+ super(operation);
+ this.inboundWire = inboundWire;
+ this.workContext = context;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ workContext.setCurrentMessageId(msg.getMessageId());
+ workContext.setCurrentCorrelationId(msg.getCorrelationId());
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public CompositeReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+ return (CompositeReferenceCallbackTargetInvoker) super.clone();
+ }
+
+ protected AbstractOperationOutboundInvocationHandler getInvocationHandler() {
+ return new OperationCallbackInvocationHandler(workContext, inboundWire);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java
new file mode 100644
index 0000000000..42c9c7ed82
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTargetInvoker.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ *
+ */
+public class CompositeReferenceTargetInvoker extends AbstractCompositeReferenceTargetInvoker {
+
+ private InboundWire inboundWire;
+ private OutboundWire outboundWire;
+ private WorkContext workContext;
+
+
+ public CompositeReferenceTargetInvoker(Operation operation,
+ InboundWire inboundWire,
+ OutboundWire outboundWire,
+ WorkContext workContext) {
+ super(operation);
+ this.inboundWire = inboundWire;
+ this.outboundWire = outboundWire;
+ this.workContext = workContext;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ inboundWire.addMapping(msg.getMessageId(), msg.getFromAddress());
+ workContext.setCurrentMessageId(msg.getMessageId());
+ workContext.setCurrentCorrelationId(msg.getCorrelationId());
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public CompositeReferenceTargetInvoker clone() throws CloneNotSupportedException {
+ return (CompositeReferenceTargetInvoker) super.clone();
+ }
+
+ protected AbstractOperationOutboundInvocationHandler getInvocationHandler() {
+ return new OperationOutboundInvocationHandler(outboundWire, workContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java
new file mode 100644
index 0000000000..45b1e41d13
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeService.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+public class CompositeService extends ServiceExtension {
+
+ private WorkContext workContext;
+
+ public CompositeService(String name,
+ Class<?> interfaze,
+ CompositeComponent parent,
+ WireService wireService,
+ WorkContext workContext) throws CoreRuntimeException {
+ super(name, interfaze, parent, wireService);
+ this.workContext = workContext;
+ }
+
+ /**
+ * A service for a remote binding does not need a target invoker, but a bindless service does because it gets wired
+ * localy from a reference (or from a parent service?!) We just reuse CompositeReferenceTargetInvoker for now since
+ * it seems the target invoker we need does the same thing, if this is confirmed we should give it a common name
+ * FIXME !!! Notice that this method is not defined in the SPI !!!
+ */
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return new CompositeReferenceTargetInvoker(operation, inboundWire, outboundWire, workContext);
+ }
+
+ /**
+ */
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
+ return new CompositeReferenceCallbackTargetInvoker(operation, inboundWire, workContext);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return interfaze.cast(wireService.createProxy(outboundWire));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java
new file mode 100644
index 0000000000..808f36072f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+
+/**
+ * A model object that represents a dependency on an external artifact.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Dependency extends ModelObject {
+ private Artifact artifact;
+
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ public void setArtifact(Artifact artifact) {
+ this.artifact = artifact;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/DependencyLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/DependencyLoader.java
new file mode 100644
index 0000000000..643c59bad2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/DependencyLoader.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+
+/**
+ * Loader for handling <dependency> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DependencyLoader extends LoaderExtension<Dependency> {
+ private static final String NS = "http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2";
+ private static final QName DEPENDENCY = new QName(NS, "dependency");
+ private static final QName GROUP = new QName(NS, "group");
+ private static final QName NAME = new QName(NS, "name");
+ private static final QName VERSION = new QName(NS, "version");
+ private static final QName CLASSIFIER = new QName(NS, "classifier");
+ private static final QName TYPE = new QName(NS, "type");
+
+ public DependencyLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return DEPENDENCY;
+ }
+
+ public Dependency load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ Artifact artifact = new Artifact();
+ while (reader.nextTag() == XMLStreamConstants.START_ELEMENT) {
+ QName name = reader.getName();
+ String text = reader.getElementText();
+ if (GROUP.equals(name)) {
+ artifact.setGroup(text);
+ } else if (NAME.equals(name)) {
+ artifact.setName(text);
+ } else if (VERSION.equals(name)) {
+ artifact.setVersion(text);
+ } else if (CLASSIFIER.equals(name)) {
+ artifact.setClassifier(text);
+ } else if (TYPE.equals(name)) {
+ artifact.setType(text);
+ }
+ }
+ Dependency dependency = new Dependency();
+ dependency.setArtifact(artifact);
+ return dependency;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java
new file mode 100644
index 0000000000..40051d30ba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Set;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.Version;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.CompositeClassLoader;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+
+/**
+ * Loader that handles an &lt;implementation.composite&gt; element.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationCompositeLoader extends LoaderExtension<CompositeImplementation> {
+ private static final QName IMPLEMENTATION_COMPOSITE =
+ new QName(Version.XML_NAMESPACE_1_0, "implementation.composite");
+
+ private final ArtifactRepository artifactRepository;
+
+ public ImplementationCompositeLoader(@Autowire LoaderRegistry registry,
+ @Autowire ArtifactRepository artifactRepository) {
+ super(registry);
+ this.artifactRepository = artifactRepository;
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_COMPOSITE;
+ }
+
+ public CompositeImplementation load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ assert IMPLEMENTATION_COMPOSITE.equals(reader.getName());
+ String name = reader.getAttributeValue(null, "name");
+ String group = reader.getAttributeValue(null, "group");
+ String version = reader.getAttributeValue(null, "version");
+ String scdlLocation = reader.getAttributeValue(null, "scdlLocation");
+ String jarLocation = reader.getAttributeValue(null, "jarLocation");
+ LoaderUtil.skipToEndElement(reader);
+
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setName(name);
+ if (scdlLocation != null) {
+ try {
+ impl.setScdlLocation(new URL(deploymentContext.getScdlLocation(), scdlLocation));
+ } catch (MalformedURLException e) {
+ InvalidValueException ive = new InvalidValueException(scdlLocation, e);
+ ive.setIdentifier(name);
+ throw ive;
+ }
+ impl.setClassLoader(deploymentContext.getClassLoader());
+ } else if (jarLocation != null) {
+ URL jarUrl;
+ try {
+ jarUrl = new URL(deploymentContext.getScdlLocation(), jarLocation);
+ } catch (MalformedURLException e) {
+ InvalidValueException ive = new InvalidValueException(jarLocation, e);
+ ive.setIdentifier(name);
+ throw ive;
+ }
+ try {
+ impl.setScdlLocation(new URL("jar:" + jarUrl.toExternalForm() + "!/META-INF/sca/default.scdl"));
+ } catch (MalformedURLException e) {
+ throw new AssertionError("Could not convert URL to a jar: url");
+ }
+ impl.setClassLoader(new CompositeClassLoader(new URL[]{jarUrl}, deploymentContext.getClassLoader()));
+ } else if (artifactRepository != null && group != null && version != null) {
+ Artifact artifact = new Artifact();
+ artifact.setGroup(group);
+ artifact.setName(name);
+ artifact.setVersion(version);
+ artifact.setType("jar");
+ artifactRepository.resolve(artifact);
+ if (artifact.getUrl() == null) {
+ MissingResourceException mre = new MissingResourceException(artifact.toString());
+ mre.setIdentifier(name);
+ throw mre;
+ }
+ try {
+ impl.setScdlLocation(new URL("jar:" + artifact.getUrl() + "!/META-INF/sca/default.scdl"));
+ } catch (MalformedURLException e) {
+ throw new AssertionError(e);
+ }
+ Set<URL> artifactURLs = artifact.getUrls();
+ URL[] urls = new URL[artifactURLs.size()];
+ int i = 0;
+ for (URL artifactURL : artifactURLs) {
+ urls[i++] = artifactURL;
+ }
+ impl.setClassLoader(new CompositeClassLoader(urls, deploymentContext.getClassLoader()));
+ }
+ return impl;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java
new file mode 100644
index 0000000000..df8e13a58e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationCallbackInvocationHandler.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ *
+ */
+public class OperationCallbackInvocationHandler extends AbstractOperationOutboundInvocationHandler {
+
+ private WorkContext context;
+ private InboundWire inboundWire;
+ private Object messageId;
+ private Object correlationId;
+
+ public OperationCallbackInvocationHandler(WorkContext context, InboundWire inboundWire) {
+ this.context = context;
+ this.inboundWire = inboundWire;
+ }
+
+ public Object invoke(Object proxy, Operation operation, Object[] args) throws Throwable {
+ messageId = context.getCurrentMessageId();
+ context.setCurrentMessageId(null);
+ correlationId = context.getCurrentCorrelationId();
+ context.setCurrentCorrelationId(null);
+ Object targetAddress = inboundWire.retrieveMapping(correlationId);
+ if (targetAddress == null) {
+ throw new AssertionError("No from address associated with message id [" + correlationId + "]");
+ }
+ //TODO optimize as this is slow in local invocations
+ Map<Operation<?>, OutboundInvocationChain> sourceCallbackInvocationChains =
+ inboundWire.getSourceCallbackInvocationChains(targetAddress);
+ OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation);
+ TargetInvoker invoker = chain.getTargetInvoker();
+ return invoke(chain, invoker, args);
+ }
+
+
+ public Object invoke(Operation operation, Object[] args) throws Throwable {
+ return invoke(null, operation, args);
+ }
+
+ protected Object getFromAddress() {
+ return (inboundWire.getContainer() == null) ? null : inboundWire.getContainer().getName();
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java
new file mode 100644
index 0000000000..ba49cee547
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/OperationOutboundInvocationHandler.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ *
+ */
+public class OperationOutboundInvocationHandler extends AbstractOperationOutboundInvocationHandler {
+
+ /*
+ * an association of an operation to chain holder. The holder contains an invocation chain
+ * and a local clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the
+ * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers
+ * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker
+ * is not cacheable, the master associated with the wire chains will be used.
+ */
+ private Map<Operation, ChainHolder> chains;
+ private WorkContext context;
+ private Object fromAddress;
+ private Object messageId;
+ private Object correlationId;
+
+ public OperationOutboundInvocationHandler(OutboundWire wire, WorkContext context) {
+ Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
+ this.chains = new HashMap<Operation, ChainHolder>(invocationChains.size());
+ this.fromAddress = (wire.getContainer() == null) ? null : wire.getContainer().getName();
+ // TODO optimize this
+ for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
+ Operation operation = entry.getKey();
+ this.chains.put(operation, new ChainHolder(entry.getValue()));
+ }
+
+ this.context = context;
+ }
+
+ public Object invoke(Object proxy, Operation operation, Object[] args) throws Throwable {
+ ChainHolder holder = chains.get(operation);
+ if (holder == null) {
+ TargetException e = new TargetException("Operation not configured");
+ e.setIdentifier(operation.getName());
+ throw e;
+ }
+ OutboundInvocationChain chain = holder.chain;
+ TargetInvoker invoker;
+
+ if (holder.cachedInvoker == null) {
+ assert chain != null;
+ if (chain.getTargetInvoker() == null) {
+ TargetException e = new TargetException("No target invoker configured for operation");
+ e.setIdentifier(chain.getOperation().getName());
+ throw e;
+ }
+ if (chain.getTargetInvoker().isCacheable()) {
+ // clone and store the invoker locally
+ holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
+ invoker = holder.cachedInvoker;
+ } else {
+ invoker = chain.getTargetInvoker();
+ }
+ } else {
+ assert chain != null;
+ invoker = chain.getTargetInvoker();
+ }
+ messageId = context.getCurrentMessageId();
+ context.setCurrentMessageId(null);
+ correlationId = context.getCurrentCorrelationId();
+ context.setCurrentCorrelationId(null);
+ return invoke(chain, invoker, args);
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws Throwable {
+ return invoke(null, operation, args);
+ }
+
+ protected Object getFromAddress() {
+ return fromAddress;
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+
+ /**
+ * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from
+ * the chain master
+ */
+ private class ChainHolder {
+
+ OutboundInvocationChain chain;
+ TargetInvoker cachedInvoker;
+
+ public ChainHolder(OutboundInvocationChain config) {
+ this.chain = config;
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java
new file mode 100644
index 0000000000..d6e2a35a87
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+import org.apache.tuscany.core.wire.PojoTargetInvoker;
+
+/**
+ * Responsible for performing a non-blocking dispatch on a Java component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class AsyncJavaTargetInvoker extends PojoTargetInvoker {
+
+ private JavaAtomicComponent component;
+ private InboundWire wire;
+ private AsyncMonitor monitor;
+ private WorkContext workContext;
+ private Object target;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param wire
+ * @param component the target component
+ * @param monitor the monitor to pass events to
+ * @param workContext
+ */
+ public AsyncJavaTargetInvoker(Method operation,
+ InboundWire wire,
+ JavaAtomicComponent component,
+ AsyncMonitor monitor,
+ WorkContext workContext) {
+ super(operation);
+ this.wire = wire;
+ this.component = component;
+ this.monitor = monitor;
+ this.workContext = workContext;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object messageId = msg.getMessageId();
+ wire.addMapping(messageId, msg.getFromAddress());
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(messageId);
+ invokeTarget(msg.getBody());
+ // async so no return value
+ return null;
+ } catch (Throwable e) {
+ // FIXME need to log exceptions
+ monitor.executionError(e);
+ return null;
+ }
+ }
+
+ public AsyncJavaTargetInvoker clone() throws CloneNotSupportedException {
+ return (AsyncJavaTargetInvoker) super.clone();
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!cacheable) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncMonitor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncMonitor.java
new file mode 100644
index 0000000000..6d35b32841
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncMonitor.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+/**
+ * A monitor used to log events during non-blocking invocations
+ * <p/>
+ * REVIEW JFM we should probably generalize async monitor and make it an invocation monitor
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface AsyncMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Throwable e);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java
new file mode 100644
index 0000000000..96b61dab1c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import org.apache.tuscany.core.implementation.PojoAtomicComponent;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.injection.CallbackWireObjectFactory;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.InvalidAccessorException;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.WireObjectFactory;
+
+/**
+ * The runtime instantiation of Java component implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaAtomicComponent extends PojoAtomicComponent {
+
+ private AsyncMonitor monitor;
+
+ public JavaAtomicComponent(String name,
+ PojoConfiguration configuration,
+ AsyncMonitor monitor) {
+ super(name, configuration);
+ this.scope = configuration.getScopeContainer().getScope();
+ this.monitor = monitor;
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ InboundWire wire = serviceWires.get(name);
+ if (wire == null) {
+ TargetNotFoundException e = new TargetNotFoundException(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ return wireService.createProxy(wire);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ if (serviceInterfaces.size() == 0) {
+ return getTargetInstance();
+ } else if (serviceInterfaces.size() == 1) {
+ return getTargetInstance();
+ } else {
+ throw new TargetException("Component must have exactly one service");
+ }
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ Method[] methods;
+ if (operation.isCallback()) {
+ methods = operation.getServiceContract().getCallbackClass().getMethods();
+
+ } else {
+ methods = operation.getServiceContract().getInterfaceClass().getMethods();
+ }
+ Method method = findMethod(operation, methods);
+ return new JavaTargetInvoker(method, this);
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ Method method;
+ if (operation.isCallback()) {
+ method = findMethod(operation, operation.getServiceContract().getCallbackClass().getMethods());
+
+ } else {
+ method = findMethod(operation, operation.getServiceContract().getInterfaceClass().getMethods());
+ }
+ return new AsyncJavaTargetInvoker(method, wire, this, monitor, workContext);
+ }
+
+ protected void onServiceWire(InboundWire wire) {
+ String name = wire.getCallbackReferenceName();
+ if (name == null) {
+ // It's ok not to have one, we just do nothing
+ return;
+ }
+ Member member = callbackSites.get(name);
+ if (member != null) {
+ injectors.add(createCallbackInjector(member, wire.getServiceContract(), wire));
+ }
+ }
+
+ protected Injector<Object> createCallbackInjector(Member member, ServiceContract<?> contract,
+ InboundWire inboundWire) {
+ if (member instanceof Field) {
+ Field field = (Field) member;
+ ObjectFactory<?> factory = new CallbackWireObjectFactory(contract, wireService, inboundWire);
+ return new FieldInjector<Object>(field, factory);
+ } else if (member instanceof Method) {
+ Method method = (Method) member;
+ ObjectFactory<?> factory = new CallbackWireObjectFactory(contract, wireService, inboundWire);
+ return new MethodInjector<Object>(method, factory);
+ } else {
+ InvalidAccessorException e = new InvalidAccessorException("Member must be a field or method");
+ e.setIdentifier(member.getName());
+ throw e;
+ }
+ }
+
+ protected ObjectFactory<?> createWireFactory(RuntimeWire wire) {
+ return new WireObjectFactory(wire, wireService);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java
new file mode 100644
index 0000000000..2666423b12
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+
+import org.apache.tuscany.api.annotation.Monitor;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Builds a Java-based atomic context from a component definition
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class JavaComponentBuilder extends ComponentBuilderExtension<JavaImplementation> {
+
+ private AsyncMonitor monitor;
+
+ @Monitor
+ public void setMonitor(AsyncMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ @SuppressWarnings("unchecked")
+ public AtomicComponent build(CompositeComponent parent,
+ ComponentDefinition<JavaImplementation> definition,
+ DeploymentContext deployment)
+ throws BuilderConfigException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
+ definition.getImplementation().getComponentType();
+
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setParent(parent);
+ Scope scope = componentType.getImplementationScope();
+ if (Scope.MODULE == scope) {
+ configuration.setScopeContainer(deployment.getModuleScope());
+ } else {
+ configuration.setScopeContainer(scopeRegistry.getScopeContainer(scope));
+ }
+ if (definition.getInitLevel() != null) {
+ configuration.setInitLevel(definition.getInitLevel());
+ } else {
+ configuration.setInitLevel(componentType.getInitLevel());
+ }
+ Method initMethod = componentType.getInitMethod();
+ if (initMethod != null) {
+ configuration.setInitInvoker(new MethodEventInvoker(initMethod));
+ }
+ Method destroyMethod = componentType.getDestroyMethod();
+ if (destroyMethod != null) {
+ configuration.setDestroyInvoker(new MethodEventInvoker(destroyMethod));
+ }
+
+ configuration.setWireService(wireService);
+ configuration.setWorkContext(workContext);
+ configuration.setScheduler(workScheduler);
+
+ // setup property injection sites
+ for (JavaMappedProperty<?> property : componentType.getProperties().values()) {
+ configuration.addPropertySite(property.getName(), property.getMember());
+ }
+
+ // setup reference injection sites
+ for (JavaMappedReference reference : componentType.getReferences().values()) {
+ Member member = reference.getMember();
+ if (member != null) {
+ // could be null if the reference is mapped to a constructor
+ configuration.addReferenceSite(reference.getName(), member);
+ }
+ }
+ // setup constructor injection
+ ConstructorDefinition<?> ctorDef = componentType.getConstructorDefinition();
+ Constructor<?> constr = ctorDef.getConstructor();
+ PojoObjectFactory<?> instanceFactory = new PojoObjectFactory(constr);
+ configuration.setInstanceFactory(instanceFactory);
+ configuration.getConstructorParamNames().addAll(ctorDef.getInjectionNames());
+
+ JavaAtomicComponent component =
+ new JavaAtomicComponent(definition.getName(), configuration, monitor);
+
+ // handle properties
+ for (PropertyValue<?> property : definition.getPropertyValues().values()) {
+ ObjectFactory<?> factory = property.getValueFactory();
+ if (factory != null) {
+ component.addPropertyFactory(property.getName(), factory);
+ }
+ }
+
+ for (JavaMappedService service : componentType.getServices().values()) {
+ // setup callback injection sites
+ if (service.getCallbackReferenceName() != null) {
+ // Only if there is a callback reference in the service
+ configuration.addCallbackSite(service.getCallbackReferenceName(), service.getCallbackMember());
+ }
+ }
+ return component;
+ }
+
+ protected Class<JavaImplementation> getImplementationType() {
+ return JavaImplementation.class;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java
new file mode 100644
index 0000000000..0c4f5537ab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.net.URL;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+
+import org.apache.tuscany.spi.implementation.java.Introspector;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentTypeLoader extends ComponentTypeLoaderExtension<JavaImplementation> {
+ private Introspector introspector;
+
+ @Constructor({"registry", "introspector"})
+ public JavaComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry,
+ @Autowire IntrospectionRegistry introspector) {
+ super(loaderRegistry);
+ this.introspector = introspector;
+ }
+
+ @Override
+ protected Class<JavaImplementation> getImplementationClass() {
+ return JavaImplementation.class;
+ }
+
+ public void load(CompositeComponent parent,
+ JavaImplementation implementation,
+ DeploymentContext deploymentContext) throws LoaderException {
+ Class<?> implClass = implementation.getImplementationClass();
+ URL resource = implClass.getResource(JavaIntrospectionHelper.getBaseName(implClass) + ".componentType");
+ PojoComponentType componentType;
+ if (resource == null) {
+ componentType = loadByIntrospection(parent, implementation, deploymentContext);
+ } else {
+ componentType = loadFromSidefile(resource, deploymentContext);
+ }
+ implementation.setComponentType(componentType);
+ }
+
+ protected PojoComponentType loadByIntrospection(CompositeComponent parent,
+ JavaImplementation implementation,
+ DeploymentContext deploymentContext) throws ProcessingException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Class<?> implClass = implementation.getImplementationClass();
+ introspector.introspect(parent, implClass, componentType, deploymentContext);
+ return componentType;
+ }
+
+ protected PojoComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException {
+ return loaderRegistry.load(null, url, PojoComponentType.class, deploymentContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java
new file mode 100644
index 0000000000..807db532fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class JavaImplementation extends AtomicImplementation<PojoComponentType> {
+ private Class<?> implementationClass;
+
+ public Class<?> getImplementationClass() {
+ return implementationClass;
+ }
+
+ public void setImplementationClass(Class<?> implementationClass) {
+ this.implementationClass = implementationClass;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java
new file mode 100644
index 0000000000..2ac8056d74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+public class JavaImplementationLoader extends LoaderExtension {
+ public static final QName IMPLEMENTATION_JAVA = new QName(XML_NAMESPACE_1_0, "implementation.java");
+
+ @Constructor({"registry"})
+ public JavaImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ @Override
+ public QName getXMLType() {
+ return IMPLEMENTATION_JAVA;
+ }
+
+ public ModelObject load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ assert IMPLEMENTATION_JAVA.equals(reader.getName());
+ JavaImplementation implementation = new JavaImplementation();
+ String implClass = reader.getAttributeValue(null, "class");
+ Class<?> implementationClass = LoaderUtil.loadClass(implClass, deploymentContext.getClassLoader());
+ implementation.setImplementationClass(implementationClass);
+ registry.loadComponentType(parent, implementation, deploymentContext);
+ LoaderUtil.skipToEndElement(reader);
+ return implementation;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java
new file mode 100644
index 0000000000..004929fd93
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.TargetException;
+
+import org.apache.tuscany.core.wire.PojoTargetInvoker;
+
+/**
+ * Uses a component to resolve an implementation instance based on the current thread component
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaTargetInvoker extends PojoTargetInvoker {
+
+ private JavaAtomicComponent component;
+ private Object target;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param component the target component
+ */
+ public JavaTargetInvoker(Method operation, JavaAtomicComponent component) {
+ super(operation);
+ assert component != null : "No atomic component specified";
+ this.component = component;
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!cacheable) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+
+ public JavaTargetInvoker clone() throws CloneNotSupportedException {
+ JavaTargetInvoker invoker = (JavaTargetInvoker) super.clone();
+ invoker.target = null;
+ invoker.cacheable = this.cacheable;
+ invoker.component = this.component;
+ return invoker;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java
new file mode 100644
index 0000000000..6a91bbefe4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when constructor parameters cannot be unambiguously resolved to a property or reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class AmbiguousConstructorException extends ProcessingException {
+ public AmbiguousConstructorException() {
+ }
+
+ public AmbiguousConstructorException(String message) {
+ super(message);
+ }
+
+ public AmbiguousConstructorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AmbiguousConstructorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java
new file mode 100644
index 0000000000..b363d46337
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+
+/**
+ * Handles processing of a constructor decorated with {@link org.osoa.sca.annotations.Constructor}
+ *
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings("unchecked")
+public class ConstructorProcessor extends ImplementationProcessorExtension {
+
+ private ImplementationProcessorService service;
+
+ public ConstructorProcessor(@Autowire ImplementationProcessorService service) {
+ this.service = service;
+ }
+
+ public <T> void visitClass(CompositeComponent parent, Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ Constructor[] ctors = clazz.getConstructors();
+ boolean found = false;
+ for (Constructor constructor : ctors) {
+ if (constructor.getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) {
+ if (found) {
+ DuplicateConstructorException e =
+ new DuplicateConstructorException("Multiple constructors marked with @Constructor");
+ e.setIdentifier(constructor.getDeclaringClass().getName());
+ throw e;
+ }
+ found = true;
+ }
+ }
+ }
+
+ public <T> void visitConstructor(CompositeComponent parent, Constructor<T> constructor,
+ PojoComponentType<JavaMappedService, JavaMappedReference,
+ JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ org.osoa.sca.annotations.Constructor annotation =
+ constructor.getAnnotation(org.osoa.sca.annotations.Constructor.class);
+ if (annotation == null) {
+ return;
+ }
+ ConstructorDefinition<?> definition = type.getConstructorDefinition();
+ if (definition != null && !definition.getConstructor().equals(constructor)) {
+ DuplicateConstructorException e =
+ new DuplicateConstructorException("Multiple constructor definitions found");
+ e.setIdentifier(constructor.getDeclaringClass().getName());
+ throw e;
+ } else if (definition == null) {
+ definition = new ConstructorDefinition(constructor);
+ }
+ Class<?>[] params = constructor.getParameterTypes();
+ String[] names = annotation.value();
+ Annotation[][] annotations = constructor.getParameterAnnotations();
+ List<String> injectionNames = definition.getInjectionNames();
+ for (int i = 0; i < params.length; i++) {
+ Class<?> param = params[i];
+ Annotation[] paramAnnotations = annotations[i];
+ try {
+ if (!service.processParam(param, paramAnnotations, names, i, type, injectionNames)) {
+ String name = (i < names.length) ? names[i] : "";
+ service.addName(injectionNames, i, name);
+ }
+ } catch (ProcessingException
+ e) {
+ e.setIdentifier(constructor.toString());
+ throw e;
+ }
+ }
+ if (names.length != 0 && names[0].length() != 0 && names.length != params.length) {
+ throw new InvalidConstructorException("Names in @Constructor do not match number of parameters");
+ }
+ type.setConstructorDefinition(definition);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java
new file mode 100644
index 0000000000..326bfb05f4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.annotations.Context;
+
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Processes {@link @Context} annotations on a component implementation and adds a {@link JavaMappedProperty} to the
+ * component type which will be used to inject the appropriate context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextProcessor extends ImplementationProcessorExtension {
+
+ public void visitMethod(CompositeComponent parent, Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ if (method.getAnnotation(Context.class) == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 1) {
+ IllegalContextException e = new IllegalContextException("Context setter must have one parameter");
+ e.setIdentifier(method.toString());
+ throw e;
+ }
+ Class<?> paramType = method.getParameterTypes()[0];
+ if (CompositeContext.class.equals(paramType)) {
+ String name = method.getName();
+ if (name.startsWith("set")) {
+ name = JavaIntrospectionHelper.toPropertyName(name);
+ }
+ JavaMappedProperty property = new JavaMappedProperty();
+ property.setName(name);
+ property.setMember(method);
+ throw new UnsupportedOperationException();
+ // TODO pass in composite context
+ //SingletonObjectFactory factory = new SingletonObjectFactory(compositeContext);
+ //property.setDefaultValueFactory(factory);
+ //type.getProperties().put(name,property);
+ } else if (RequestContext.class.equals(paramType)) {
+ String name = method.getName();
+ if (name.startsWith("set")) {
+ name = JavaIntrospectionHelper.toPropertyName(name);
+ }
+ JavaMappedProperty property = new JavaMappedProperty();
+ property.setName(name);
+ property.setMember(method);
+ throw new UnsupportedOperationException();
+ // TODO pass in request context
+ //property.setDefaultValueFactory(factory);
+ //type.getProperties().put(name,property);
+ } else {
+ throw new UnknownContextTypeException(paramType.getName());
+ }
+
+ }
+
+ public void visitField(CompositeComponent parent, Field field,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ super.visitField(parent, field, type, context);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java
new file mode 100644
index 0000000000..a25902566f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.osoa.sca.annotations.Destroy;
+
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Processes the {@link @Destroy} annotation on a component implementation and updates the component type with the
+ * decorated destructor method
+ *
+ * @version $Rev$ $Date$
+ */
+public class DestroyProcessor extends ImplementationProcessorExtension {
+
+ public void visitMethod(CompositeComponent parent, Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ Destroy annotation = method.getAnnotation(Destroy.class);
+ if (annotation == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 0) {
+ IllegalDestructorException e = new IllegalDestructorException("Destructor must not have argments");
+ e.setIdentifier(method.toString());
+ throw e;
+ }
+ if (type.getDestroyMethod() != null) {
+ throw new DuplicateDestructorException("More than one destructor found on implementation");
+ }
+ if (Modifier.isProtected(method.getModifiers())) {
+ method.setAccessible(true);
+ }
+ type.setDestroyMethod(method);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java
new file mode 100644
index 0000000000..909d0ef124
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when more than one component implementation constructor is annotated with {@link
+ * org.osoa.sca.annotations.Constructor}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateConstructorException extends ProcessingException {
+
+ public DuplicateConstructorException() {
+ }
+
+ public DuplicateConstructorException(String message) {
+ super(message);
+ }
+
+ public DuplicateConstructorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicateConstructorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java
new file mode 100644
index 0000000000..732dd926c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when an implementation is annotated multiple times with {@link org.osoa.sca.annotations.Destroy}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateDestructorException extends ProcessingException {
+ public DuplicateDestructorException() {
+ }
+
+ public DuplicateDestructorException(String message) {
+ super(message);
+ }
+
+ public DuplicateDestructorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicateDestructorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java
new file mode 100644
index 0000000000..6795a7bfce
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when an implementation is annotated multiple times with {@link @org.osoa.sca.annotations.Init}
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateInitException extends ProcessingException {
+ public DuplicateInitException() {
+ }
+
+ public DuplicateInitException(String message) {
+ super(message);
+ }
+
+ public DuplicateInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicateInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java
new file mode 100644
index 0000000000..da6ceaa472
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when an implementation has more than one reference injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateReferenceException extends ProcessingException {
+ public DuplicateReferenceException() {
+ }
+
+ public DuplicateReferenceException(String message) {
+ super(message);
+ }
+
+ public DuplicateReferenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicateReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
new file mode 100644
index 0000000000..27ecccafb3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
@@ -0,0 +1,521 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.OverrideOptions;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Heuristically evaluates an un-annotated Java implementation type to determine services, references, and properties
+ * according to the algorithm described in the SCA Java Client and Implementation Model Specification <p/> TODO
+ * Implement:
+ * <p/>
+ * When no service inteface is annotated, need to calculate a single service comprising all public methods that are not
+ * reference or property injection sites. If that service can be exactly mapped to an interface implemented by the class
+ * then the service interface will be defined in terms of that interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeuristicPojoProcessor extends ImplementationProcessorExtension {
+
+ private ImplementationProcessorService implService;
+
+ public HeuristicPojoProcessor(@Autowire ImplementationProcessorService service) {
+ this.implService = service;
+ }
+
+ public <T> void visitEnd(
+ CompositeComponent parent,
+ Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ Map<String, JavaMappedService> services = type.getServices();
+ if (services.isEmpty()) {
+ // heuristically determine the service
+ // TODO finish algorithm
+ Set<Class> interfaces = getAllInterfaces(clazz);
+ if (interfaces.size() == 0) {
+ // class is the interface
+ JavaMappedService service;
+ try {
+ service = implService.createService(clazz);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ type.getServices().put(service.getName(), service);
+ } else if (interfaces.size() == 1) {
+ JavaMappedService service;
+ try {
+ service = implService.createService(interfaces.iterator().next());
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ type.getServices().put(service.getName(), service);
+ }
+ }
+ Set<Method> methods = getAllUniquePublicProtectedMethods(clazz);
+ if (!type.getReferences().isEmpty() || !type.getProperties().isEmpty()) {
+ // references and properties have been explicitly defined
+ if (type.getServices().isEmpty()) {
+ calculateServiceInterface(clazz, type, methods);
+ if (type.getServices().isEmpty()) {
+ throw new ServiceTypeNotFoundException(clazz.getName());
+ }
+ }
+ evaluateConstructor(type, clazz);
+ return;
+ }
+
+ // heuristically determine the properties references
+ // make a first pass through all public methods with one param
+ for (Method method : methods) {
+ if (method.getParameterTypes().length != 1 || !Modifier.isPublic(method.getModifiers())
+ || !method.getName().startsWith("set")
+ || method.getReturnType() != void.class) {
+ continue;
+ }
+ if (!isInServiceInterface(method, services)) {
+ String name = toPropertyName(method.getName());
+ // avoid duplicate property or ref names
+ if (!type.getProperties().containsKey(name) && !type.getReferences().containsKey(name)) {
+ Class<?> param = method.getParameterTypes()[0];
+ Type genericType = method.getGenericParameterTypes()[0];
+ if (isReferenceType(genericType)) {
+ type.add(createReference(name, method, param));
+ } else {
+ type.add(createProperty(name, method, param));
+ }
+ }
+ }
+ }
+ // second pass for protected methods with one param
+ for (Method method : methods) {
+ if (method.getParameterTypes().length != 1 || !Modifier.isProtected(method.getModifiers())
+ || !method.getName().startsWith("set")
+ || method.getReturnType() != void.class) {
+ continue;
+ }
+ Class<?> param = method.getParameterTypes()[0];
+ String name = toPropertyName(method.getName());
+ // avoid duplicate property or ref names
+ if (!type.getProperties().containsKey(name) && !type.getReferences().containsKey(name)) {
+ if (isReferenceType(param)) {
+ type.add(createReference(name, method, param));
+ } else {
+ type.add(createProperty(name, method, param));
+ }
+ }
+ }
+ Set<Field> fields = getAllPublicAndProtectedFields(clazz);
+ for (Field field : fields) {
+ Class<?> paramType = field.getType();
+ if (isReferenceType(paramType)) {
+ type.add(createReference(field.getName(), field, paramType));
+ } else {
+ type.add(createProperty(field.getName(), field, paramType));
+ }
+ }
+ evaluateConstructor(type, clazz);
+ }
+
+ /**
+ * Determines the constructor to use based on the component type's references and properties
+ *
+ * @param type the component type
+ * @param clazz the implementation class corresponding to the component type
+ * @throws NoConstructorException if no suitable constructor is found
+ * @throws AmbiguousConstructorException if the parameters of a constructor cannot be unambiguously mapped to
+ * references and properties
+ */
+ @SuppressWarnings("unchecked")
+ private <T> void evaluateConstructor(
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Class<T> clazz) throws ProcessingException {
+ // determine constructor if one is not annotated
+ ConstructorDefinition<?> definition = type.getConstructorDefinition();
+ Constructor constructor;
+ boolean explict = false;
+ if (definition != null
+ && definition.getConstructor().getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) {
+ // the constructor was already defined explicitly
+ return;
+ } else if (definition != null) {
+ explict = true;
+ constructor = definition.getConstructor();
+ } else {
+ // no definition, heuristically determine constructor
+ Constructor[] constructors = clazz.getConstructors();
+ if (constructors.length == 0) {
+ NoConstructorException e = new NoConstructorException("No public constructor for class");
+ e.setIdentifier(clazz.getName());
+ throw e;
+ } else if (constructors.length == 1) {
+ constructor = constructors[0];
+ } else {
+ // FIXME multiple constructors, none yet done
+ Constructor<T> selected = null;
+ int sites = type.getProperties().size() + type.getReferences().size();
+ for (Constructor<T> ctor : constructors) {
+ if (ctor.getParameterTypes().length == 0) {
+ selected = ctor;
+ }
+ if (ctor.getParameterTypes().length == sites) {
+ // TODO finish
+ // selected = constructor;
+ // select constructor
+ // break;
+ }
+ }
+ if (selected == null) {
+ throw new NoConstructorException();
+ }
+ constructor = selected;
+ definition = new ConstructorDefinition<T>(selected);
+ type.setConstructorDefinition(definition);
+ // return;
+ }
+ definition = new ConstructorDefinition<T>(constructor);
+ type.setConstructorDefinition(definition);
+ }
+ Class[] params = constructor.getParameterTypes();
+ if (params.length == 0) {
+ return;
+ }
+ List<String> paramNames = definition.getInjectionNames();
+ Map<String, JavaMappedProperty<?>> props = type.getProperties();
+ Map<String, JavaMappedReference> refs = type.getReferences();
+ Annotation[][] annotations = constructor.getParameterAnnotations();
+ if (!explict) {
+ // the constructor wasn't defined by an annotation, so check to see if any of the params have an annotation
+ // which we can impute as explicitly defining the constructor, e.g. @Property, @Reference, or @Autowire
+ explict = implService.injectionAnnotationsPresent(annotations);
+ }
+ if (explict) {
+ for (int i = 0; i < params.length; i++) {
+ Class param = params[i];
+ implService.processParam(param, annotations[i], new String[0], i, type, paramNames);
+ }
+ } else {
+ if (!implService.areUnique(params)) {
+ throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor");
+ }
+ if (!calcPropRefUniqueness(props.values(), refs.values())) {
+ throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor");
+ }
+ boolean empty = props.size() + refs.size() == 0;
+ if (!empty) {
+ // the constructor param types must unambiguously match defined reference or property types
+ for (Class param : params) {
+ String name = findReferenceOrProperty(param, props, refs);
+ if (name == null) {
+ throw new AmbiguousConstructorException(param.getName());
+ }
+ paramNames.add(name);
+ }
+ } else {
+ // heuristically determine refs and props from the parameter types
+ for (Class<?> param : params) {
+ String name = getBaseName(param).toLowerCase();
+ if (isReferenceType(param)) {
+ refs.put(name, createReference(name, null, param));
+ } else {
+ props.put(name, createProperty(name, null, param));
+ }
+ paramNames.add(name);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns true if the union of the given collections of properties and references have unique Java types
+ */
+ private boolean calcPropRefUniqueness(
+ Collection<JavaMappedProperty<?>> props,
+ Collection<JavaMappedReference> refs) {
+
+ Class[] classes = new Class[props.size() + refs.size()];
+ int i = 0;
+ for (JavaMappedProperty<?> property : props) {
+ classes[i] = property.getJavaType();
+ i++;
+ }
+ for (JavaMappedReference reference : refs) {
+ classes[i] = reference.getServiceContract().getInterfaceClass();
+ i++;
+ }
+ return implService.areUnique(classes);
+ }
+
+ /**
+ * Unambiguously finds the reference or property associated with the given type
+ *
+ * @return the name of the reference or property if found, null if not
+ * @throws AmbiguousConstructorException if the constructor parameter cannot be resolved to a property or reference
+ */
+ private String findReferenceOrProperty(
+ Class<?> type,
+ Map<String, JavaMappedProperty<?>> props,
+ Map<String, JavaMappedReference> refs) throws AmbiguousConstructorException {
+
+ String name = null;
+ for (JavaMappedProperty<?> property : props.values()) {
+ if (property.getJavaType().equals(type)) {
+ if (name != null) {
+ AmbiguousConstructorException e =
+ new AmbiguousConstructorException("Ambiguous property or reference for constructor type");
+ e.setIdentifier(type.getName());
+ throw e;
+ }
+ name = property.getName();
+ // do not break since ambiguities must be checked, i.e. more than one prop or ref of the same type
+ }
+ }
+ for (JavaMappedReference reference : refs.values()) {
+ if (reference.getServiceContract().getInterfaceClass().equals(type)) {
+ if (name != null) {
+ AmbiguousConstructorException e =
+ new AmbiguousConstructorException("Ambiguous property or reference for constructor type");
+ e.setIdentifier(type.getName());
+ throw e;
+ }
+ name = reference.getName();
+ // do not break since ambiguities must be checked, i.e. more than one prop or ref of the same type
+ }
+ }
+ return name;
+ }
+
+ /**
+ * Returns true if a given type is reference according to the SCA specification rules for determining reference
+ * types
+ */
+ private boolean isReferenceType(Type operationType) {
+ Class<?> rawType;
+ Class<?> referenceType = null;
+ if (operationType instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) operationType;
+ rawType = (Class<?>) parameterizedType.getRawType();
+ Type[] typeArgs = parameterizedType.getActualTypeArguments();
+ if (typeArgs.length == 1) {
+ referenceType = (Class<?>) typeArgs[0];
+ }
+ } else {
+ rawType = (Class<?>) operationType;
+ }
+ if (rawType.isArray()) {
+ referenceType = rawType.getComponentType();
+ } else if (Collection.class.isAssignableFrom(rawType) && referenceType == null) {
+ return true;
+ }
+ if (referenceType != null) {
+ return referenceType.getAnnotation(Remotable.class) != null
+ || referenceType.getAnnotation(Service.class) != null;
+ } else {
+ return rawType.getAnnotation(Remotable.class) != null || rawType.getAnnotation(Service.class) != null;
+ }
+ }
+
+ /**
+ * Returns true if the given operation is defined in the collection of service interfaces
+ */
+ private boolean isInServiceInterface(Method operation, Map<String, JavaMappedService> services) {
+ for (JavaMappedService service : services.values()) {
+ Class<?> clazz = service.getServiceContract().getInterfaceClass();
+ if (operation.getDeclaringClass().equals(clazz)) {
+ return true;
+ }
+ Method[] methods = service.getServiceContract().getInterfaceClass().getMethods();
+ for (Method method : methods) {
+ if (operation.getName().equals(method.getName())
+ && operation.getParameterTypes().length == method.getParameterTypes().length) {
+ Class<?>[] methodTypes = method.getParameterTypes();
+ for (int i = 0; i < operation.getParameterTypes().length; i++) {
+ Class<?> paramType = operation.getParameterTypes()[i];
+ if (!paramType.equals(methodTypes[i])) {
+ break;
+ } else if (i == operation.getParameterTypes().length - 1) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Creates a mapped reference
+ *
+ * @param name the reference name
+ * @param member the injection site the reference maps to
+ * @param paramType the service interface of the reference
+ */
+ private JavaMappedReference createReference(String name, Member member, Class<?> paramType)
+ throws ProcessingException {
+ return implService.createReference(name, member, paramType);
+ }
+
+ /**
+ * Creates a mapped property
+ *
+ * @param name the property name
+ * @param member the injection site the reference maps to
+ * @param paramType the property type
+ */
+ private <T> JavaMappedProperty<T> createProperty(String name, Member member, Class<T> paramType) {
+ JavaMappedProperty<T> property = new JavaMappedProperty<T>();
+ property.setName(name);
+ property.setMember(member);
+ property.setOverride(OverrideOptions.MAY);
+ property.setJavaType(paramType);
+ return property;
+ }
+
+ /**
+ * Populates a component type with a service whose interface type is determined by examining all implemented
+ * interfaces of the given class and chosing one whose operations match all of the class's non-property and
+ * non-reference methods
+ *
+ * @param clazz the class to examine
+ * @param type the component type
+ * @param methods all methods in the class to examine
+ */
+ private void calculateServiceInterface(
+ Class<?> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Set<Method> methods) throws ProcessingException {
+ List<Method> nonPropRefMethods = new ArrayList<Method>();
+ // Map<String, JavaMappedService> services = type.getServices();
+ Map<String, JavaMappedReference> references = type.getReferences();
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ // calculate methods that are not properties or references
+ for (Method method : methods) {
+ String name = toPropertyName(method.getName());
+ if (!references.containsKey(name) && !properties.containsKey(name)) {
+ nonPropRefMethods.add(method);
+ }
+ }
+ // determine if an implemented interface matches all of the non-property and non-reference methods
+ Class[] interfaces = clazz.getInterfaces();
+ if (interfaces.length == 0) {
+ return;
+ }
+ for (Class interfaze : interfaces) {
+ if (analyzeInterface(interfaze, nonPropRefMethods)) {
+ JavaMappedService service;
+ try {
+ service = implService.createService(interfaze);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ type.getServices().put(service.getName(), service);
+ }
+ }
+ }
+
+ /**
+ * Determines if the methods of a given interface match the given list of methods
+ *
+ * @param interfaze the interface to examine
+ * @param nonPropRefMethods the list of methods to match against
+ * @return true if the interface matches
+ */
+ private boolean analyzeInterface(Class<?> interfaze, List<Method> nonPropRefMethods) {
+ Method[] interfaceMethods = interfaze.getMethods();
+ if (nonPropRefMethods.size() != interfaceMethods.length) {
+ return false;
+ }
+ for (Method method : nonPropRefMethods) {
+ boolean found = false;
+ for (Method interfaceMethod : interfaceMethods) {
+ if (interfaceMethod.getName().equals(method.getName())) {
+ Class<?>[] interfaceParamTypes = interfaceMethod.getParameterTypes();
+ Class<?>[] methodParamTypes = method.getParameterTypes();
+ if (interfaceParamTypes.length == methodParamTypes.length) {
+ if (interfaceParamTypes.length == 0) {
+ found = true;
+ } else {
+ for (int i = 0; i < methodParamTypes.length; i++) {
+ Class<?> param = methodParamTypes[i];
+ if (!param.equals(interfaceParamTypes[i])) {
+ break;
+ }
+ if (i == methodParamTypes.length - 1) {
+ found = true;
+ }
+ }
+ }
+ }
+ if (found) {
+ break;
+ }
+ }
+ }
+ if (!found) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
+
+/*
+ * 1) public setter methods that are not included in any service interface 2) protected setter methods 3) public or
+ * protected fields unless there is a setter method for the same name If the type associated with the member is an array
+ * or a java.util.Collection, then the basetype will be the element type of the array or the parameterized type of the
+ * Collection, otherwise the basetype will be the member type. If the basetype is an interface with an @Remotable or
+ * @Service annotation then the member will be defined as a reference, otherwise it will be defined as a property.
+ *
+ *
+ */
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java
new file mode 100644
index 0000000000..7ad5b7e526
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an illegcal use of {@link org.osoa.sca.annotations.Callback} on a reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalCallbackReferenceException extends ProcessingException {
+ public IllegalCallbackReferenceException() {
+ }
+
+ public IllegalCallbackReferenceException(String message) {
+ super(message);
+ }
+
+ public IllegalCallbackReferenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalCallbackReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java
new file mode 100644
index 0000000000..9c64b3dee8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an illegal signature for a method decorated with {@link org.osoa.sca.annotations.Context}
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalContextException extends ProcessingException {
+ public IllegalContextException() {
+ }
+
+ public IllegalContextException(String message) {
+ super(message);
+ }
+
+ public IllegalContextException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalContextException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java
new file mode 100644
index 0000000000..b412a38bb9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an illegal signature for a method decorated with {@link org.osoa.sca.annotations.Destroy}
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalDestructorException extends ProcessingException {
+ public IllegalDestructorException() {
+ }
+
+ public IllegalDestructorException(String message) {
+ super(message);
+ }
+
+ public IllegalDestructorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalDestructorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java
new file mode 100644
index 0000000000..615a81926c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an illegal signature for a method decorated with {@link @org.osoa.sca.annotations.Init}
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalInitException extends ProcessingException {
+ public IllegalInitException() {
+ }
+
+ public IllegalInitException(String message) {
+ super(message);
+ }
+
+ public IllegalInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java
new file mode 100644
index 0000000000..10a75baaa5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an illegal reference definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalReferenceException extends ProcessingException {
+ public IllegalReferenceException() {
+ }
+
+ public IllegalReferenceException(String message) {
+ super(message);
+ }
+
+ public IllegalReferenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java
new file mode 100644
index 0000000000..60fd13a3e5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an illegal use of the {@link @org.osoa.sca.annotations.Service} annotation
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalServiceDefinitionException extends ProcessingException {
+ public IllegalServiceDefinitionException() {
+ }
+
+ public IllegalServiceDefinitionException(String message) {
+ super(message);
+ }
+
+ public IllegalServiceDefinitionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalServiceDefinitionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
new file mode 100644
index 0000000000..2c2b40bc3e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.List;
+import javax.xml.namespace.QName;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Remotable;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.OverrideOptions;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import org.apache.tuscany.core.idl.java.IllegalCallbackException;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+
+/**
+ * The default implementation of an <code>ImplementationProcessorService</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationProcessorServiceImpl implements ImplementationProcessorService {
+ private JavaInterfaceProcessorRegistry registry;
+
+ public ImplementationProcessorServiceImpl(@Autowire JavaInterfaceProcessorRegistry registry) {
+ this.registry = registry;
+ }
+
+ public JavaMappedService createService(Class<?> interfaze) throws InvalidServiceContractException {
+ JavaMappedService service = new JavaMappedService();
+ service.setName(getBaseName(interfaze));
+ service.setRemotable(interfaze.getAnnotation(Remotable.class) != null);
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ service.setServiceContract(contract);
+ return service;
+ }
+
+ public void processCallback(Class<?> interfaze, ServiceContract<?> contract) throws IllegalCallbackException {
+ Callback callback = interfaze.getAnnotation(Callback.class);
+ if (callback != null && !Void.class.equals(callback.value())) {
+ Class<?> callbackClass = callback.value();
+ contract.setCallbackClass(callbackClass);
+ contract.setCallbackName(getBaseName(callbackClass));
+ } else if (callback != null && Void.class.equals(callback.value())) {
+ IllegalCallbackException e = new IllegalCallbackException(
+ "Callback annotation must specify an interface on service type");
+ e.setIdentifier(interfaze.getName());
+ throw e;
+ }
+ }
+
+ public boolean areUnique(Class[] collection) {
+ if (collection.length == 0) {
+ return true;
+ }
+ return areUnique(collection, 0);
+ }
+
+ public void addName(List<String> names, int pos, String name) {
+ if (names.size() < pos) {
+ for (int i = 0; i < pos; i++) {
+ names.add(i, "");
+ }
+ names.add(name);
+ } else if (names.size() > pos) {
+ names.remove(pos);
+ names.add(pos, name);
+ } else {
+ names.add(pos, name);
+ }
+ }
+
+ public boolean processParam(
+ Class<?> param,
+ Annotation[] paramAnnotations,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ List<String> injectionNames) throws ProcessingException {
+ boolean processed = false;
+ for (Annotation annot : paramAnnotations) {
+ if (Autowire.class.equals(annot.annotationType())) {
+ processed = true;
+ processAutowire(annot, constructorNames, pos, param, type, injectionNames);
+ } else if (Property.class.equals(annot.annotationType())) {
+ processed = true;
+ processProperty(annot, constructorNames, pos, type, param, injectionNames);
+ } else if (Reference.class.equals(annot.annotationType())) {
+ processed = true;
+ processReference(annot, constructorNames, pos, type, param, injectionNames);
+ }
+ }
+ return processed;
+ }
+
+ public boolean injectionAnnotationsPresent(Annotation[][] annots) {
+ for (Annotation[] annotations : annots) {
+ for (Annotation annotation : annotations) {
+ Class<? extends Annotation> annotType = annotation.annotationType();
+ if (annotType.equals(Autowire.class) || annotType.equals(Property.class)
+ || annotType.equals(Reference.class)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determines if all the members of a collection have unique types
+ *
+ * @param collection the collection to analyze
+ * @param start the position in the collection to start
+ * @return true if the types are unique
+ */
+ private boolean areUnique(Class[] collection, int start) {
+ Object compare = collection[start];
+ for (int i = start + 1; i < collection.length; i++) {
+ if (compare.equals(collection[i])) {
+ return false;
+ }
+ }
+ if (start + 1 < collection.length) {
+ return areUnique(collection, start + 1);
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Processes autowire metadata for a constructor parameter
+ *
+ * @param annot the autowire annotation
+ * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor}
+ * annotation
+ * @param pos the position of the parameter in the constructor's parameter list
+ * @param param the parameter type
+ * @param type the component type associated with the implementation being processed
+ * @param injectionNames the collection of injection names to update
+ * @throws InvalidAutowireException
+ * @throws InvalidConstructorException
+ */
+ private void processAutowire(
+ Annotation annot,
+ String[] constructorNames,
+ int pos,
+ Class<?> param,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ List<String> injectionNames) throws InvalidAutowireException, InvalidConstructorException {
+ // the param is marked as an autowire
+ Autowire autowireAnnot = (Autowire) annot;
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setAutowire(true);
+ String name = autowireAnnot.name();
+ if (name == null || name.length() == 0) {
+ if (constructorNames.length > 1 && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) {
+ throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at "
+ + (pos + 1));
+ } else if (constructorNames.length == 1 && constructorNames[0].length() == 0) {
+ // special case when @Constructor present with all autowire params not specifying any name
+ name = param.getName() + String.valueOf(pos);
+ } else if (constructorNames.length == 1
+ && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) {
+ throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at "
+ + (pos + 1));
+ } else if (constructorNames.length == 1 && constructorNames[0].length() > 0) {
+ name = constructorNames[pos];
+ } else if (constructorNames.length == 0 || constructorNames[pos].length() == 0) {
+ name = param.getName() + String.valueOf(pos);
+ } else {
+ name = constructorNames[pos];
+ }
+ } else if (pos < constructorNames.length && constructorNames[pos] != null
+ && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
+ throw new InvalidConstructorException("Name specified by @Constructor does not match autowire name at "
+ + (pos + 1));
+ }
+ reference.setName(name);
+
+ reference.setRequired(autowireAnnot.required());
+
+ ServiceContract<?> contract = new JavaServiceContract();
+ contract.setInterfaceClass(param);
+ reference.setServiceContract(contract);
+ type.getReferences().put(name, reference);
+ addName(injectionNames, pos, name);
+ }
+
+ /**
+ * Processes parameter metadata for a constructor parameter
+ *
+ * @param annot the parameter annotation
+ * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor}
+ * annotation
+ * @param pos the position of the parameter in the constructor's parameter list
+ * @param type the component type associated with the implementation being processed
+ * @param param the parameter type
+ * @param explicitNames the collection of injection names to update
+ * @throws ProcessingException
+ */
+ private <T> void processProperty(
+ Annotation annot,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Class<T> param,
+ List<String> explicitNames) throws ProcessingException {
+ // TODO multiplicity
+ // the param is marked as a property
+ Property propAnnot = (Property) annot;
+ JavaMappedProperty<T> property = new JavaMappedProperty<T>();
+ String name = propAnnot.name();
+ if (name == null || name.length() == 0) {
+ if (constructorNames.length < pos + 1 || constructorNames[pos] == null
+ || constructorNames[pos].length() == 0) {
+ throw new InvalidPropertyException("No name specified for property parameter " + (pos + 1));
+ }
+ name = constructorNames[pos];
+ } else if (pos < constructorNames.length && constructorNames[pos] != null
+ && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
+ throw new InvalidConstructorException("Name specified by @Constructor does not match property name at "
+ + (pos + 1));
+ }
+ if (type.getProperties().get(name) != null) {
+ throw new DuplicatePropertyException(name);
+ }
+ property.setName(name);
+ property.setOverride(OverrideOptions.valueOf(propAnnot.override().toUpperCase()));
+
+ property.setXmlType(QName.valueOf(propAnnot.xmlType()));
+ property.setJavaType(param);
+ type.getProperties().put(name, property);
+ addName(explicitNames, pos, name);
+ }
+
+ /**
+ * Processes reference metadata for a constructor parameter
+ *
+ * @param annot the parameter annotation
+ * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor}
+ * annotation
+ * @param pos the position of the parameter in the constructor's parameter list
+ * @param type the component type associated with the implementation being processed
+ * @param param the parameter type
+ * @param explicitNames the collection of injection names to update
+ * @throws ProcessingException
+ */
+ private void processReference(
+ Annotation annot,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ Class<?> param,
+ List<String> explicitNames) throws ProcessingException {
+
+ // TODO multiplicity
+ // the param is marked as a reference
+ Reference refAnnotation = (Reference) annot;
+ JavaMappedReference reference = new JavaMappedReference();
+ String name = refAnnotation.name();
+ if (name == null || name.length() == 0) {
+ if (constructorNames.length < pos + 1 || constructorNames[pos] == null
+ || constructorNames[pos].length() == 0) {
+ throw new InvalidReferenceException("No name specified for reference parameter " + (pos + 1));
+ }
+ name = constructorNames[pos];
+ } else if (pos < constructorNames.length && constructorNames[pos] != null
+ && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
+ throw new InvalidConstructorException("Name specified by @Constructor does not match reference name at "
+ + (pos + 1));
+ }
+ if (type.getReferences().get(name) != null) {
+ throw new DuplicateReferenceException(name);
+ }
+ reference.setName(name);
+ reference.setRequired(refAnnotation.required());
+ try {
+ ServiceContract<?> contract = registry.introspect(param);
+ reference.setServiceContract(contract);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ type.getReferences().put(name, reference);
+ addName(explicitNames, pos, name);
+ }
+
+ public JavaMappedReference createReference(String name, Member member, Class<?> paramType)
+ throws ProcessingException {
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setName(name);
+ reference.setMember(member);
+ reference.setRequired(false);
+ ServiceContract contract = null;
+ try {
+ contract = registry.introspect(paramType);
+ } catch (InvalidServiceContractException e1) {
+ throw new ProcessingException(e1);
+ }
+ try {
+ processCallback(paramType, contract);
+ } catch (IllegalCallbackException e) {
+ throw new ProcessingException(e);
+ }
+ reference.setServiceContract(contract);
+ return reference;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java
new file mode 100644
index 0000000000..cf32e8b855
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Processes the {@link @Init} annotation on a component implementation and updates the component type with the
+ * decorated initializer method
+ *
+ * @version $Rev$ $Date$
+ */
+public class InitProcessor extends ImplementationProcessorExtension {
+
+ public void visitMethod(CompositeComponent parent, Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ Init annotation = method.getAnnotation(Init.class);
+ if (annotation == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 0) {
+ IllegalInitException e = new IllegalInitException("Initializer must not have argments");
+ e.setIdentifier(method.toString());
+ throw e;
+ }
+ if (type.getInitMethod() != null) {
+ throw new DuplicateInitException("More than one initializer found on implementaton");
+ }
+ if (Modifier.isProtected(method.getModifiers())) {
+ method.setAccessible(true);
+ }
+ type.setEagerInit(annotation.eager());
+ type.setInitMethod(method);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java
new file mode 100644
index 0000000000..1a46b22d8d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an invalid usage of {@link org.apache.tuscany.spi.annotation.Autowire}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidAutowireException extends ProcessingException {
+
+ public InvalidAutowireException() {
+ }
+
+ public InvalidAutowireException(String message) {
+ super(message);
+ }
+
+ public InvalidAutowireException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidAutowireException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java
new file mode 100644
index 0000000000..ded7b8886a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an invalid constructor definition, e.g. when the number of injection names specified in {@link
+ * org.osoa.sca.annotations.Constructor} do not match the number of actual constructor parameters
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConstructorException extends ProcessingException {
+ public InvalidConstructorException() {
+ }
+
+ public InvalidConstructorException(String message) {
+ super(message);
+ }
+
+ public InvalidConstructorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidConstructorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java
new file mode 100644
index 0000000000..7a45d22605
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an invalid usage of {@link org.osoa.sca.annotations.Property}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidPropertyException extends ProcessingException {
+
+ public InvalidPropertyException() {
+ }
+
+ public InvalidPropertyException(String message) {
+ super(message);
+ }
+
+ public InvalidPropertyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidPropertyException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java
new file mode 100644
index 0000000000..634acaaaed
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Denotes an invalid usage of {@link org.osoa.sca.annotations.Reference}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidReferenceException extends ProcessingException {
+
+ public InvalidReferenceException() {
+ }
+
+ public InvalidReferenceException(String message) {
+ super(message);
+ }
+
+ public InvalidReferenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java
new file mode 100644
index 0000000000..36936acbfb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when a service type specified by an {@link org.osoa.sca.annotations.Service} annotation is invalid, e.g. it is
+ * not an interface
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidServiceType extends ProcessingException {
+ public InvalidServiceType() {
+ }
+
+ public InvalidServiceType(String message) {
+ super(message);
+ }
+
+ public InvalidServiceType(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidServiceType(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java
new file mode 100644
index 0000000000..e7acce2973
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.AbstractPropertyProcessor;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+
+import org.apache.tuscany.api.annotation.Monitor;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * Processes an {@link @Monitor} annotation, updating the component type with corresponding {@link
+ * org.apache.tuscany.spi.implementation.java.JavaMappedProperty}
+ *
+ * @version $Rev$ $Date$
+ */
+public class MonitorProcessor extends AbstractPropertyProcessor<Monitor> {
+ private MonitorFactory monitorFactory;
+
+ public MonitorProcessor(@Autowire MonitorFactory monitorFactory, @Autowire ImplementationProcessorService service) {
+ super(Monitor.class, service);
+ this.monitorFactory = monitorFactory;
+ }
+
+ protected String getName(Monitor annotation) {
+ return null;
+ }
+
+ protected <T> void initProperty(JavaMappedProperty<T> property,
+ Monitor annotation,
+ CompositeComponent parent,
+ DeploymentContext context) {
+ Class<T> javaType = property.getJavaType();
+ property.setDefaultValueFactory(new SingletonObjectFactory<T>(monitorFactory.getMonitor(javaType)));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java
new file mode 100644
index 0000000000..78a9c6b503
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when a suitable constructor for a component implementation cannot be found
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoConstructorException extends ProcessingException {
+
+ public NoConstructorException() {
+ }
+
+ public NoConstructorException(String message) {
+ super(message);
+ }
+
+ public NoConstructorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoConstructorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java
new file mode 100644
index 0000000000..09b3c7383d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.implementation.java.AbstractPropertyProcessor;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.OverrideOptions;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Processes an {@link @Property} annotation, updating the component type with corresponding {@link JavaMappedProperty}
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
+ private SimpleTypeMapperExtension typeMapper = new SimpleTypeMapperExtension();
+
+ public PropertyProcessor(@Autowire ImplementationProcessorService service) {
+ super(Property.class, service);
+ }
+
+ protected String getName(Property annotation) {
+ return annotation.name();
+ }
+
+ protected <T> void initProperty(JavaMappedProperty<T> property,
+ Property annotation,
+ CompositeComponent parent,
+ DeploymentContext context) {
+ property.setOverride(OverrideOptions.valueOf(annotation.override().toUpperCase()));
+ String xmlType = annotation.xmlType();
+ if (xmlType != null && xmlType.length() != 0) {
+ property.setXmlType(QName.valueOf(annotation.xmlType()));
+ } else {
+ TypeInfo type = typeMapper.getXMLType(property.getJavaType());
+ if (type != null) {
+ property.setXmlType(type.getQName());
+ }
+ }
+ }
+
+ public <T> void visitConstructor(CompositeComponent parent, Constructor<T> constructor,
+ PojoComponentType<JavaMappedService, JavaMappedReference,
+ JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ // override since heuristic pojo processor evalautes properties
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java
new file mode 100644
index 0000000000..d96f31023b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+
+/**
+ * Processes an {@link @Reference} annotation, updating the component type with corresponding {@link
+ * org.apache.tuscany.spi.implementation.java.JavaMappedReference}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceProcessor extends ImplementationProcessorExtension {
+
+ private JavaInterfaceProcessorRegistry regsitry;
+
+ public ReferenceProcessor(@Autowire JavaInterfaceProcessorRegistry registry) {
+ this.regsitry = registry;
+ }
+
+ public void visitMethod(CompositeComponent parent, Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ Reference annotation = method.getAnnotation(Reference.class);
+ Autowire autowire = method.getAnnotation(Autowire.class);
+ boolean isAutowire = autowire != null;
+ if (annotation == null && !isAutowire) {
+ return; //Not a reference or autowire annotation.
+ }
+ if (method.getParameterTypes().length != 1) {
+ IllegalReferenceException e = new IllegalReferenceException("Setter must have one parameter");
+ e.setIdentifier(method.toString());
+ throw e;
+ }
+ //process autowire required first let reference override. or if conflicting should this fault?
+ boolean required = false;
+ if (isAutowire) {
+ required = autowire.required();
+ }
+
+ String name = null;
+
+ if (annotation != null) {
+ if (annotation.name() != null && annotation.name().length() > 0) {
+ name = annotation.name();
+ }
+ required = annotation.required();
+ }
+ if (name == null) {
+ name = method.getName();
+ if (method.getName().startsWith("set")) {
+ name = toPropertyName(method.getName());
+ }
+ }
+ if (type.getReferences().get(name) != null) {
+ throw new DuplicateReferenceException(name);
+ }
+
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setMember(method);
+ reference.setAutowire(isAutowire);
+ reference.setRequired(required);
+ reference.setName(name);
+ ServiceContract contract;
+ try {
+ contract = regsitry.introspect(method.getParameterTypes()[0]);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ reference.setServiceContract(contract);
+ type.getReferences().put(name, reference);
+ }
+
+ public void visitField(CompositeComponent parent, Field field,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ Reference annotation = field.getAnnotation(Reference.class);
+ boolean autowire = field.getAnnotation(Autowire.class) != null;
+ if (annotation == null && !autowire) {
+ return;
+ }
+ String name = field.getName();
+ boolean required = false;
+ if (annotation != null) {
+ if (annotation.name() != null) {
+ name = annotation.name();
+ }
+ required = annotation.required();
+ }
+ if (name.length() == 0) {
+ name = field.getName();
+ }
+ if (type.getReferences().get(name) != null) {
+ throw new DuplicateReferenceException(name);
+ }
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setMember(field);
+ reference.setRequired(required);
+ reference.setAutowire(autowire);
+ reference.setName(name);
+ ServiceContract contract;
+ try {
+ contract = regsitry.introspect(field.getType());
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ reference.setServiceContract(contract);
+ type.getReferences().put(name, reference);
+ }
+
+ public <T> void visitConstructor(CompositeComponent parent, Constructor<T> constructor,
+ PojoComponentType<JavaMappedService, JavaMappedReference,
+ JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
new file mode 100644
index 0000000000..3827a82652
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * Processes the {@link Scope} annotation and updates the component type with the corresponding implmentation scope
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeProcessor extends ImplementationProcessorExtension {
+
+ public <T> void visitClass(CompositeComponent parent, Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ org.osoa.sca.annotations.Scope annotation = clazz.getAnnotation(org.osoa.sca.annotations.Scope.class);
+ if (annotation == null) {
+ type.setImplementationScope(Scope.STATELESS);
+ return;
+ }
+ //FIXME deal with eager init
+ String name = annotation.value();
+ Scope scope;
+ if ("MODULE".equals(name)) {
+ scope = Scope.MODULE;
+ } else if ("SESSION".equals(name)) {
+ scope = Scope.SESSION;
+ } else if ("REQUEST".equals(name)) {
+ scope = Scope.REQUEST;
+ } else if ("COMPOSITE".equals(name)) {
+ scope = Scope.COMPOSITE;
+ } else {
+ scope = new Scope(name);
+ }
+ type.setImplementationScope(scope);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java
new file mode 100644
index 0000000000..5e4e561228
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+
+/**
+ * Processes an {@link org.osoa.sca.annotations.Service} annotation and updates the component type with corresponding
+ * {@link JavaMappedService}s. Also processes related {@link org.osoa.sca.annotations.Callback} annotations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceProcessor extends ImplementationProcessorExtension {
+
+ private ImplementationProcessorService implService;
+
+ public ServiceProcessor(@Autowire ImplementationProcessorService implService) {
+ this.implService = implService;
+ }
+
+ public <T> void visitClass(CompositeComponent parent, Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ org.osoa.sca.annotations.Service annotation = clazz.getAnnotation(org.osoa.sca.annotations.Service.class);
+ if (annotation == null) {
+ // scan intefaces for remotable
+ Set<Class> interfaces = getAllInterfaces(clazz);
+ for (Class<?> interfaze : interfaces) {
+ if (interfaze.getAnnotation(Remotable.class) != null) {
+ JavaMappedService service;
+ try {
+ service = implService.createService(interfaze);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ type.getServices().put(service.getName(), service);
+ }
+ }
+ return;
+ }
+ Class<?>[] interfaces = annotation.interfaces();
+ if (interfaces.length == 0) {
+ Class<?> interfaze = annotation.value();
+ if (Void.class.equals(interfaze)) {
+ throw new IllegalServiceDefinitionException("No interfaces specified");
+ } else {
+ interfaces = new Class<?>[1];
+ interfaces[0] = interfaze;
+ }
+ }
+ for (Class<?> interfaze : interfaces) {
+ if (!interfaze.isInterface()) {
+ InvalidServiceType e = new InvalidServiceType("Service must be an interface");
+ e.setIdentifier(interfaze.getName());
+ throw e;
+ }
+ JavaMappedService service;
+ try {
+ service = implService.createService(interfaze);
+ } catch (InvalidServiceContractException e) {
+ throw new ProcessingException(e);
+ }
+ type.getServices().put(service.getName(), service);
+ }
+ }
+
+
+ public void visitMethod(CompositeComponent parent,
+ Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+
+ Callback annotation = method.getAnnotation(Callback.class);
+ if (annotation == null) {
+ return;
+ }
+ if (method.getParameterTypes().length != 1) {
+ IllegalCallbackReferenceException e =
+ new IllegalCallbackReferenceException("Setter must have one parameter");
+ e.setIdentifier(method.toString());
+ throw e;
+ }
+ String name = toPropertyName(method.getName());
+ JavaMappedService callbackService = null;
+ Class<?> callbackClass = method.getParameterTypes()[0];
+ for (JavaMappedService service : type.getServices().values()) {
+ ServiceContract serviceContract = service.getServiceContract();
+ if (serviceContract.getCallbackClass().equals(callbackClass)) {
+ callbackService = service;
+ }
+ }
+ if (callbackService == null) {
+ throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface");
+ }
+ callbackService.setCallbackReferenceName(name);
+ callbackService.setCallbackMember(method);
+ }
+
+ public void visitField(CompositeComponent parent, Field field,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+
+ Callback annotation = field.getAnnotation(Callback.class);
+ if (annotation == null) {
+ return;
+ }
+ String name = field.getName();
+ JavaMappedService callbacksService = null;
+ Class<?> callbackClass = field.getType();
+ for (JavaMappedService service : type.getServices().values()) {
+ ServiceContract serviceContract = service.getServiceContract();
+ if (serviceContract.getCallbackClass().equals(callbackClass)) {
+ callbacksService = service;
+ }
+ }
+ if (callbacksService == null) {
+ throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface");
+ }
+ callbacksService.setCallbackReferenceName(name);
+ callbacksService.setCallbackMember(field);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java
new file mode 100644
index 0000000000..a84e8f3850
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Thrown when a service interface cannot be determined based on a heuristic evaluation of an implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceTypeNotFoundException extends ProcessingException {
+ public ServiceTypeNotFoundException() {
+ }
+
+ public ServiceTypeNotFoundException(String message) {
+ super(message);
+ }
+
+ public ServiceTypeNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ServiceTypeNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java
new file mode 100644
index 0000000000..875f10a4fd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+/**
+ * Thrown when a method or field marked with {@link org.osoa.sca.annotations.Context} takes an unknown type
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnknownContextTypeException extends IllegalContextException {
+ public UnknownContextTypeException() {
+ }
+
+ public UnknownContextTypeException(String message) {
+ super(message);
+ }
+
+ public UnknownContextTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnknownContextTypeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
new file mode 100644
index 0000000000..059ae0e768
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.builder;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.builder.BindingBuilder;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import org.apache.tuscany.core.implementation.system.component.SystemReference;
+import org.apache.tuscany.core.implementation.system.component.SystemReferenceImpl;
+import org.apache.tuscany.core.implementation.system.component.SystemService;
+import org.apache.tuscany.core.implementation.system.component.SystemServiceImpl;
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWire;
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWireImpl;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundAutowire;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWireImpl;
+
+/**
+ * Creates {@link SystemService}s and {@link org.apache.tuscany.core.implementation.system.component.SystemReference}s
+ * by evaluating an assembly definition
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemBindingBuilder implements BindingBuilder<SystemBinding> {
+
+ public SystemService build(CompositeComponent parent,
+ BoundServiceDefinition<SystemBinding> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+ Class<?> interfaze = boundServiceDefinition.getServiceContract().getInterfaceClass();
+ QualifiedName targetName = new QualifiedName(boundServiceDefinition.getTarget().getPath());
+ Component target = (Component) parent.getSystemChild(targetName.getPartName());
+ if (target == null) {
+ throw new BuilderConfigException("Target not found: [" + targetName + ']');
+ }
+ String name = boundServiceDefinition.getName();
+ InboundWire inboundWire =
+ new SystemInboundWireImpl(name, interfaze, target);
+ SystemOutboundWire outboundWire =
+ new SystemOutboundWireImpl(name, targetName, interfaze);
+ SystemService service = new SystemServiceImpl(boundServiceDefinition.getName(), parent);
+ service.setInboundWire(inboundWire);
+ service.setOutboundWire(outboundWire);
+ return service;
+ }
+
+ public SystemReference build(CompositeComponent parent,
+ BoundReferenceDefinition<SystemBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ CompositeComponent autowireComponent = parent.getParent();
+ Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
+ String name = boundReferenceDefinition.getName();
+ SystemReferenceImpl reference = new SystemReferenceImpl(name, interfaze, parent);
+ SystemInboundWire inboundWire = new SystemInboundWireImpl(name, interfaze);
+ String refName = boundReferenceDefinition.getName();
+ boolean required = boundReferenceDefinition.isRequired();
+ SystemOutboundWire outboundWire = new SystemOutboundAutowire(refName, interfaze, autowireComponent, required);
+ reference.setInboundWire(inboundWire);
+ reference.setOutboundWire(outboundWire);
+ return reference;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java
new file mode 100644
index 0000000000..ceff57f9f9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.builder;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWire;
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWireImpl;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundAutowire;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWireImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Produces system atomic components from a component definition
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemComponentBuilder extends ComponentBuilderExtension<SystemImplementation> {
+
+ protected Class<SystemImplementation> getImplementationType() {
+ return SystemImplementation.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public AtomicComponent build(CompositeComponent parent,
+ ComponentDefinition<SystemImplementation> definition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+ PojoComponentType<ServiceDefinition, JavaMappedReference, JavaMappedProperty<?>> componentType =
+ definition.getImplementation().getComponentType();
+
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setParent(parent);
+ configuration.setScopeContainer(deploymentContext.getModuleScope());
+ if (definition.getInitLevel() != null) {
+ configuration.setInitLevel(definition.getInitLevel());
+ } else {
+ configuration.setInitLevel(componentType.getInitLevel());
+ }
+ Method initMethod = componentType.getInitMethod();
+ if (initMethod != null) {
+ configuration.setInitInvoker(new MethodEventInvoker<Object>(initMethod));
+ }
+ Method destroyMethod = componentType.getDestroyMethod();
+ if (destroyMethod != null) {
+ configuration.setDestroyInvoker(new MethodEventInvoker<Object>(destroyMethod));
+ }
+ for (ServiceDefinition serviceDefinition : componentType.getServices().values()) {
+ configuration.addServiceInterface(serviceDefinition.getServiceContract().getInterfaceClass());
+ }
+ // setup property injection sites
+ for (JavaMappedProperty<?> property : componentType.getProperties().values()) {
+ configuration.addPropertySite(property.getName(), property.getMember());
+ }
+ // setup reference injection sites
+ for (JavaMappedReference reference : componentType.getReferences().values()) {
+ Member member = reference.getMember();
+ if (member != null) {
+ // could be null if the reference is mapped to a constructor
+ configuration.addReferenceSite(reference.getName(), member);
+ }
+ }
+ // setup constructor injection
+ ConstructorDefinition<?> ctorDef = componentType.getConstructorDefinition();
+ Constructor<?> constr = ctorDef.getConstructor();
+ PojoObjectFactory<?> instanceFactory = new PojoObjectFactory(constr);
+ configuration.setInstanceFactory(instanceFactory);
+ configuration.getConstructorParamNames().addAll(ctorDef.getInjectionNames());
+ SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(definition.getName(), configuration);
+ // handle properties
+ Map<String, PropertyValue<?>> propertyValues = definition.getPropertyValues();
+ processProperties(propertyValues, componentType.getProperties().values(), component);
+ // handle inbound wires
+ for (ServiceDefinition serviceDefinition : componentType.getServices().values()) {
+ Class<?> interfaze = serviceDefinition.getServiceContract().getInterfaceClass();
+ String name = serviceDefinition.getName();
+ SystemInboundWire wire = new SystemInboundWireImpl(name, interfaze, component);
+ component.addInboundWire(wire);
+ }
+ // handle references
+ processReferences(definition, componentType.getReferences(), parent, component);
+ // FIXME we need a way to build configuration references from autowires in the loader to eliminate this eval
+ for (ReferenceDefinition reference : componentType.getReferences().values()) {
+ if (reference.isAutowire()) {
+ Class interfaze = reference.getServiceContract().getInterfaceClass();
+ OutboundWire wire =
+ new SystemOutboundAutowire(reference.getName(), interfaze, parent, reference.isRequired());
+ component.addOutboundWire(wire);
+ }
+ }
+ return component;
+ }
+
+ private void processReferences(ComponentDefinition<SystemImplementation> definition,
+ Map<String, JavaMappedReference> references,
+ CompositeComponent parent,
+ SystemAtomicComponentImpl component) {
+ // no proxies needed for system components
+ for (ReferenceTarget target : definition.getReferenceTargets().values()) {
+ String referenceName = target.getReferenceName();
+ JavaMappedReference referenceDefiniton = references.get(referenceName);
+ Class interfaze = referenceDefiniton.getServiceContract().getInterfaceClass();
+ OutboundWire wire;
+ if (referenceDefiniton.isAutowire()) {
+ boolean required = referenceDefiniton.isRequired();
+ wire = new SystemOutboundAutowire(referenceName, interfaze, parent, required);
+ } else {
+ //FIXME support multiplicity!
+ assert target.getTargets().size() == 1 : "Multiplicity not yet implemented";
+ QualifiedName targetName = new QualifiedName(target.getTargets().get(0).getPath());
+ wire = new SystemOutboundWireImpl(referenceName, targetName, interfaze);
+ }
+ component.addOutboundWire(wire);
+ }
+ }
+
+ private void processProperties(Map<String, PropertyValue<?>> propertyValues,
+ Collection<JavaMappedProperty<?>> properties,
+ SystemAtomicComponentImpl component) {
+ for (JavaMappedProperty<?> property : properties) {
+ PropertyValue value = propertyValues.get(property.getName());
+ ObjectFactory<?> factory;
+ if (value != null) {
+ factory = value.getValueFactory();
+ } else {
+ factory = property.getDefaultValueFactory();
+ }
+ if (factory != null) {
+ component.addPropertyFactory(property.getName(), factory);
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java
new file mode 100644
index 0000000000..77fc5bf17c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemCompositeBuilder.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+
+/**
+ * Produces system composite components by evaluating an assembly.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemCompositeBuilder extends ComponentBuilderExtension<SystemCompositeImplementation> {
+ public SystemCompositeBuilder() {
+ }
+
+ public SystemCompositeBuilder(BuilderRegistry builderRegistry, Connector connector) {
+ this.builderRegistry = builderRegistry;
+ this.connector = connector;
+ }
+
+ protected Class<SystemCompositeImplementation> getImplementationType() {
+ return SystemCompositeImplementation.class;
+ }
+
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<SystemCompositeImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+ SystemCompositeImplementation impl = componentDefinition.getImplementation();
+ CompositeComponentType<?, ?, ?> componentType = impl.getComponentType();
+
+ // create lists of all components and services in this composite
+ List<ComponentDefinition<? extends Implementation<?>>> allComponents =
+ new ArrayList<ComponentDefinition<? extends Implementation<?>>>();
+ allComponents.addAll(componentType.getComponents().values());
+
+ List<BoundServiceDefinition<? extends Binding>> allBoundServices =
+ new ArrayList<BoundServiceDefinition<? extends Binding>>();
+ for (ServiceDefinition serviceDefinition : componentType.getServices().values()) {
+ if (serviceDefinition instanceof BoundServiceDefinition) {
+ BoundServiceDefinition<? extends Binding> boundService =
+ (BoundServiceDefinition<? extends Binding>) serviceDefinition;
+ allBoundServices.add(boundService);
+ }
+ }
+
+ /*
+ // add in components and services from included composites
+ for (Include include : componentType.getIncludes().values()) {
+ CompositeComponentType<?, ?, ?> included = include.getIncluded();
+ allComponents.addAll(included.getComponents().values());
+ for (ServiceDefinition serviceDefinition : included.getServices().values()) {
+ if (serviceDefinition instanceof BoundServiceDefinition) {
+ BoundServiceDefinition<? extends Binding> boundService =
+ (BoundServiceDefinition<? extends Binding>) serviceDefinition;
+ allBoundServices.add(boundService);
+ }
+ }
+ }
+ */
+
+ // create the composite component
+ String name = componentDefinition.getName();
+ CompositeComponent component = new CompositeComponentImpl(name, parent, connector, null);
+ for (ComponentDefinition<? extends Implementation> childComponentDefinition : allComponents) {
+ component.register(builderRegistry.build(component, childComponentDefinition, deploymentContext));
+ }
+
+ for (BoundServiceDefinition<? extends Binding> serviceDefinition : allBoundServices) {
+ component.register(builderRegistry.build(component, serviceDefinition, deploymentContext));
+ }
+ return component;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java
new file mode 100644
index 0000000000..cc9926280c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import org.apache.tuscany.core.implementation.PojoAtomicComponent;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+
+/**
+ * Default implementation of a system atomic context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemAtomicComponentImpl extends PojoAtomicComponent implements SystemAtomicComponent {
+
+ public SystemAtomicComponentImpl(String name, PojoConfiguration configuration) {
+ super(name, configuration);
+ scope = Scope.MODULE;
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ return getTargetInstance();
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getTargetInstance();
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return null;
+ }
+
+ public boolean isSystem() {
+ return true;
+ }
+
+ protected ObjectFactory<?> createWireFactory(RuntimeWire wire) {
+ assert wire instanceof SystemOutboundWire : "Wire must be an instance of " + SystemOutboundWire.class.getName();
+ SystemOutboundWire systemWire = (SystemOutboundWire) wire;
+ return new SystemWireObjectFactory(systemWire);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReference.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReference.java
new file mode 100644
index 0000000000..5c15edb957
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReference.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import org.apache.tuscany.spi.component.Reference;
+
+/**
+ * A marker for SCA references configured with the
+ * {@link org.apache.tuscany.core.implementation.system.model.SystemBinding}
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface SystemReference extends Reference {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReferenceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReferenceImpl.java
new file mode 100644
index 0000000000..a9a23b028c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemReferenceImpl.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWire;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+
+/**
+ * Default implementation of a reference configured with the
+ * {@link org.apache.tuscany.core.implementation.system.model.SystemBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemReferenceImpl extends AbstractSCAObject implements SystemReference {
+
+ protected SystemInboundWire inboundWire;
+ protected SystemOutboundWire outboundWire;
+ protected Class<?> referenceInterface;
+
+
+ public SystemReferenceImpl(String name, Class<?> referenceInterface, CompositeComponent parent) {
+ super(name, parent);
+ assert referenceInterface != null : "Reference interface was null";
+ this.referenceInterface = referenceInterface;
+ }
+
+ public Scope getScope() {
+ return Scope.COMPOSITE;
+ }
+
+ public void setInboundWire(InboundWire wire) {
+ assert wire instanceof SystemInboundWire : "Wire must be a " + SystemInboundWire.class.getName();
+ this.inboundWire = (SystemInboundWire) wire;
+ }
+
+ public InboundWire getInboundWire() {
+ return inboundWire;
+ }
+
+ public OutboundWire getOutboundWire() {
+ return outboundWire;
+ }
+
+ public void setOutboundWire(OutboundWire wire) {
+ assert wire instanceof SystemOutboundWire : "Wire must be a " + SystemOutboundWire.class.getName();
+ this.outboundWire = (SystemOutboundWire) wire;
+ }
+
+ public Class<?> getInterface() {
+ return referenceInterface;
+ }
+
+ public void setInterface(Class<?> referenceInterface) {
+ this.referenceInterface = referenceInterface;
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return referenceInterface.cast(inboundWire.getTargetService());
+ }
+
+ public WireInvocationHandler getHandler() throws TargetException {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceContract<?> getBindingServiceContract() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBindingServiceContract(ServiceContract<?> serviceContract) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSystem() {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemService.java
new file mode 100644
index 0000000000..95999c5045
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import org.apache.tuscany.spi.component.Service;
+
+/**
+ * Marker for services configured with the {@link org.apache.tuscany.core.implementation.system.model.SystemBinding}
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface SystemService extends Service {
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemServiceImpl.java
new file mode 100644
index 0000000000..1a8cd490ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemServiceImpl.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWire;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+
+/**
+ * Default implementation for services configured with the
+ * {@link org.apache.tuscany.core.implementation.system.model.SystemBinding}
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemServiceImpl extends AbstractSCAObject implements SystemService {
+
+ protected SystemInboundWire inboundWire;
+ protected SystemOutboundWire outboundWire;
+
+ public SystemServiceImpl(String name, CompositeComponent parent) throws CoreRuntimeException {
+ super(name, parent);
+ }
+
+ public Scope getScope() {
+ return Scope.COMPOSITE;
+ }
+
+ public InboundWire getInboundWire() {
+ return inboundWire;
+ }
+
+ public void setInboundWire(InboundWire wire) {
+ assert wire instanceof SystemInboundWire : "wire must be a " + SystemInboundWire.class.getName();
+ this.inboundWire = (SystemInboundWire) wire;
+ }
+
+ public OutboundWire getOutboundWire() {
+ return outboundWire;
+ }
+
+ public void setOutboundWire(OutboundWire wire) {
+ assert wire instanceof SystemOutboundWire : "wire must be a " + SystemOutboundWire.class.getName();
+ this.outboundWire = (SystemOutboundWire) wire;
+ }
+
+ public Class<?> getInterface() {
+ return inboundWire.getServiceContract().getInterfaceClass();
+ }
+
+ public WireInvocationHandler getHandler() {
+ // system services do not proxy
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return inboundWire.getTargetService();
+ }
+
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceContract<?> getBindingServiceContract() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBindingServiceContract(ServiceContract<?> serviceContract) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSystem() {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java
new file mode 100644
index 0000000000..a40cc9785c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * An {@link org.apache.tuscany.spi.component.AtomicComponent} used when registering objects directly into a composite
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemSingletonAtomicComponent<S, T extends S> extends AbstractSCAObject
+ implements SystemAtomicComponent {
+
+ private T instance;
+ private List<Class<?>> serviceInterfaces;
+
+ public SystemSingletonAtomicComponent(String name, CompositeComponent parent, Class<S> interfaze, T instance) {
+ super(name, parent);
+ this.instance = instance;
+ serviceInterfaces = new ArrayList<Class<?>>(1);
+ serviceInterfaces.add(interfaze);
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return serviceInterfaces;
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public boolean isEagerInit() {
+ return false;
+ }
+
+ public int getInitLevel() {
+ return 0;
+ }
+
+ public T getTargetInstance() throws TargetException {
+ return instance;
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ return getTargetInstance();
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getTargetInstance();
+ }
+
+ public void init(Object instance) throws TargetException {
+
+ }
+
+ public void destroy(Object instance) throws TargetException {
+
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInboundWire(InboundWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<String, InboundWire> getInboundWires() {
+ return Collections.emptyMap();
+ }
+
+ public InboundWire getInboundWire(String serviceName) {
+ return null;
+ }
+
+ public void addOutboundWire(OutboundWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addOutboundWires(Class<?> multiplicityClass, List<OutboundWire> wires) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<String, List<OutboundWire>> getOutboundWires() {
+ return Collections.emptyMap();
+ }
+
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return null;
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ return null;
+ }
+
+ public boolean isSystem() {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemWireObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemWireObjectFactory.java
new file mode 100644
index 0000000000..2399bee076
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemWireObjectFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+
+/**
+ * Uses a system wire to return an object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemWireObjectFactory implements ObjectFactory {
+
+ private SystemOutboundWire wire;
+
+ public SystemWireObjectFactory(SystemOutboundWire factory) {
+ this.wire = factory;
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ return wire.getTargetService();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemBindingLoader.java
new file mode 100644
index 0000000000..4db167a852
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemBindingLoader.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * Loads a system binding specified in an XML-based assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemBindingLoader extends LoaderExtension<SystemBinding> {
+ public static final QName SYSTEM_BINDING =
+ new QName("http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2", "binding.system");
+
+ @Constructor({"registry"})
+ public SystemBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return SYSTEM_BINDING;
+ }
+
+ public SystemBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ LoaderUtil.skipToEndElement(reader);
+ return new SystemBinding();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java
new file mode 100644
index 0000000000..90165c21c0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.loader;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry;
+import org.apache.tuscany.spi.implementation.java.Introspector;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+
+/**
+ * Loads a system component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentTypeLoader extends ComponentTypeLoaderExtension<SystemImplementation> {
+ private Introspector introspector;
+
+ public SystemComponentTypeLoader() {
+ }
+
+ public SystemComponentTypeLoader(Introspector introspector) {
+ this.introspector = introspector;
+ }
+
+ public SystemComponentTypeLoader(LoaderRegistry loaderRegistry, Introspector introspector) {
+ super(loaderRegistry);
+ this.introspector = introspector;
+ }
+
+ //FIXME autowire to support multiple interfaces
+ @Autowire
+ public void setIntrospector(IntrospectionRegistry introspector) {
+ this.introspector = introspector;
+ }
+
+ public void load(CompositeComponent parent, SystemImplementation implementation,
+ DeploymentContext deploymentContext) throws LoaderException {
+ Class<?> implClass = implementation.getImplementationClass();
+ URL sidefile = implClass.getResource(JavaIntrospectionHelper.getBaseName(implClass) + ".componentType");
+ PojoComponentType componentType;
+ if (sidefile == null) {
+ componentType = loadByIntrospection(parent, implementation, deploymentContext);
+ } else {
+ componentType = loadFromSidefile(sidefile, deploymentContext);
+ }
+ implementation.setComponentType(componentType);
+ }
+
+ protected Class<SystemImplementation> getImplementationClass() {
+ return SystemImplementation.class;
+ }
+
+ protected PojoComponentType loadByIntrospection(CompositeComponent parent,
+ SystemImplementation implementation,
+ DeploymentContext deploymentContext) throws ProcessingException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Class<?> implClass = implementation.getImplementationClass();
+ introspector.introspect(parent, implClass, componentType, deploymentContext);
+ return componentType;
+ }
+
+
+ protected PojoComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException {
+ return loaderRegistry.load(null, url, PojoComponentType.class, deploymentContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java
new file mode 100644
index 0000000000..74ce87673e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.loader;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+
+import org.apache.tuscany.core.deployer.ChildDeploymentContext;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+
+/**
+ * Loads a system composite component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemCompositeComponentTypeLoader extends ComponentTypeLoaderExtension<SystemCompositeImplementation> {
+ public SystemCompositeComponentTypeLoader() {
+ }
+
+ public SystemCompositeComponentTypeLoader(LoaderRegistry loaderRegistry) {
+ super(loaderRegistry);
+ }
+
+ protected Class<SystemCompositeImplementation> getImplementationClass() {
+ return SystemCompositeImplementation.class;
+ }
+
+ public void load(CompositeComponent parent, SystemCompositeImplementation implementation,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+ URL scdlLocation = implementation.getScdlLocation();
+ if (scdlLocation == null) {
+ throw new LoaderException("SCDL location not found");
+ }
+ ClassLoader cl = implementation.getClassLoader();
+ deploymentContext = new ChildDeploymentContext(deploymentContext, cl, scdlLocation);
+ CompositeComponentType componentType = loadFromSidefile(parent, scdlLocation, deploymentContext);
+ implementation.setComponentType(componentType);
+ }
+
+
+ protected CompositeComponentType loadFromSidefile(CompositeComponent parent,
+ URL url,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+ return loaderRegistry.load(parent, url, CompositeComponentType.class, deploymentContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java
new file mode 100644
index 0000000000..7db92e07ef
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * Loads information for a system implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemImplementationLoader extends LoaderExtension<SystemImplementation> {
+ public static final QName SYSTEM_IMPLEMENTATION =
+ new QName("http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2", "implementation.system");
+
+ @Constructor({"registry"})
+ public SystemImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public SystemImplementation load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext
+ )
+ throws XMLStreamException, LoaderException {
+ assert SYSTEM_IMPLEMENTATION.equals(reader.getName());
+ SystemImplementation implementation = new SystemImplementation();
+ String implClass = reader.getAttributeValue(null, "class");
+ Class<?> implementationClass = LoaderUtil.loadClass(implClass, deploymentContext.getClassLoader());
+ implementation.setImplementationClass(implementationClass);
+ registry.loadComponentType(parent, implementation, deploymentContext);
+ LoaderUtil.skipToEndElement(reader);
+ return implementation;
+ }
+
+ public QName getXMLType() {
+ return SYSTEM_IMPLEMENTATION;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemBinding.java
new file mode 100644
index 0000000000..36a439c61b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemBinding.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.model;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * A by-reference binding used by runtime system services
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemBinding extends Binding {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java
new file mode 100644
index 0000000000..e634609c5b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.model;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Represents a system composite type
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemCompositeImplementation extends Implementation<CompositeComponentType> {
+ private URL scdlLocation;
+ private ClassLoader classLoader;
+
+ public SystemCompositeImplementation() {
+ }
+
+ public SystemCompositeImplementation(CompositeComponentType componentType) {
+ super(componentType);
+ }
+
+ public URL getScdlLocation() {
+ return scdlLocation;
+ }
+
+ public void setScdlLocation(URL scdlLocation) {
+ this.scdlLocation = scdlLocation;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java
new file mode 100644
index 0000000000..ce48ed3fe5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.model;
+
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Represents the system composite implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemImplementation extends AtomicImplementation<PojoComponentType> {
+ private Class<?> implementationClass;
+
+ public SystemImplementation(PojoComponentType componentType, Class<?> implementationClass) {
+ super(componentType);
+ this.implementationClass = implementationClass;
+ }
+
+ public SystemImplementation() {
+ }
+
+ public SystemImplementation(Class<?> implementationClass) {
+ this.implementationClass = implementationClass;
+ }
+
+ public Class<?> getImplementationClass() {
+ return implementationClass;
+ }
+
+ public void setImplementationClass(Class<?> implementationClass) {
+ this.implementationClass = implementationClass;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWire.java
new file mode 100644
index 0000000000..188a813800
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWire.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import org.apache.tuscany.spi.wire.InboundWire;
+
+/**
+ * Specified by a {@link org.apache.tuscany.core.implementation.system.model.SystemBinding}, a specialized inbound wire
+ * that returns a direct reference to the target.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface SystemInboundWire extends InboundWire {
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java
new file mode 100644
index 0000000000..7938f3ad48
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Default implementation of an inbound system wire
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemInboundWireImpl implements SystemInboundWire {
+ private String serviceName;
+ private ServiceContract serviceContract;
+ private Component component;
+ private SystemOutboundWire wire;
+ private SCAObject container;
+ private Class<?> interfaze;
+
+ /**
+ * Constructs a new inbound wire
+ *
+ * @param serviceName the name of the service the inbound wire represents
+ * @param interfaze the service interface
+ * @param target the target context the wire is connected to
+ */
+ public SystemInboundWireImpl(String serviceName, Class<?> interfaze, Component target) {
+ this.serviceName = serviceName;
+ this.component = target;
+ serviceContract = new JavaServiceContract(interfaze);
+ this.interfaze = interfaze;
+ }
+
+ public SystemInboundWireImpl(String serviceName, Class<?> interfaze) {
+ this(serviceName, interfaze, null);
+ }
+
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getTargetService() throws TargetException {
+ if (wire != null) {
+ return interfaze.cast(wire.getTargetService());
+ }
+ return interfaze.cast(component.getServiceInstance(serviceName));
+ }
+
+ public Class[] getImplementedInterfaces() {
+ return new Class[0];
+ }
+
+ public Map<Operation<?>, InboundInvocationChain> getInvocationChains() {
+ return Collections.emptyMap();
+ }
+
+ public void addInvocationChain(Operation<?> operation, InboundInvocationChain chain) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInvocationChains(Map chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<Operation<?>, OutboundInvocationChain> getSourceCallbackInvocationChains(Object targetAddr) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addSourceCallbackInvocationChains(Object targetAddr,
+ Map<Operation<?>,
+ OutboundInvocationChain> chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addSourceCallbackInvocationChain(Object targetAddr, Operation operation,
+ OutboundInvocationChain chain) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInterface(Class claz) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getCallbackReferenceName() {
+ return null;
+ }
+
+ public void setCallbackReferenceName(String callbackReferenceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isOptimizable() {
+ return true; // system wires are always optimizable
+ }
+
+ public void setTargetWire(OutboundWire wire) {
+ assert wire instanceof SystemOutboundWire : "wire must be a " + SystemOutboundWireImpl.class.getName();
+ this.wire = (SystemOutboundWire) wire;
+ }
+
+ public SCAObject getContainer() {
+ return container;
+ }
+
+ public void setContainer(SCAObject container) {
+ this.container = container;
+ }
+
+ public void addMapping(Object messageId, Object fromAddress) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object retrieveMapping(Object messageId) {
+ return null;
+ }
+
+ public void removeMapping(Object messageId) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java
new file mode 100644
index 0000000000..ff4cad9795
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import org.apache.tuscany.core.wire.OutboundAutowire;
+
+/**
+ * A specialization of <code>OutboundAutowire</code> that returns a direct reference to the target
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemOutboundAutowire implements OutboundAutowire, SystemOutboundWire {
+ private String referenceName;
+ private ServiceContract serviceContract;
+ private CompositeComponent component;
+ private final boolean required;
+ private SCAObject container;
+
+ public SystemOutboundAutowire(String referenceName, Class<?> interfaze, CompositeComponent component,
+ boolean required) {
+
+ this.referenceName = referenceName;
+ this.component = component;
+ serviceContract = new JavaServiceContract(interfaze);
+ this.required = required;
+ }
+
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public String getReferenceName() {
+ return referenceName;
+ }
+
+ public void setReferenceName(String referenceName) {
+ this.referenceName = referenceName;
+ }
+
+ public QualifiedName getTargetName() {
+ return null;
+ }
+
+ public void setTargetName(QualifiedName targetName) {
+ }
+
+ public Object getTargetService() throws TargetException {
+ Class<?> interfaze = serviceContract.getInterfaceClass();
+ Object service = component.resolveSystemInstance(interfaze);
+ if (service == null && required) {
+ TargetNotFoundException e = new TargetNotFoundException("Autowire target not found");
+ e.setIdentifier(interfaze.getName());
+ throw e;
+ }
+ return service;
+ }
+
+ public void setCallbackInterface(Class<?> interfaze) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class<?> getCallbackInterface() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addCallbackInterface(Class<?> claz) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class[] getImplementedCallbackInterfaces() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTargetWire(InboundWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<Operation<?>, OutboundInvocationChain> getInvocationChains() {
+ return Collections.emptyMap();
+ }
+
+ public void addInvocationChain(Operation operation, OutboundInvocationChain chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInterface(Class claz) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+
+ public SCAObject getContainer() {
+ return container;
+ }
+
+ public void setContainer(SCAObject container) {
+ this.container = container;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWire.java
new file mode 100644
index 0000000000..bf9ccdd5a1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWire.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Specified by a {@link org.apache.tuscany.core.implementation.system.model.SystemBinding}, a specialized outbound wire
+ * that returns a direct reference to the target.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface SystemOutboundWire extends OutboundWire {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java
new file mode 100644
index 0000000000..ae20b89b55
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+/**
+ * Default implementation of a system outbound wire
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemOutboundWireImpl implements SystemOutboundWire {
+ private String referenceName;
+ private QualifiedName targetName;
+ private ServiceContract serviceContract;
+ private SystemInboundWire targetWire;
+ private SCAObject container;
+ private Class<?> interfaze;
+
+ public SystemOutboundWireImpl(String referenceName, QualifiedName targetName, Class<?> interfaze) {
+ this.referenceName = referenceName;
+ this.targetName = targetName;
+ serviceContract = new JavaServiceContract(interfaze);
+ this.interfaze = interfaze;
+ }
+
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public String getReferenceName() {
+ return referenceName;
+ }
+
+ public void setReferenceName(String referenceName) {
+ this.referenceName = referenceName;
+ }
+
+ public QualifiedName getTargetName() {
+ return targetName;
+ }
+
+ public void setTargetName(QualifiedName targetName) {
+ this.targetName = targetName;
+ }
+
+ public Object getTargetService() throws TargetException {
+ if (targetWire == null) {
+ throw new TargetException("No target wire connected to source wire");
+ }
+ return interfaze.cast(targetWire.getTargetService());
+ }
+
+ public void setCallbackInterface(Class<?> interfaze) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class<?> getCallbackInterface() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addCallbackInterface(Class<?> claz) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class[] getImplementedCallbackInterfaces() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<Operation<?>, OutboundInvocationChain> getInvocationChains() {
+ return Collections.emptyMap();
+ }
+
+ public void addInvocationChain(Operation operation, OutboundInvocationChain chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInvocationChains(Map chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addInterface(Class claz) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTargetWire(InboundWire wire) {
+ assert wire instanceof SystemInboundWire : "wire must be a " + SystemInboundWire.class.getName();
+ this.targetWire = (SystemInboundWire) wire;
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+
+ public SCAObject getContainer() {
+ return container;
+ }
+
+ public void setContainer(SCAObject container) {
+ this.container = container;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java
new file mode 100644
index 0000000000..1a441dcf87
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Array;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>Array</code>
+ * containing object instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArrayMultiplicityObjectFactory implements ObjectFactory<Object> {
+
+ private ObjectFactory[] factories;
+
+ private Class interfaceType;
+
+ public ArrayMultiplicityObjectFactory(Class interfaceType, List<ObjectFactory<?>> factories) {
+ assert interfaceType != null : "Interface type was null";
+ assert factories != null : "Object factories were null";
+ this.interfaceType = interfaceType;
+ this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ Object array = Array.newInstance(interfaceType, factories.length);
+ for (int i = 0; i < factories.length; i++) {
+ Array.set(array, i, factories[i].getInstance());
+ }
+ return array;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java
new file mode 100644
index 0000000000..87f3a46218
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * Returns proxy instance for a wire callback
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackWireObjectFactory implements ObjectFactory {
+
+ private WireService wireService;
+ private ServiceContract<?> contract;
+ private InboundWire wire;
+
+ public CallbackWireObjectFactory(ServiceContract<?> contract, WireService wireService, InboundWire wire) {
+ this.contract = contract;
+ this.wireService = wireService;
+ this.wire = wire;
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ return wireService.createCallbackProxy(contract, wire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java
new file mode 100644
index 0000000000..a422500f3c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured context type (interface) on an instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContextInjector<S, T> extends Injector<T> {
+
+ void setContext(S context) throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java
new file mode 100644
index 0000000000..af2382b36a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+/**
+ * Performs an invocation on an instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EventInvoker<T> {
+
+ /**
+ * Performs the invocation on a given instance
+ *
+ * @throws ObjectCallbackException
+ */
+ void invokeEvent(T instance) throws ObjectCallbackException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java
new file mode 100644
index 0000000000..e9f8f42aa1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.spi.ObjectFactory} on a given field
+ *
+ * @version $Rev$ $Date$
+ */
+public class FieldInjector<T> implements Injector<T> {
+
+ private final Field field;
+
+ private final ObjectFactory<?> objectFactory;
+
+ /**
+ * Create an injector and have it use the given <code>ObjectFactory</code> to inject a value on the instance using
+ * the reflected <code>Field</code>
+ */
+ public FieldInjector(Field field, ObjectFactory<?> objectFactory) {
+ this.field = field;
+ this.field.setAccessible(true);
+ this.objectFactory = objectFactory;
+ }
+
+ /**
+ * Inject a new value on the given isntance
+ */
+ public void inject(T instance) throws ObjectCreationException {
+ try {
+ field.set(instance, objectFactory.getInstance());
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Field is not accessible [" + field + "]");
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java
new file mode 100644
index 0000000000..2b2dbc9056
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class InjectionRuntimeException extends TuscanyRuntimeException {
+
+ public InjectionRuntimeException() {
+ super();
+ }
+
+ public InjectionRuntimeException(String message) {
+ super(message);
+ }
+
+ public InjectionRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InjectionRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java
new file mode 100644
index 0000000000..c2125d8212
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured value on an instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Injector<T> {
+
+ /**
+ * Inject a value on the given instance
+ */
+ void inject(T instance) throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java
new file mode 100644
index 0000000000..d263830d69
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class InvalidAccessorException extends InjectionRuntimeException {
+ public InvalidAccessorException() {
+ }
+
+ public InvalidAccessorException(String message) {
+ super(message);
+ }
+
+ public InvalidAccessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidAccessorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java
new file mode 100644
index 0000000000..0189d8245b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * An implementation of ObjectFactory that creates instances by looking them up in a JNDI context.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JNDIObjectFactory<T> implements ObjectFactory<T> {
+ private final Context context;
+ private final String name;
+
+ public JNDIObjectFactory(Context context, String name) {
+ this.context = context;
+ this.name = name;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public T getInstance() throws ObjectCreationException {
+ try {
+ return (T) context.lookup(name);
+ } catch (NamingException e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java
new file mode 100644
index 0000000000..b261bcda53
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>List</code>
+ * containing object instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class ListMultiplicityObjectFactory implements ObjectFactory<List> {
+
+ private ObjectFactory[] factories;
+
+ public ListMultiplicityObjectFactory(List<ObjectFactory<?>> factories) {
+ assert factories != null : "Object factories were null";
+ this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+ }
+
+ public List getInstance() throws ObjectCreationException {
+ List<Object> list = new ArrayList<Object>();
+ for (ObjectFactory factory : factories) {
+ list.add(factory.getInstance());
+ }
+ return list;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java
new file mode 100644
index 0000000000..e748c228d0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Performs an wire on a method of a given instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class MethodEventInvoker<T> implements EventInvoker<T> {
+ private final Method method;
+
+ /**
+ * Intantiates an invoker for the given method
+ */
+ public MethodEventInvoker(Method method) {
+ assert method != null;
+ this.method = method;
+ }
+
+ public void invokeEvent(T instance) throws ObjectCallbackException {
+ try {
+ method.invoke(instance, (Object[]) null);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Method is not accessible [" + method + "]");
+ } catch (InvocationTargetException e) {
+ throw new ObjectCallbackException("Exception thrown by callback method [" + method + "]", e.getCause());
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java
new file mode 100644
index 0000000000..d645d7efac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.spi.ObjectFactory} using a given method
+ *
+ * @version $Rev$ $Date$
+ */
+public class MethodInjector<T> implements Injector<T> {
+ private final Method method;
+ private final ObjectFactory<?> objectFactory;
+
+ public MethodInjector(Method method, ObjectFactory<?> objectFactory) {
+ assert method != null;
+ assert objectFactory != null;
+ this.method = method;
+ this.method.setAccessible(true);
+ this.objectFactory = objectFactory;
+ }
+
+ public void inject(T instance) throws ObjectCreationException {
+ try {
+ method.invoke(instance, objectFactory.getInstance());
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Method is not accessible [" + method + "]");
+ } catch (IllegalArgumentException e) {
+ ObjectCreationException oce = new ObjectCreationException("Exception thrown by setter", e);
+ oce.setIdentifier(method.getName());
+ throw oce;
+ } catch (InvocationTargetException e) {
+ ObjectCreationException oce = new ObjectCreationException("Exception thrown by setter", e);
+ oce.setIdentifier(method.getName());
+ throw oce;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java
new file mode 100644
index 0000000000..b3109074e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class NoAccessorException extends InjectionRuntimeException {
+ public NoAccessorException() {
+ }
+
+ public NoAccessorException(String message) {
+ super(message);
+ }
+
+ public NoAccessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoAccessorException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java
new file mode 100644
index 0000000000..46f7c8253b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+/**
+ * Denotes an error when invoking on an object
+ *
+ * @version $Rev$ $Date$
+ */
+public class ObjectCallbackException extends InjectionRuntimeException {
+
+ public ObjectCallbackException() {
+ super();
+ }
+
+ public ObjectCallbackException(String message) {
+ super(message);
+ }
+
+ public ObjectCallbackException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCallbackException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java
new file mode 100644
index 0000000000..21f9196b06
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Creates new instances of a Java class
+ *
+ * @version $Rev$ $Date$
+ * @see org.apache.tuscany.core.injection.Injector
+ */
+public class PojoObjectFactory<T> implements ObjectFactory<T> {
+
+ private final Constructor<T> ctr;
+ private ObjectFactory[] initializerFactories;
+
+ /**
+ * Creates the object factory
+ *
+ * @param ctr the constructor to use when instantiating a new object
+ */
+ public PojoObjectFactory(Constructor<T> ctr) {
+ assert ctr != null;
+ this.ctr = ctr;
+ initializerFactories = new ObjectFactory[ctr.getParameterTypes().length];
+ }
+
+ /**
+ * Creates the object factory
+ *
+ * @param ctr the constructor to use when instantiating a new object
+ * @param factories an ordered list of <code>ObjectFactory</code>s to use for returning constructor parameters
+ */
+ public PojoObjectFactory(Constructor<T> ctr, List<ObjectFactory> factories) {
+ assert ctr != null;
+ int params = ctr.getParameterTypes().length;
+ assert params == factories.size();
+ this.ctr = ctr;
+ initializerFactories = new ObjectFactory[params];
+ int i = 0;
+ for (ObjectFactory factory : factories) {
+ initializerFactories[i] = factory;
+ i++;
+ }
+ }
+
+ /**
+ * Returns the ordered array of <code>ObjectFactory</code>s use in creating constructor parameters
+ */
+ public ObjectFactory[] getInitializerFactories() {
+ return initializerFactories;
+ }
+
+ /**
+ * Sets an <code>ObjectFactory</code>s to use in creating constructor parameter
+ *
+ * @param pos the constructor parameter position
+ * @param factory the object factory
+ */
+ public void setInitializerFactory(int pos, ObjectFactory factory) {
+ assert pos < initializerFactories.length;
+ initializerFactories[pos] = factory;
+ }
+
+ /**
+ * Creates a new instance of an object
+ */
+ public T getInstance() throws ObjectCreationException {
+ int size = initializerFactories.length;
+ Object[] initargs = new Object[size];
+ // create the constructor arg array
+ for (int i = 0; i < size; i++) {
+ ObjectFactory<?> objectFactory = initializerFactories[i];
+ initargs[i] = objectFactory.getInstance();
+ }
+ try {
+ ctr.setAccessible(true);
+ return ctr.newInstance(initargs);
+ } catch (InstantiationException e) {
+ throw new AssertionError("Class is not instantiable [" + ctr.getDeclaringClass().getName() + "]");
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Constructor is not accessible [" + ctr + "]");
+ } catch (InvocationTargetException e) {
+ throw new ObjectCreationException("Exception thrown by constructor [" + ctr + "]", e);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java
new file mode 100644
index 0000000000..713c1ae54f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Implementation of ObjectFactory that returns a single instance, typically an immutable type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactory<T> implements ObjectFactory<T> {
+ private final T instance;
+
+ public SingletonObjectFactory(T instance) {
+ this.instance = instance;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/WireObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/WireObjectFactory.java
new file mode 100644
index 0000000000..2355272496
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/WireObjectFactory.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * Uses a wire to return an object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireObjectFactory implements ObjectFactory {
+
+ private RuntimeWire wire;
+ private WireService wireService;
+
+ public WireObjectFactory(RuntimeWire wire, WireService wireService) {
+ this.wire = wire;
+ this.wireService = wireService;
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ return wireService.createProxy(wire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java
new file mode 100644
index 0000000000..46004d90d2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.launcher;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceReference;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+
+public class CompositeContextImpl extends SCA implements CompositeContext {
+ protected final CompositeComponent composite;
+
+ public CompositeContextImpl(final CompositeComponent composite) {
+ this.composite = composite;
+ }
+
+ public void start() {
+ setCompositeContext(this);
+ }
+
+ public void stop() {
+ setCompositeContext(null);
+ }
+
+ public ServiceReference createServiceReferenceForSession(Object arg0) {
+ return null;
+ }
+
+ public ServiceReference createServiceReferenceForSession(Object arg0, String arg1) {
+ return null;
+ }
+
+ public String getCompositeName() {
+ return null;
+ }
+
+ public String getCompositeURI() {
+ return null;
+ }
+
+ public RequestContext getRequestContext() {
+ return null;
+ }
+
+ public <T> T locateService(Class<T> serviceInterface, String serviceName) {
+ return composite.locateService(serviceInterface, serviceName);
+ }
+
+ public ServiceReference newSession(String arg0) {
+ return null;
+ }
+
+ public ServiceReference newSession(String arg0, Object arg1) {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/InvalidMainException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/InvalidMainException.java
new file mode 100644
index 0000000000..ff8978445f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/InvalidMainException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.launcher;
+
+/**
+ * Exception indicating that application's main method is missing or invalid
+ * (for example it may not be static).
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidMainException extends LaunchException {
+ public InvalidMainException(String message) {
+ super(message);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java
new file mode 100644
index 0000000000..dbd8dcad74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.launcher;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Exception indicating that there was a problem launching an application.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class LaunchException extends TuscanyException {
+ public LaunchException() {
+ }
+
+ public LaunchException(String message) {
+ super(message);
+ }
+
+ public LaunchException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public LaunchException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java
new file mode 100644
index 0000000000..1655ebbea6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.launcher;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.osoa.sca.CompositeContext;
+
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+
+import org.apache.tuscany.api.TuscanyException;
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.host.Launcher;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * Basic launcher implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LauncherImpl implements Launcher {
+ /**
+ * A conventional META-INF based location for the system SCDL.
+ *
+ * @see #bootRuntime(URL, MonitorFactory)
+ */
+ public static final String METAINF_SYSTEM_SCDL_PATH = "META-INF/tuscany/system.scdl";
+
+ /**
+ * A conventional META-INF based location for the application SCDL.
+ */
+ public static final String METAINF_APPLICATION_SCDL_PATH = "META-INF/sca/default.scdl";
+
+ private ClassLoader applicationLoader;
+
+ private RuntimeComponent runtime;
+
+ private Deployer deployer;
+
+ private CompositeComponent composite;
+
+ public void bootRuntime(URL systemScdl, ClassLoader systemClassLoader, MonitorFactory monitor)
+ throws TuscanyException {
+ if (systemScdl == null) {
+ throw new LoaderException("Null system SCDL URL");
+ }
+
+ XMLInputFactory xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", systemClassLoader);
+ Bootstrapper bootstrapper = new DefaultBootstrapper(monitor, xmlFactory);
+ Deployer bootDeployer = bootstrapper.createDeployer();
+
+ // create and start the core runtime
+ runtime = bootstrapper.createRuntime();
+ runtime.start(); // REVIEW: is this redundant w/ the composite.start() call below?
+
+ // initialize the runtime info
+ CompositeComponent parent = runtime.getSystemComponent();
+ RuntimeInfo runtimeInfo = new LauncherRuntimeInfo(getInstallDirectory(), getApplicationRootDirectory(), true);
+ parent.registerJavaObject("RuntimeInfo", RuntimeInfo.class, runtimeInfo);
+
+ // registory the monitor factory
+ parent.registerJavaObject("MonitorFactory", MonitorFactory.class, monitor);
+
+ // create a ComponentDefinition to represent the component we are going to deploy
+ SystemCompositeImplementation moduleImplementation = new SystemCompositeImplementation();
+ moduleImplementation.setScdlLocation(systemScdl);
+ moduleImplementation.setClassLoader(systemClassLoader);
+ ComponentDefinition<SystemCompositeImplementation> definition =
+ new ComponentDefinition<SystemCompositeImplementation>(
+ ComponentNames.TUSCANY_SYSTEM, moduleImplementation);
+
+ // deploy the component into the runtime under the system parent
+ composite = (CompositeComponent) bootDeployer.deploy(parent, definition);
+
+ // start the system
+ composite.start();
+
+ deployer = (Deployer) composite.getSystemChild("deployer").getServiceInstance();
+ }
+
+ /**
+ * Shuts down the active runtime being managed by this instance.
+ */
+ public void shutdownRuntime() {
+ if (composite != null) {
+ composite.stop();
+ composite = null;
+ }
+
+ if (runtime != null) {
+ runtime.stop();
+ runtime = null;
+ }
+ }
+
+ public CompositeContext bootApplication(URL applicationScdl, ClassLoader applicationLoader) {
+ // FIXME implement
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the classloader for application classes.
+ *
+ * @return the classloader for application classes
+ */
+ public ClassLoader getApplicationLoader() {
+ return applicationLoader;
+ }
+
+ /**
+ * Set the classloader to be used for application classes. You should almost always supply your own application
+ * classloader, based on the hosting environment that the runtime is embedded in.
+ *
+ * @param applicationLoader the classloader to be used for application classes
+ */
+ public void setApplicationLoader(ClassLoader applicationLoader) {
+ this.applicationLoader = applicationLoader;
+ }
+
+ /**
+ * Boots the runtime defined by the specified SCDL.
+ *
+ * @param systemScdl a resource path to the SCDL defining the system.
+ * @return a CompositeComponent for the newly booted runtime system
+ * @throws LoaderException
+ */
+ @Deprecated
+ public CompositeComponent bootRuntime(URL systemScdl, MonitorFactory monitor) throws TuscanyException {
+ ClassLoader systemClassLoader = getClass().getClassLoader();
+ bootRuntime(systemScdl, systemClassLoader, monitor);
+ return composite;
+ }
+
+ /**
+ * Boots the application defined by the specified SCDL.
+ *
+ * @param name the name of the application component
+ * @param appScdl URL to the SCDL defining the application
+ * @return a CompositeComponent for the newly booted application
+ * @throws LoaderException
+ * @see METAINF_APPLICATION_SCDL_PATH
+ */
+ @Deprecated
+ public CompositeComponent bootApplication(String name, URL appScdl) throws TuscanyException {
+ ClassLoader applicationLoader = getApplicationLoader();
+
+ if (appScdl == null) {
+ throw new LoaderException("No application scdl found");
+ }
+
+ // create a ComponentDefinition to represent the component we are going to deploy
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setScdlLocation(appScdl);
+ impl.setClassLoader(applicationLoader);
+ ComponentDefinition<CompositeImplementation> moduleDefinition =
+ new ComponentDefinition<CompositeImplementation>(name, impl);
+
+ // deploy the component into the runtime under the system parent
+ CompositeComponent parent = runtime.getRootComponent();
+ // FIXME andyp -- this seems bogus when running inside an appserver
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+
+ try {
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+ return (CompositeComponent) deployer.deploy(parent, moduleDefinition);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+ }
+
+ public File getInstallDirectory() {
+ String property = System.getProperty("tuscany.installDir");
+ if (property != null) {
+ return new File(property);
+ }
+
+ // TODO: TUSCANY-648, should this throw an exception if it not running from a jar?
+
+ URL url = getClass().getResource("LauncherImpl.class");
+ String jarLocation = url.toString();
+ if ("jar".equals(url.getProtocol())) {
+ jarLocation = jarLocation.substring(4, jarLocation.lastIndexOf("!/"));
+ }
+ if (jarLocation.startsWith("file:")) {
+ jarLocation = jarLocation.substring(5);
+ }
+
+ File jarFile = new File(jarLocation);
+ return jarFile.getParentFile().getParentFile();
+ }
+
+ public File getApplicationRootDirectory() {
+ String property = System.getProperty("tuscany.applicationRootDir");
+ if (property != null) {
+ return new File(property);
+ }
+
+ return new File(System.getProperty("user.dir"));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java
new file mode 100644
index 0000000000..6b1f7fa4fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.launcher;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LauncherRuntimeInfo implements RuntimeInfo {
+
+ /** Install directory */
+ private final File installDirectory;
+
+ /** Application root directory */
+ private final File applicationRootDirectory;
+
+ private final boolean online;
+
+ /**
+ * Initializes the installation and application root directories.
+ *
+ * @param installDirectory Installation directory.
+ * @param applicationRootDirectory Application root directory.
+ */
+ public LauncherRuntimeInfo(File installDirectory, File applicationRootDirectory, boolean online) {
+ this.installDirectory = installDirectory;
+ this.applicationRootDirectory = applicationRootDirectory;
+ this.online = online;
+ }
+
+ /**
+ * Return the directory where the running runtime was installed.
+ *
+ * @return the directory where the runtime was installed
+ */
+ public File getInstallDirectory() {
+ return installDirectory;
+ }
+
+ /**
+ * Return the root directory used to resolve application file paths.
+ *
+ * @return the directory used to resolve application file paths.
+ */
+ public File getApplicationRootDirectory() {
+ return applicationRootDirectory;
+ }
+
+ /**
+ * Gets the base URL for the runtime.
+ *
+ * @return The base URL for the runtime.
+ */
+ public URL getBaseURL() {
+ try {
+ return getInstallDirectory().toURL();
+ } catch (MalformedURLException e) {
+ // TODO Decide on how to handle the exception
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean isOnline() {
+ return online;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java
new file mode 100644
index 0000000000..5f9ed6dde1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.lang.reflect.Type;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Document;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.InvalidReferenceException;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingImplementationException;
+import org.apache.tuscany.spi.loader.MissingMustOverridePropertyException;
+import org.apache.tuscany.spi.loader.NotOverridablePropertyException;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+import org.apache.tuscany.spi.loader.UndefinedPropertyException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.OverrideOptions;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.property.SimplePropertyObjectFactory;
+
+/**
+ * Loads a component definition from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentLoader extends LoaderExtension<ComponentDefinition<?>> {
+ private static final QName COMPONENT = new QName(XML_NAMESPACE_1_0, "component");
+ private static final QName PROPERTY = new QName(XML_NAMESPACE_1_0, "property");
+ private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference");
+
+ private static final String PROPERTY_FILE_ATTR = "file";
+ private static final String PROPERTY_NAME_ATTR = "name";
+ private static final String PROPERTY_SOURCE_ATTR = "source";
+
+ private PropertyObjectFactory propertyFactory;
+
+ @Constructor({"registry", "propertyFactory"})
+ public ComponentLoader(@Autowire LoaderRegistry registry, @Autowire PropertyObjectFactory propertyFactory) {
+ super(registry);
+ this.propertyFactory = propertyFactory;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void populatePropertyValues(ComponentDefinition<Implementation<?>> componentDefinition)
+ throws MissingMustOverridePropertyException {
+ ComponentType componentType = componentDefinition.getImplementation().getComponentType();
+ if (componentType != null) {
+ Map<String, Property<?>> properties = componentType.getProperties();
+ Map<String, PropertyValue<?>> propertyValues = componentDefinition.getPropertyValues();
+
+ for (Property<?> aProperty : properties.values()) {
+ if (propertyValues.get(aProperty.getName()) == null) {
+ if (aProperty.getOverride() == OverrideOptions.MUST) {
+ throw new MissingMustOverridePropertyException(aProperty.getName());
+ } else {
+ PropertyValue propertyValue = new PropertyValue();
+ propertyValue.setName(aProperty.getName());
+ propertyValue.setValue(aProperty.getDefaultValue());
+ // propertyValue.setValueFactory(aProperty.getDefaultValueFactory());
+ propertyValue.setValueFactory(new SimplePropertyObjectFactory(aProperty,
+ propertyValue
+ .getValue()));
+ propertyValues.put(aProperty.getName(), propertyValue);
+ }
+ }
+ }
+ }
+ }
+
+ public QName getXMLType() {
+ return COMPONENT;
+ }
+
+ public ComponentDefinition<?> load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException,
+ LoaderException {
+ assert COMPONENT.equals(reader.getName());
+ String name = reader.getAttributeValue(null, "name");
+ String initLevel = reader.getAttributeValue(null, "initLevel");
+
+ try {
+ Implementation<?> impl = loadImplementation(parent, reader, deploymentContext);
+ registry.loadComponentType(parent, impl, deploymentContext);
+
+ ComponentDefinition<Implementation<?>> componentDefinition =
+ new ComponentDefinition<Implementation<?>>(name, impl);
+
+ if (initLevel != null) {
+ if (initLevel.length() == 0) {
+ componentDefinition.setInitLevel(0);
+ } else {
+ try {
+ componentDefinition.setInitLevel(Integer.valueOf(initLevel));
+ } catch (NumberFormatException e) {
+ InvalidValueException ive = new InvalidValueException(initLevel, e);
+ ive.setIdentifier("initValue");
+ ive.addContextName(name);
+ throw ive;
+ }
+ }
+ }
+
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ if (PROPERTY.equals(qname)) {
+ loadProperty(reader, deploymentContext, componentDefinition);
+ } else if (REFERENCE.equals(qname)) {
+ loadReference(reader, deploymentContext, componentDefinition);
+ }
+ reader.next();
+ break;
+ case END_ELEMENT:
+ if (reader.getName().equals(COMPONENT)) {
+ // hack to leave alone SystemImplementation
+ if (!((Implementation) componentDefinition
+ .getImplementation() instanceof SystemImplementation)) {
+ populatePropertyValues(componentDefinition);
+ }
+
+ return componentDefinition;
+ }
+ break;
+ }
+ }
+ } catch (LoaderException e) {
+ e.addContextName(name);
+ throw e;
+ }
+ }
+
+ protected Implementation<?> loadImplementation(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ reader.nextTag();
+ ModelObject o = registry.load(parent, reader, deploymentContext);
+ if (!(o instanceof Implementation)) {
+ throw new MissingImplementationException();
+ }
+ return (Implementation<?>) o;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void loadProperty(XMLStreamReader reader,
+ DeploymentContext deploymentContext,
+ ComponentDefinition<?> componentDefinition) throws XMLStreamException,
+ LoaderException {
+ String name = reader.getAttributeValue(null, PROPERTY_NAME_ATTR);
+ Implementation<?> implementation = componentDefinition.getImplementation();
+ ComponentType<?, ?, ?> componentType = implementation.getComponentType();
+ Property<Type> property = (Property<Type>)componentType.getProperties().get(name);
+ if (property == null) {
+ throw new UndefinedPropertyException(name);
+ } else if (OverrideOptions.NO.equals(property.getOverride())) {
+ throw new NotOverridablePropertyException(name);
+ }
+ PropertyValue<Type> propertyValue;
+ String source = reader.getAttributeValue(null, PROPERTY_SOURCE_ATTR);
+ String file = reader.getAttributeValue(null, PROPERTY_FILE_ATTR);
+ if (source != null || file != null) {
+ propertyValue = new PropertyValue<Type>(name, source, file);
+ LoaderUtil.skipToEndElement(reader);
+ } else {
+ try {
+ DocumentBuilder documentBuilder = DOMHelper.newDocumentBuilder();
+ Document value = StAXUtil.createPropertyValue(reader, property.getXmlType(), documentBuilder);
+ propertyValue = new PropertyValue<Type>(name, value);
+ } catch (ParserConfigurationException e) {
+ throw new LoaderException(e);
+ }
+ }
+ ObjectFactory<Type> objectFactory = propertyFactory.createObjectFactory(property, propertyValue);
+ // propertyValue.setValueFactory(new SimplePropertyObjectFactory(property, propertyValue.getValue()));
+ propertyValue.setValueFactory(objectFactory);
+ componentDefinition.add(propertyValue);
+ }
+
+ protected void loadReference(XMLStreamReader reader,
+ DeploymentContext deploymentContext,
+ ComponentDefinition<?> componentDefinition) throws XMLStreamException,
+ LoaderException {
+ String name = reader.getAttributeValue(null, "name");
+ String text = reader.getElementText();
+ String target = text != null ? text.trim() : null;
+
+ if (name == null || target == null) {
+ InvalidReferenceException le = new InvalidReferenceException();
+ le.setIdentifier(target);
+ throw le;
+ }
+
+ ReferenceTarget referenceTarget = new ReferenceTarget();
+ referenceTarget.setReferenceName(name);
+ try {
+ referenceTarget.addTarget(new URI(target));
+ } catch (URISyntaxException e) {
+ InvalidReferenceException le = new InvalidReferenceException(e);
+ le.setIdentifier(target);
+ throw le;
+ }
+ componentDefinition.add(referenceTarget);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java
new file mode 100644
index 0000000000..b7b01d1b65
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeElementLoader extends LoaderExtension<ComponentType> {
+ public static final QName COMPONENT_TYPE = new QName(XML_NAMESPACE_1_0, "componentType");
+
+ @Constructor({"registry"})
+ public ComponentTypeElementLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return COMPONENT_TYPE;
+ }
+
+ public ComponentType load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ assert COMPONENT_TYPE.equals(reader.getName());
+ ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> componentType
+ = new ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>>();
+
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ ModelObject o = registry.load(parent, reader, deploymentContext);
+ if (o instanceof ServiceDefinition) {
+ componentType.add((ServiceDefinition) o);
+ } else if (o instanceof ReferenceDefinition) {
+ componentType.add((ReferenceDefinition) o);
+ } else if (o instanceof Property) {
+ componentType.add((Property<?>) o);
+ }
+ break;
+ case END_ELEMENT:
+ return componentType;
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java
new file mode 100644
index 0000000000..f5c36c3f83
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.loader.MissingIncludeException;
+import org.apache.tuscany.spi.model.Include;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.core.deployer.ChildDeploymentContext;
+
+/**
+ * Loader that handles &lt;include&gt; elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IncludeLoader extends LoaderExtension<Include> {
+ private static final QName INCLUDE = new QName(XML_NAMESPACE_1_0, "include");
+
+ @Constructor({"registry"})
+ public IncludeLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return INCLUDE;
+ }
+
+ public Include load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ assert INCLUDE.equals(reader.getName());
+ String name = reader.getAttributeValue(null, "name");
+ String scdlLocation = reader.getAttributeValue(null, "scdlLocation");
+ String scdlResource = reader.getAttributeValue(null, "scdlResource");
+ LoaderUtil.skipToEndElement(reader);
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ URL url;
+ if (scdlLocation != null) {
+ try {
+ url = new URL(deploymentContext.getScdlLocation(), scdlLocation);
+ } catch (MalformedURLException e) {
+ MissingResourceException mre = new MissingResourceException(scdlLocation, e);
+ mre.setIdentifier(name);
+ throw mre;
+ }
+ } else if (scdlResource != null) {
+ url = cl.getResource(scdlResource);
+ if (url == null) {
+ MissingResourceException mre = new MissingResourceException(scdlResource);
+ mre.setIdentifier(name);
+ throw mre;
+ }
+ } else {
+ MissingIncludeException mie = new MissingIncludeException();
+ mie.setIdentifier(name);
+ throw mie;
+ }
+
+ DeploymentContext childContext = new ChildDeploymentContext(deploymentContext, cl, url);
+ CompositeComponentType composite = loadFromSidefile(parent, url, childContext);
+
+ Include include = new Include();
+ include.setName(name);
+ include.setScdlLocation(url);
+ include.setIncluded(composite);
+ return include;
+ }
+
+ protected CompositeComponentType loadFromSidefile(CompositeComponent parent,
+ URL url,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+ return registry.load(parent, url, CompositeComponentType.class, deploymentContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java
new file mode 100644
index 0000000000..8759377840
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+import org.apache.tuscany.core.injection.JNDIObjectFactory;
+
+/**
+ * A StAXPropertyFactory that creates property values by looking them up in the default JNDI InitialContext. <p/> This
+ * can be used to locate resources in a J2EE environment and inject them as configuration properties. For example, to
+ * access a database a component could write: <code> &at;Property DataSource myDB; </code> and configure with <code>
+ * &lt;properties&gt; &lt;v:myDb&gt;java:comp/env/jdbc/MyDatabase&lt;/v:myDB&gt; &lt;/properties&gt; </code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class JNDIPropertyFactory implements PropertyObjectFactory {
+ public <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> value)
+ throws LoaderException {
+ String text = value.getValue().getDocumentElement().getTextContent();
+ try {
+ Context context = new InitialContext();
+ return new JNDIObjectFactory<T>(context, text);
+ } catch (NamingException e) {
+ throw new LoaderException(e);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java
new file mode 100644
index 0000000000..b0a666b8ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.ComponentTypeLoader;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.StAXElementLoader;
+import org.apache.tuscany.spi.loader.UnrecognizedElementException;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * The default implementation of a loader registry
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoaderRegistryImpl implements LoaderRegistry {
+ private Monitor monitor;
+ private final Map<QName, StAXElementLoader<? extends ModelObject>> loaders =
+ new HashMap<QName, StAXElementLoader<? extends ModelObject>>();
+ private final Map<Class<? extends Implementation<?>>,
+ ComponentTypeLoader<? extends Implementation<?>>> componentTypeLoaders =
+ new HashMap<Class<? extends Implementation<?>>, ComponentTypeLoader<? extends Implementation<?>>>();
+
+
+ public LoaderRegistryImpl() {
+ }
+
+ public LoaderRegistryImpl(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ @org.apache.tuscany.api.annotation.Monitor
+ public void setMonitor(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ @Init(eager = true)
+ public void init() {
+
+ }
+
+ public <T extends ModelObject> void registerLoader(QName element, StAXElementLoader<T> loader) {
+ monitor.registeringLoader(element);
+ loaders.put(element, loader);
+ }
+
+ public <T extends ModelObject> void unregisterLoader(QName element, StAXElementLoader<T> loader) {
+ monitor.unregisteringLoader(element);
+ loaders.remove(element);
+ }
+
+ public ModelObject load(CompositeComponent parent, XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ QName name = reader.getName();
+ monitor.elementLoad(name);
+ StAXElementLoader<? extends ModelObject> loader = loaders.get(name);
+ if (loader == null) {
+ throw new UnrecognizedElementException(name);
+ }
+ return loader.load(parent, reader, deploymentContext);
+ }
+
+ public <MO extends ModelObject> MO load(CompositeComponent parent,
+ URL url,
+ Class<MO> type,
+ DeploymentContext ctx) throws LoaderException {
+ try {
+ XMLStreamReader reader;
+ InputStream is;
+ is = url.openStream();
+ try {
+ XMLInputFactory factory = ctx.getXmlFactory();
+ reader = factory.createXMLStreamReader(is);
+ try {
+ reader.nextTag();
+ QName name = reader.getName();
+ ModelObject mo = load(parent, reader, ctx);
+ if (type.isInstance(mo)) {
+ return type.cast(mo);
+ } else {
+ UnrecognizedElementException e = new UnrecognizedElementException(name);
+ e.setResourceURI(url.toString());
+ throw e;
+ }
+ } finally {
+ try {
+ reader.close();
+ } catch (XMLStreamException e) {
+ // ignore
+ }
+ }
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ } catch (IOException e) {
+ LoaderException sfe = new LoaderException(e);
+ sfe.setResourceURI(url.toString());
+ throw sfe;
+ } catch (XMLStreamException e) {
+ LoaderException sfe = new LoaderException(e);
+ sfe.setResourceURI(url.toString());
+ throw sfe;
+ }
+ }
+
+ public <I extends Implementation<?>> void registerLoader(Class<I> key, ComponentTypeLoader<I> loader) {
+ componentTypeLoaders.put(key, loader);
+ }
+
+ public <I extends Implementation<?>> void unregisterLoader(Class<I> key) {
+ componentTypeLoaders.remove(key);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <I extends Implementation<?>> void loadComponentType(CompositeComponent parent, I implementation,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+ Class<I> key = (Class<I>) implementation.getClass();
+ ComponentTypeLoader<I> loader = (ComponentTypeLoader<I>) componentTypeLoaders.get(key);
+ if (loader == null) {
+ throw new UnsupportedOperationException();
+ }
+ loader.load(parent, implementation, deploymentContext);
+ }
+
+ public static interface Monitor {
+ /**
+ * Event emitted when a StAX element loader is registered.
+ *
+ * @param xmlType the QName of the element the loader will handle
+ */
+ void registeringLoader(QName xmlType);
+
+ /**
+ * Event emitted when a StAX element loader is unregistered.
+ *
+ * @param xmlType the QName of the element the loader will handle
+ */
+ void unregisteringLoader(QName xmlType);
+
+ /**
+ * Event emitted when a request is made to load an element.
+ *
+ * @param xmlType the QName of the element that should be loaded
+ */
+ void elementLoad(QName xmlType);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
new file mode 100644
index 0000000000..7ce3c10af5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.OverrideOptions;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * Loads a property from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertyLoader extends LoaderExtension<Property> {
+ public static final String PROPERTY_NAME_ATTR = "name";
+ public static final String PROPERTY_TYPE_ATTR = "type";
+ public static final String PROPERTY_MANY_ATTR = "many";
+ public static final String PROPERTY_OVERRIDE_ATTR = "override";
+
+ public static final QName PROPERTY = new QName(XML_NAMESPACE_1_0, "property");
+ private final DocumentBuilder documentBuilder;
+
+ @Constructor({"registry"})
+ public PropertyLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ try {
+ documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ // we should be able to construct the default DocumentBuilder
+ throw new AssertionError(e);
+ }
+ }
+
+ public QName getXMLType() {
+ return PROPERTY;
+ }
+
+ public Property<?> load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext ctx)
+ throws XMLStreamException, LoaderException {
+ assert PROPERTY.equals(reader.getName());
+ String name = reader.getAttributeValue(null, PROPERTY_NAME_ATTR);
+ String typeName = reader.getAttributeValue(null, PROPERTY_TYPE_ATTR);
+ QName xmlType = null;
+ if (typeName != null) {
+ int index = typeName.indexOf(':');
+ if (index != -1) {
+ String prefix = typeName.substring(0, index);
+ String localName = typeName.substring(index + 1);
+ String ns = reader.getNamespaceURI(prefix);
+ xmlType = new QName(ns, localName, prefix);
+ }
+ }
+ boolean many = Boolean.parseBoolean(reader.getAttributeValue(null, PROPERTY_MANY_ATTR));
+ String override = reader.getAttributeValue(null, PROPERTY_OVERRIDE_ATTR);
+
+ Document value = StAXUtil.createPropertyValue(reader, xmlType, documentBuilder);
+
+ Property<?> property = new Property();
+ property.setName(name);
+ property.setXmlType(xmlType);
+ property.setMany(many);
+
+ if (override != null) {
+ property.setOverride(OverrideOptions.valueOf(override.toUpperCase()));
+ }
+ property.setDefaultValue(value);
+ return property;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java
new file mode 100644
index 0000000000..a36ebe92ff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.Multiplicity;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Loads a reference from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceLoader extends LoaderExtension<ReferenceDefinition> {
+ public static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference");
+
+ @Constructor({"registry"})
+ public ReferenceLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return REFERENCE;
+ }
+
+ public ReferenceDefinition load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext
+ )
+ throws XMLStreamException, LoaderException {
+ assert REFERENCE.equals(reader.getName());
+
+ String name = reader.getAttributeValue(null, "name");
+ Multiplicity multiplicity =
+ StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE);
+ Binding binding = null;
+ ServiceContract serviceContract = null;
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ ModelObject o = registry.load(parent, reader, deploymentContext);
+ if (o instanceof ServiceContract) {
+ serviceContract = (ServiceContract) o;
+ } else if (o instanceof Binding) {
+ binding = (Binding) o;
+ }
+ reader.next();
+ break;
+ case END_ELEMENT:
+ if (binding == null) {
+ ReferenceDefinition referenceDefinition = new ReferenceDefinition(name, serviceContract);
+ referenceDefinition.setMultiplicity(multiplicity);
+ return referenceDefinition;
+ } else {
+ BoundReferenceDefinition<Binding> referenceDefinition = new BoundReferenceDefinition<Binding>();
+ referenceDefinition.setName(name);
+ referenceDefinition.setServiceContract(serviceContract);
+ referenceDefinition.setMultiplicity(multiplicity);
+ referenceDefinition.setBinding(binding);
+ return referenceDefinition;
+ }
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java
new file mode 100644
index 0000000000..0d5f562b69
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.InvalidReferenceException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Loads a service definition from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceLoader extends LoaderExtension<ServiceDefinition> {
+ private static final QName SERVICE = new QName(XML_NAMESPACE_1_0, "service");
+ private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference");
+
+ @Constructor({"registry"})
+ public ServiceLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return SERVICE;
+ }
+
+ public ServiceDefinition load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ assert SERVICE.equals(reader.getName());
+ String name = reader.getAttributeValue(null, "name");
+ String target = null;
+ Binding binding = null;
+ ServiceContract serviceContract = null;
+ while (true) {
+ int i = reader.next();
+ switch (i) {
+ case START_ELEMENT:
+
+ // there is a reference already using this qname which doesn't seem appropriate.
+ if (REFERENCE.equals(reader.getName())) {
+ String text = reader.getElementText();
+ target = text != null ? text.trim() : null;
+ } else {
+
+ ModelObject o = registry.load(parent, reader, deploymentContext);
+ if (o instanceof ServiceContract) {
+ serviceContract = (ServiceContract) o;
+ } else if (o instanceof Binding) {
+ binding = (Binding) o;
+ }
+ }
+ break;
+ case END_ELEMENT:
+ if (SERVICE.equals(reader.getName())) {
+ if (binding != null) {
+ if (target == null) {
+ InvalidReferenceException e = new InvalidReferenceException("No target for service ");
+ e.setIdentifier(name);
+ throw e;
+ }
+ URI targetURI;
+ try {
+ targetURI = new URI(target);
+ } catch (URISyntaxException e) {
+ InvalidReferenceException ire = new InvalidReferenceException(target);
+ ire.setIdentifier(name);
+ throw ire;
+ }
+
+ // FIXME need a way to specify "remotable" on a service
+ return new BoundServiceDefinition<Binding>(name,
+ serviceContract,
+ false,
+ binding,
+ targetURI);
+ } else if (target != null) {
+ URI targetURI;
+ try {
+ targetURI = new URI(target);
+ } catch (URISyntaxException e) {
+ InvalidReferenceException ire = new InvalidReferenceException(target);
+ ire.setIdentifier(name);
+ throw ire;
+ }
+
+ return new BindlessServiceDefinition(name, serviceContract, false, targetURI);
+ } else {
+ // FIXME need a way to specify "remotable" on a service
+ return new ServiceDefinition(name, serviceContract, false);
+ }
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java
new file mode 100644
index 0000000000..50dee55c8e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.Multiplicity;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Utility classes to support StAX-based loaders
+ *
+ * @version $Rev$ $Date$
+ */
+public final class StAXUtil {
+ private static final Map<String, Multiplicity> MULTIPLICITY = new HashMap<String, Multiplicity>(4);
+
+ static {
+ MULTIPLICITY.put("0..1", Multiplicity.ZERO_ONE);
+ MULTIPLICITY.put("1..1", Multiplicity.ONE_ONE);
+ MULTIPLICITY.put("0..n", Multiplicity.ZERO_N);
+ MULTIPLICITY.put("1..n", Multiplicity.ONE_N);
+ }
+
+ private StAXUtil() {
+ }
+
+ /**
+ * Convert a "multiplicity" attribute to the equivalent enum value.
+ *
+ * @param multiplicity the attribute to convert
+ * @param def the default value
+ * @return the enum equivalent
+ */
+ public static Multiplicity multiplicity(String multiplicity, Multiplicity def) {
+ return multiplicity == null ? def : MULTIPLICITY.get(multiplicity);
+ }
+
+ /**
+ * Convert a "scope" attribute to the equivalent enum value. Returns
+ * CONVERSATIONAL if the value equals (ignoring case) "conversational",
+ * otherwise returns NONCONVERSATIONAL.
+ *
+ * @param scope the attribute to convert
+ * @return the enum equivalent
+ */
+ public static InteractionScope interactionScope(String scope) {
+ if ("conversational".equalsIgnoreCase(scope)) {
+ return InteractionScope.CONVERSATIONAL;
+ } else {
+ return InteractionScope.NONCONVERSATIONAL;
+ }
+ }
+
+ public static Document createPropertyValue(XMLStreamReader reader, QName type, DocumentBuilder builder)
+ throws XMLStreamException {
+ Document doc = builder.newDocument();
+
+ // root element has no namespace and local name "value"
+ Element root = doc.createElementNS(null, "value");
+ if (type != null) {
+ Attr xsi = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
+ xsi.setValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+ root.setAttributeNodeNS(xsi);
+
+ String prefix = type.getPrefix();
+ if (prefix == null || prefix.length() == 0) {
+ prefix = "ns";
+ }
+ Attr typeXmlns = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + prefix);
+ typeXmlns.setValue(type.getNamespaceURI());
+ root.setAttributeNodeNS(typeXmlns);
+
+ Attr xsiType = doc.createAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
+ xsiType.setValue(prefix + ":" + type.getLocalPart());
+ root.setAttributeNodeNS(xsiType);
+ }
+ doc.appendChild(root);
+
+ loadPropertyValue(reader, root);
+ return doc;
+ }
+
+ /**
+ * Load a property value specification from an StAX stream into a DOM
+ * Document. Only elements, text and attributes are processed; all comments
+ * and other whitespace are ignored.
+ *
+ * @param reader the stream to read from
+ * @param root the DOM node to load
+ */
+ public static void loadPropertyValue(XMLStreamReader reader, Node root) throws XMLStreamException {
+ Document document = root.getOwnerDocument();
+ Node current = root;
+ while (true) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ Element child = document.createElementNS(name.getNamespaceURI(), name.getLocalPart());
+
+ // add the attributes for this element
+ int count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String localPart = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+ child.setAttributeNS(ns, localPart, value);
+ }
+
+ // push the new element and make it the current one
+ current.appendChild(child);
+ current = child;
+ break;
+ case XMLStreamConstants.CDATA:
+ current.appendChild(document.createCDATASection(reader.getText()));
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ current.appendChild(document.createTextNode(reader.getText()));
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ // if we are back at the root then we are done
+ if (current == root) {
+ return;
+ }
+
+ // pop the element off the stack
+ current = current.getParentNode();
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java
new file mode 100644
index 0000000000..eda09d6f11
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+
+/**
+ * Implementation of StAXPropertyFactory that interprets the XML as
+ *
+ * @version $Rev$ $Date$
+ */
+public class StringParserPropertyFactory implements PropertyObjectFactory {
+
+ public <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> value)
+ throws LoaderException {
+ String text = value.getValue().getDocumentElement().getTextContent();
+ return new SingletonObjectFactory<T>(createInstance(text, property.getJavaType()));
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T createInstance(String text, Class<T> type) throws LoaderException {
+ // Class<T> type = property.getJavaType();
+ assert type != null : "property type is null";
+
+ // degenerate case where property type is a String
+ if (String.class.equals(type)) {
+ return type.cast(text);
+ }
+
+ // special handler to convert hexBinary to a byte[]
+ if (byte[].class.equals(type)) {
+ byte[] instance = new byte[text.length() >> 1];
+ for (int i = 0; i < instance.length; i++) {
+ instance[i] =
+ (byte) (Character.digit(text.charAt(i << 1), 16) << 4 | Character.digit(text
+ .charAt((i << 1) + 1), 16));
+ }
+ return type.cast(instance);
+ }
+
+ // does this type have a static valueOf(String) method?
+ try {
+ Method valueOf = type.getMethod("valueOf", String.class);
+ if (Modifier.isStatic(valueOf.getModifiers())) {
+ try {
+ return type.cast(valueOf.invoke(null, text));
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("getMethod returned an inaccessible method");
+ } catch (InvocationTargetException e) {
+ // FIXME we should throw something better
+ throw new LoaderException(e.getCause());
+ }
+ }
+ } catch (NoSuchMethodException e) {
+ // try something else
+ }
+
+ // does this type have a constructor that takes a String?
+ try {
+ Constructor<T> ctr = type.getConstructor(String.class);
+ return ctr.newInstance(text);
+ } catch (NoSuchMethodException e) {
+ // try something else
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("getConstructor returned an inaccessible method");
+ } catch (InstantiationException e) {
+ throw new LoaderException("Property type cannot be instantiated: " + type.getName());
+ } catch (InvocationTargetException e) {
+ // FIXME we should throw something better
+ throw new LoaderException(e.getCause());
+ }
+
+ // do we have a property editor for it?
+ PropertyEditor editor = PropertyEditorManager.findEditor(type);
+ if (editor != null) {
+ try {
+ editor.setAsText(text);
+ return (T) editor.getValue();
+ } catch (IllegalArgumentException e) {
+ // FIXME we should throw something better
+ throw new LoaderException(e);
+
+ }
+ }
+
+ // FIXME we should throw something better
+ throw new LoaderException("Do not have a way to parse a String into a " + type.getName());
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> ObjectFactory<T> createObjectFactory(String text, Property<T> property)
+ throws XMLStreamException, LoaderException {
+ Class<T> type = property.getJavaType();
+ assert type != null : "property type is null";
+
+ // degenerate case where property type is a String
+ if (String.class.equals(type)) {
+ return new SingletonObjectFactory<T>(type.cast(text));
+ }
+
+ // special handler to convert hexBinary to a byte[]
+ if (byte[].class.equals(type)) {
+ byte[] instance = new byte[text.length() >> 1];
+ for (int i = 0; i < instance.length; i++) {
+ instance[i] =
+ (byte) (Character.digit(text.charAt(i << 1), 16) << 4 | Character.digit(text
+ .charAt((i << 1) + 1), 16));
+ }
+ return new SingletonObjectFactory<T>(type.cast(instance));
+ }
+
+ // does this type have a static valueOf(String) method?
+ try {
+ Method valueOf = type.getMethod("valueOf", String.class);
+ if (Modifier.isStatic(valueOf.getModifiers())) {
+ try {
+ return new SingletonObjectFactory<T>(type.cast(valueOf.invoke(null, text)));
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("getMethod returned an inaccessible method");
+ } catch (InvocationTargetException e) {
+ // FIXME we should throw something better
+ throw new LoaderException(e.getCause());
+ }
+ }
+ } catch (NoSuchMethodException e) {
+ // try something else
+ }
+
+ // does this type have a constructor that takes a String?
+ try {
+ Constructor<T> ctr = type.getConstructor(String.class);
+ return new SingletonObjectFactory<T>(ctr.newInstance(text));
+ } catch (NoSuchMethodException e) {
+ // try something else
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("getConstructor returned an inaccessible method");
+ } catch (InstantiationException e) {
+ throw new LoaderException("Property type cannot be instantiated: " + type.getName());
+ } catch (InvocationTargetException e) {
+ // FIXME we should throw something better
+ throw new LoaderException(e.getCause());
+ }
+
+ // do we have a property editor for it?
+ PropertyEditor editor = PropertyEditorManager.findEditor(type);
+ if (editor != null) {
+ try {
+ editor.setAsText(text);
+ return new SingletonObjectFactory<T>((T) editor.getValue());
+ } catch (IllegalArgumentException e) {
+ // FIXME we should throw something better
+ throw new LoaderException(e);
+
+ }
+ }
+
+ // FIXME we should throw something better
+ throw new LoaderException("Do not have a way to parse a String into a " + type.getName());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java
new file mode 100644
index 0000000000..cf07b0f914
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.monitor;
+
+/**
+ * Exception indicating an invalid log level has been passed.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidLevelException extends IllegalArgumentException {
+ private static final long serialVersionUID = 7767234706427841915L;
+ private final String method;
+ private final String level;
+
+ /**
+ * Constructor specifying the method name and the level affected.
+ *
+ * @param method the name of the method being monitored
+ * @param level the invalid log level value
+ */
+ public InvalidLevelException(String method, String level) {
+ super();
+ this.method = method;
+ this.level = level;
+ }
+
+ /**
+ * Returns the name of the method being monitored.
+ *
+ * @return the name of the method being monitored
+ */
+ public String getMethod() {
+ return method;
+ }
+
+ /**
+ * Returns the invalid log level specified.
+ *
+ * @return the invalid log level that was specified
+ */
+ public String getLevel() {
+ return level;
+ }
+
+ public String getMessage() {
+ return "Invalid level for method " + method + " : " + level;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java
new file mode 100644
index 0000000000..bd5b4598e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.monitor;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.api.annotation.LogLevel;
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * A factory for monitors that forwards events to a {@link java.util.logging.Logger Java Logging (JSR47) Logger}.
+ *
+ * @version $Rev$ $Date$
+ * @see java.util.logging
+ */
+public class JavaLoggingMonitorFactory implements MonitorFactory {
+ private String bundleName;
+ private Level defaultLevel;
+ private Map<String, Level> levels;
+
+ private Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap<Class<?>, WeakReference<?>>();
+
+ /**
+ * Construct a MonitorFactory that will monitor the specified methods at the specified levels and generate messages
+ * using java.util.logging.
+ * <p/>
+ * The supplied Properties can be used to specify custom log levels for specific monitor methods. The key should be
+ * the method name in form returned by <code>Class.getName() + '#' + Method.getName()</code> and the value the log
+ * level to use as defined by {@link java.util.logging.Level}.
+ *
+ * @param levels definition of custom levels for specific monitored methods, may be null or empty.
+ * @param defaultLevel the default log level to use
+ * @param bundleName the name of a resource bundle that will be passed to the logger
+ * @see java.util.logging.Logger
+ */
+ public JavaLoggingMonitorFactory(Properties levels, Level defaultLevel, String bundleName) {
+ Map<String, Object> configProperties = new HashMap<String, Object>();
+ configProperties.put("levels", levels);
+ configProperties.put("defaultLevel", defaultLevel);
+ configProperties.put("bundleName", bundleName);
+ initInternal(configProperties);
+ }
+
+ /**
+ * Constructs a MonitorFactory that needs to be subsequently configured via a call to {@link #initialize}.
+ */
+ public JavaLoggingMonitorFactory() {
+ }
+
+ public void initialize(Map<String, Object> configProperties) {
+ if (configProperties == null) {
+ return;
+ }
+ initInternal(configProperties);
+ }
+
+ private void initInternal(Map<String, Object> configProperties) {
+ try {
+ this.defaultLevel = (Level) configProperties.get("defaultLevel");
+ this.bundleName = (String) configProperties.get("bundleName");
+ Properties levels = (Properties) configProperties.get("levels");
+
+ this.levels = new HashMap<String, Level>();
+ if (levels != null) {
+ for (Map.Entry<Object, Object> entry : levels.entrySet()) {
+ String method = (String) entry.getKey();
+ String level = (String) entry.getValue();
+ try {
+ this.levels.put(method, Level.parse(level));
+ } catch (IllegalArgumentException e) {
+ throw new InvalidLevelException(method, level);
+ }
+ }
+ }
+ } catch (ClassCastException cce) {
+ throw new IllegalArgumentException(cce.getLocalizedMessage());
+ }
+ }
+
+ public synchronized <T> T getMonitor(Class<T> monitorInterface) {
+ T proxy = getCachedMonitor(monitorInterface);
+ if (proxy == null) {
+ proxy = createMonitor(monitorInterface, bundleName);
+ proxies.put(monitorInterface, new WeakReference<T>(proxy));
+ }
+ return proxy;
+ }
+
+ private <T>T getCachedMonitor(Class<T> monitorInterface) {
+ WeakReference<?> ref = proxies.get(monitorInterface);
+ return (ref != null) ? monitorInterface.cast(ref.get()) : null;
+ }
+
+ private <T>T createMonitor(Class<T> monitorInterface, String bundleName) {
+ String className = monitorInterface.getName();
+ Logger logger = Logger.getLogger(className);
+ Method[] methods = monitorInterface.getMethods();
+ Map<String, Level> levels = new HashMap<String, Level>(methods.length);
+ for (Method method : methods) {
+ String key = className + '#' + method.getName();
+ Level level = this.levels.get(key);
+
+ // if not specified the in config properties, look for an annotation on the method
+ if (level == null) {
+ LogLevel annotation = method.getAnnotation(LogLevel.class);
+ if (annotation != null && annotation.value() != null) {
+ try {
+ level = Level.parse(annotation.value());
+ } catch (IllegalArgumentException e) {
+ // bad value, just use the default
+ level = defaultLevel;
+ }
+ }
+ }
+ if (level == null) {
+ level = defaultLevel;
+ }
+ levels.put(method.getName(), level);
+ }
+
+ ResourceBundle bundle = locateBundle(monitorInterface, bundleName);
+
+ InvocationHandler handler = new LoggingHandler(logger, levels, bundle);
+ return monitorInterface
+ .cast(Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, handler));
+ }
+
+ private static <T>ResourceBundle locateBundle(Class<T> monitorInterface, String bundleName) {
+ Locale locale = Locale.getDefault();
+ ClassLoader cl = monitorInterface.getClassLoader();
+ String packageName = monitorInterface.getPackage().getName();
+ while (true) {
+ try {
+ return ResourceBundle.getBundle(packageName + '.' + bundleName, locale, cl);
+ } catch (MissingResourceException e) {
+ //ok
+ }
+ int index = packageName.lastIndexOf('.');
+ if (index == -1) {
+ break;
+ }
+ packageName = packageName.substring(0, index);
+ }
+ try {
+ return ResourceBundle.getBundle(bundleName, locale, cl);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static final class LoggingHandler implements InvocationHandler {
+ private final Logger logger;
+ private final Map<String, Level> methodLevels;
+ private final ResourceBundle bundle;
+
+ public LoggingHandler(Logger logger, Map<String, Level> methodLevels, ResourceBundle bundle) {
+ this.logger = logger;
+ this.methodLevels = methodLevels;
+ this.bundle = bundle;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String sourceMethod = method.getName();
+ Level level = methodLevels.get(sourceMethod);
+ if (level != null && logger.isLoggable(level)) {
+ // construct the key for the resource bundle
+ String className = logger.getName();
+ String key = className + '#' + sourceMethod;
+
+ LogRecord logRecord = new LogRecord(level, key);
+ logRecord.setLoggerName(className);
+ logRecord.setSourceClassName(className);
+ logRecord.setSourceMethodName(sourceMethod);
+ logRecord.setParameters(args);
+ if (args != null) {
+ for (Object o : args) {
+ if (o instanceof Throwable) {
+ logRecord.setThrown((Throwable) o);
+ break;
+ }
+ }
+ }
+ logRecord.setResourceBundle(bundle);
+ logger.log(logRecord);
+ }
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java
new file mode 100644
index 0000000000..92224d469f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.monitor;
+
+import org.apache.tuscany.host.MonitorFactory;
+
+import java.util.Map;
+
+/**
+ * Helper for creating MonitorFactory instances.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public final class MonitorFactoryUtil {
+ /**
+ * Hide the constructor
+ */
+ private MonitorFactoryUtil() {
+ }
+
+ /**
+ * Creates a MonitorFactory instance of the specified type.
+ * @param name fully qualified classname of the desired MonitorFactory type
+ * @param props collection of initialization properties
+ * @return a configured MonitorFactory instance, or null if the factory could not be instantiated.
+ */
+ @SuppressWarnings("unchecked")
+ public static MonitorFactory createMonitorFactory(String name, Map<String, Object> props) {
+ Class<? extends MonitorFactory> clazz;
+ try {
+ clazz = (Class<? extends MonitorFactory>) Class.forName(name);
+ } catch (ClassNotFoundException cnfe) {
+ return null;
+ } catch (ClassCastException cce) {
+ return null;
+ }
+
+ return createMonitorFactory(clazz, props);
+ }
+
+ /**
+ * Creates a MonitorFactory instance of the specified type.
+ * @param mfc class of the desired MonitorFactory type
+ * @param props collection of initialization properties
+ * @return a configured MonitorFactory instance, or null if the factory could not be instantiated.
+ */
+ public static MonitorFactory createMonitorFactory(Class<? extends MonitorFactory> mfc, Map<String, Object> props) {
+ MonitorFactory mf;
+ try {
+ mf = mfc.newInstance();
+ mf.initialize(props);
+ } catch (InstantiationException e) {
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError(e);
+ }
+ // allow IllegalArgumentException to propogate out
+
+ return mf;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java
new file mode 100644
index 0000000000..938ca3fe98
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.monitor;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * Implementation of a {@link MonitorFactory} that produces implementations that simply return.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NullMonitorFactory implements MonitorFactory {
+ /**
+ * Singleton wire hander that does nothing.
+ */
+ private static final InvocationHandler NULL_MONITOR = new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ return null;
+ }
+ };
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public void initialize(Map<String, Object> configProperties) {
+ }
+
+ public <T> T getMonitor(Class<T> monitorInterface) {
+ /*
+ * This uses a reflection proxy to implement the monitor interface which
+ * is a simple but perhaps not very performant solution. Performance
+ * might be improved by code generating an implementation with empty methods.
+ */
+ return monitorInterface.cast(
+ Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, NULL_MONITOR));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java
new file mode 100644
index 0000000000..e80d5c7b00
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.policy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.policy.PolicyBuilderRegistry;
+import org.apache.tuscany.spi.policy.SourcePolicyBuilder;
+import org.apache.tuscany.spi.policy.TargetPolicyBuilder;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * The default policy builder
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyBuilderRegistryImpl implements PolicyBuilderRegistry {
+
+ private final List<List<SourcePolicyBuilder>> sourceBuilders;
+ private final List<List<TargetPolicyBuilder>> targetBuilders;
+
+ public PolicyBuilderRegistryImpl() {
+ sourceBuilders = new ArrayList<List<SourcePolicyBuilder>>();
+ targetBuilders = new ArrayList<List<TargetPolicyBuilder>>();
+ for (int i = 0; i <= FINAL; i++) {
+ sourceBuilders.add(new ArrayList<SourcePolicyBuilder>());
+ targetBuilders.add(new ArrayList<TargetPolicyBuilder>());
+ }
+ }
+
+ public void registerTargetBuilder(int phase, TargetPolicyBuilder builder) {
+ assert INITIAL <= phase && phase <= FINAL : "Illegal phase";
+ targetBuilders.get(phase).add(builder);
+ }
+
+ public void registerSourceBuilder(int phase, SourcePolicyBuilder builder) {
+ assert INITIAL <= phase && phase <= FINAL : "Illegal phase";
+ sourceBuilders.get(phase).add(builder);
+ }
+
+
+ public void buildSource(ReferenceDefinition referenceDefinition, OutboundWire wire) throws BuilderException {
+ for (List<SourcePolicyBuilder> builders : sourceBuilders) {
+ for (SourcePolicyBuilder builder : builders) {
+ builder.build(referenceDefinition, wire);
+ }
+ }
+ }
+
+ public void buildTarget(ServiceDefinition serviceDefinition, InboundWire wire) throws BuilderException {
+ for (List<TargetPolicyBuilder> builders : targetBuilders) {
+ for (TargetPolicyBuilder builder : builders) {
+ builder.build(serviceDefinition, wire);
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java
new file mode 100644
index 0000000000..77e3a6829f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.property;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.tuscany.core.databinding.xml.InputStream2Node;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * The property factory backed by the DataBindingframework
+ */
+public final class PropertyHelper {
+
+ private static final XPathFactory FACTORY = XPathFactory.newInstance();
+
+ private PropertyHelper() {
+ }
+
+ public static Document evaluate(NamespaceContext nsContext, Node node, String xPathExpression)
+ throws XPathExpressionException, ParserConfigurationException {
+ XPath path = FACTORY.newXPath();
+ if (nsContext != null) {
+ path.setNamespaceContext(nsContext);
+ } else {
+ path.setNamespaceContext(new DOMNamespeceContext(node));
+ }
+ XPathExpression expression = path.compile(xPathExpression);
+ Node result = (Node)expression.evaluate(node, XPathConstants.NODE);
+ if (result == null) {
+ return null;
+ }
+
+ // TODO: How to wrap the result into a Document?
+ Document document = DOMHelper.newDocument();
+ if (result instanceof Document) {
+ return document;
+ } else {
+ document.appendChild(document.importNode(result, true));
+ return document;
+ }
+ }
+
+ public static Document loadFromFile(String file, DeploymentContext deploymentContext)
+ throws LoaderException {
+ try {
+ URI uri = URI.create(file);
+ URL url = null;
+ if (!uri.isAbsolute()) {
+ url = deploymentContext.getClassLoader().getResource(file);
+ } else {
+ url = uri.toURL();
+ }
+ InputStream is = url.openStream();
+ try {
+ InputStream2Node transformer = new InputStream2Node();
+ return (Document)transformer.transform(is, null);
+ } finally {
+ is.close();
+ }
+ } catch (Exception e) {
+ throw new LoaderException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void processProperties(CompositeComponentType<?, ?, Property<?>> parent,
+ ComponentDefinition<? extends Implementation<?>> componentDefinition,
+ DeploymentContext deploymentContext) throws LoaderException {
+ Map<String, PropertyValue<?>> propertyValues = componentDefinition.getPropertyValues();
+ for (PropertyValue propValue : propertyValues.values()) {
+ Document node = propValue.getValue();
+ String source = propValue.getSource();
+ String file = propValue.getFile();
+ if (source != null) {
+ try {
+ // $<name>/...
+ int index = source.indexOf('/');
+ if (index == -1) {
+ // Tolerating $prop
+ source = source + "/";
+ index = source.length() - 1;
+ }
+ if (source.charAt(0) == '$') {
+ String name = source.substring(1, index);
+ Property<?> compositeProp = parent.getProperties().get(name);
+ if (compositeProp == null) {
+ InvalidValueException ex =
+ new InvalidValueException(
+ "The 'source' cannot be resolved to a composite property");
+ ex.addContextName(source);
+ throw ex;
+ }
+ Document document = compositeProp.getDefaultValue();
+ // Adding /value because the document root is "value"
+ String path = source.substring(index);
+ String xpath = null;
+ if ("/".equals(path)) {
+ // trailing / is not legal for xpath
+ xpath = "/value";
+ } else {
+ xpath = "/value" + path;
+ }
+
+ // FIXME: How to deal with namespaces?
+ node = evaluate(null, document, xpath);
+ propValue.setValue(node);
+ Property<?> prop =
+ (Property<?>)componentDefinition.getImplementation().getComponentType()
+ .getProperties().get(propValue.getName());
+ propValue
+ .setValueFactory(new SimplePropertyObjectFactory(prop, propValue.getValue()));
+ } else {
+ InvalidValueException ex =
+ new InvalidValueException("The 'source' has an invalid value");
+ ex.addContextName(source);
+ throw ex;
+ }
+ } catch (Exception e) {
+ throw new LoaderException(e);
+ }
+ } else if (file != null) {
+ node = loadFromFile(propValue.getFile(), deploymentContext);
+ propValue.setValue(node);
+ Property<?> prop =
+ (Property<?>)componentDefinition.getImplementation().getComponentType().getProperties()
+ .get(propValue.getName());
+ propValue.setValueFactory(new SimplePropertyObjectFactory(prop, propValue.getValue()));
+ }
+ }
+ }
+
+ private static class DOMNamespeceContext implements NamespaceContext {
+ private Node node;
+
+ /**
+ * @param node
+ */
+ public DOMNamespeceContext(Node node) {
+ super();
+ this.node = node;
+ }
+
+ public String getNamespaceURI(String prefix) {
+ return node.lookupNamespaceURI(prefix);
+ }
+
+ public String getPrefix(String namespaceURI) {
+ return node.lookupPrefix(namespaceURI);
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ return null;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java
new file mode 100644
index 0000000000..ae8fd52548
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.property;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.core.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+@Service(PropertyObjectFactory.class)
+@Scope("MODULE")
+public class PropertyObjectFactoryImpl implements PropertyObjectFactory {
+ private DataBindingRegistry registry;
+ private Mediator mediator;
+
+ public PropertyObjectFactoryImpl() {
+ }
+
+ @Constructor({"registry", "mediator"})
+ public PropertyObjectFactoryImpl(@Autowire DataBindingRegistry registry, @Autowire Mediator mediator) {
+ super();
+ this.registry = registry;
+ this.mediator = mediator;
+ }
+
+ public <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> value) {
+ if (mediator == null) {
+ return new SimplePropertyObjectFactory<T>(property, value.getValue());
+ }
+ return new ObjectFactoryImpl<T>(property, value);
+ }
+
+ public class ObjectFactoryImpl<P> implements ObjectFactory<P> {
+ private Property<P> property;
+ private PropertyValue<P> propertyValue;
+ private DataType<QName> sourceDataType;
+ private DataType<?> targetDataType;
+
+ public ObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
+ this.property = property;
+ this.propertyValue = propertyValue;
+ sourceDataType = new DataType<QName>(DOMDataBinding.NAME, Node.class, this.property.getXmlType());
+ TypeInfo typeInfo = new TypeInfo(property.getXmlType(), true, null);
+ ElementInfo elementInfo = new ElementInfo(null, typeInfo);
+ sourceDataType.setMetadata(ElementInfo.class.getName(), elementInfo);
+ Class javaType = this.property.getJavaType();
+ String dataBinding = (String)property.getExtensions().get(DataBinding.class.getName());
+ if (dataBinding != null) {
+ targetDataType = new DataType<Class>(dataBinding, javaType, javaType);
+ } else {
+ targetDataType = registry.introspectType(javaType);
+ if (targetDataType == null) {
+ targetDataType = new DataType<Class>("java.lang.Object", javaType, javaType);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public P getInstance() throws ObjectCreationException {
+ return (P)mediator.mediate(propertyValue.getValue(), sourceDataType, targetDataType, null);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java
new file mode 100644
index 0000000000..b291eb8d96
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.property;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.model.Property;
+import org.w3c.dom.Document;
+
+public class SimplePropertyObjectFactory<P> implements ObjectFactory<P> {
+ private SimpleTypeMapperExtension typeMapper;
+ private Property<P> property;
+ private Document value;
+ private P instance;
+
+ public SimplePropertyObjectFactory(Property<P> property, Document value) {
+ super();
+ this.property = property;
+ this.value = (value == null) ? property.getDefaultValue() : value;
+ this.typeMapper = new SimpleTypeMapperExtension();
+ }
+
+ @SuppressWarnings("unchecked")
+ public P getInstance() throws ObjectCreationException {
+ if (value == null) {
+ return null;
+ }
+ if (instance == null) {
+ String text = value.getDocumentElement().getTextContent();
+ TypeInfo xmlType = null;
+ if (property.getJavaType() == null) {
+ xmlType = new TypeInfo(property.getXmlType(), true, null);
+ } else {
+ xmlType = typeMapper.getXMLType(property.getJavaType());
+ }
+ if (xmlType == null) {
+ throw new IllegalArgumentException("Complex property is not supported.");
+ }
+ instance = (P)typeMapper.toJavaObject(xmlType, text, null);
+ }
+ return instance;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
new file mode 100644
index 0000000000..f054b3bcdb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.runtime;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractRuntime implements TuscanyRuntime {
+ private URL systemScdl;
+ private String applicationName;
+ private URL applicationScdl;
+ private ClassLoader hostClassLoader;
+ private ClassLoader applicationClassLoader;
+ private RuntimeInfo runtimeInfo;
+ private MonitorFactory monitorFactory;
+
+ public URL getSystemScdl() {
+ return systemScdl;
+ }
+
+ public void setSystemScdl(URL systemScdl) {
+ this.systemScdl = systemScdl;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ public URL getApplicationScdl() {
+ return applicationScdl;
+ }
+
+ public void setApplicationScdl(URL applicationScdl) {
+ this.applicationScdl = applicationScdl;
+ }
+
+ public ClassLoader getApplicationClassLoader() {
+ return applicationClassLoader;
+ }
+
+ public void setApplicationClassLoader(ClassLoader applicationClassLoader) {
+ this.applicationClassLoader = applicationClassLoader;
+ }
+
+ public ClassLoader getHostClassLoader() {
+ return hostClassLoader;
+ }
+
+ public void setHostClassLoader(ClassLoader hostClassLoader) {
+ this.hostClassLoader = hostClassLoader;
+ }
+
+ public RuntimeInfo getRuntimeInfo() {
+ return runtimeInfo;
+ }
+
+ public void setRuntimeInfo(RuntimeInfo runtimeInfo) {
+ this.runtimeInfo = runtimeInfo;
+ }
+
+ public MonitorFactory getMonitorFactory() {
+ return monitorFactory;
+ }
+
+ public void setMonitorFactory(MonitorFactory monitorFactory) {
+ this.monitorFactory = monitorFactory;
+ }
+
+ public MonitorFactory createDefaultMonitorFactory() {
+ return new NullMonitorFactory();
+ }
+
+ protected CompositeComponent deploySystemScdl(Deployer deployer,
+ CompositeComponent parent,
+ String name,
+ URL systemScdl,
+ ClassLoader systemClassLoader)
+ throws LoaderException {
+
+ SystemCompositeImplementation impl = new SystemCompositeImplementation();
+ impl.setScdlLocation(systemScdl);
+ impl.setClassLoader(systemClassLoader);
+ ComponentDefinition<SystemCompositeImplementation> definition =
+ new ComponentDefinition<SystemCompositeImplementation>(name, impl);
+
+ return (CompositeComponent) deployer.deploy(parent, definition);
+ }
+
+ protected CompositeComponent deployApplicationScdl(Deployer deployer,
+ CompositeComponent parent,
+ String name,
+ URL applicationScdl,
+ ClassLoader applicationClassLoader)
+ throws LoaderException {
+
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setScdlLocation(applicationScdl);
+ impl.setClassLoader(applicationClassLoader);
+ ComponentDefinition<CompositeImplementation> definition =
+ new ComponentDefinition<CompositeImplementation>(name, impl);
+
+ return (CompositeComponent) deployer.deploy(parent, definition);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java
new file mode 100644
index 0000000000..f50e8544a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.artifact;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+
+/**
+ * An implementation of ArtifactRepository that uses a local Maven2 repository.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LocalMavenRepository implements ArtifactRepository {
+ private File localRepo;
+
+ /**
+ * Constructor specifying the location of the local repo. Relative paths are resolved against the user's home
+ * directory.
+ *
+ * @param repoPath the path to the local repo
+ */
+ public LocalMavenRepository(@Property(name = "repository") String repoPath) {
+ String home = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("user.home");
+ }
+ });
+ this.localRepo = new File(home, repoPath);
+ }
+
+ public void resolve(Artifact artifact) {
+ if (artifact.getUrl() != null) {
+ return;
+ }
+
+ String path = getPath(artifact);
+ File artifactFile = new File(localRepo, path);
+ if (artifactFile.exists()) {
+ try {
+ artifact.setUrl(artifactFile.toURI().toURL());
+ } catch (MalformedURLException e) {
+ // toURI should have escaped the filename to allow it to be converted to a URL
+ throw new AssertionError();
+ }
+ }
+ }
+
+ /**
+ * Return the path into the repo for an artifact. The path for an artifact is ${group.replace('.',
+ * '/')}/$[name}/${version}/${name}-${version}[-${classifier}].${type}
+ *
+ * @param artifact the artifact to resolve
+ * @return the path into the repo for the artifact
+ */
+ protected String getPath(Artifact artifact) {
+ StringBuilder builder = new StringBuilder();
+ if (artifact.getGroup() != null) {
+ builder.append(artifact.getGroup().replace('.', '/')).append('/');
+ }
+ builder.append(artifact.getName()).append('/');
+ builder.append(artifact.getVersion()).append('/');
+
+ builder.append(artifact.getName()).append('-').append(artifact.getVersion());
+ if (artifact.getClassifier() != null) {
+ builder.append('-').append(artifact.getClassifier());
+ }
+ builder.append('.').append(artifact.getType());
+ return builder.toString();
+ }
+
+ public void resolve(Collection<? extends Artifact> artifacts) {
+ for (Artifact artifact : artifacts) {
+ resolve(artifact);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java
new file mode 100644
index 0000000000..2727e8a108
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.extension;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.CompositeClassLoader;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractExtensionDeployer {
+ protected Deployer deployer;
+ protected CompositeComponent parent;
+
+ @Autowire
+ public void setDeployer(Deployer deployer) {
+ this.deployer = deployer;
+ }
+
+ @Autowire
+ public void setParent(CompositeComponent parent) {
+ this.parent = parent;
+ }
+
+ protected void deployExtension(File file) {
+ // extension name is file name less any extension
+ String name = file.getName();
+ int dot = name.lastIndexOf('.');
+ if (dot > 0) {
+ name = name.substring(0, dot);
+ }
+ URL url;
+ try {
+ url = file.toURI().toURL();
+ } catch (MalformedURLException e) {
+ // toURI should have encoded the URL
+ throw new AssertionError();
+ }
+
+ deployExtension(name, url);
+ }
+
+ protected void deployExtension(String name, URL url) {
+ // FIXME for now, assume this class's ClassLoader is the Tuscany system classloader
+ // FIXME we should really use the one associated with the parent composite
+ CompositeClassLoader extensionCL = new CompositeClassLoader(getClass().getClassLoader());
+
+ // see if the URL points to a composite JAR by looking for a default SCDL file inside it
+ URL scdlLocation;
+ try {
+ scdlLocation = new URL("jar:" + url.toExternalForm() + "!/META-INF/sca/default.scdl");
+ } catch (MalformedURLException e) {
+ // the form of the jar: URL should be correct given url.toExternalForm() worked
+ throw new AssertionError();
+ }
+ try {
+ scdlLocation.openStream().close();
+ // we connected to the SCDL so let's add the JAR file to the classloader
+ extensionCL.addURL(url);
+ } catch (IOException e) {
+ // assume that the URL we were given is not a JAR file so just use the supplied resource
+ scdlLocation = url;
+ }
+
+ // create a ComponentDefinition to represent the component we are going to deploy
+ SystemCompositeImplementation implementation = new SystemCompositeImplementation();
+ implementation.setScdlLocation(scdlLocation);
+ implementation.setClassLoader(extensionCL);
+ ComponentDefinition<SystemCompositeImplementation> definition =
+ new ComponentDefinition<SystemCompositeImplementation>(name, implementation);
+
+ // FIXME: [rfeng] Should we reset the thread context class loader here?
+ // From the debugger with tomcat, the current TCCL is the RealmClassLoader
+ // ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
+ try {
+ // Thread.currentThread().setContextClassLoader(extensionCL);
+ Component component = deployer.deploy(parent, definition);
+ component.start();
+ } catch (LoaderException e) {
+ // FIXME handle the exception
+ e.printStackTrace();
+ } finally {
+ // Thread.currentThread().setContextClassLoader(contextCL);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java
new file mode 100644
index 0000000000..79b7bf4ca1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jca;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.apache.tuscany.spi.services.work.NotificationListener;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.services.work.WorkSchedulerException;
+
+/**
+ * A work scheduler implementation based on the JCA SPI work manager.
+ * <p/>
+ * <p/>
+ * This needs a JCA SPI work manager implementation available for scheduling work. Instances can be configured with a
+ * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work
+ * manager implementaion available. </p>
+ */
+public class JcaWorkScheduler implements WorkScheduler {
+
+ /**
+ * Underlying JCA work manager
+ */
+ private WorkManager jcaWorkManager;
+
+ /**
+ * Initializes the JCA work manager.
+ *
+ * @param jcaWorkManager JCA work manager.
+ */
+ public JcaWorkScheduler(WorkManager jcaWorkManager) {
+
+ if (jcaWorkManager == null) {
+ throw new IllegalArgumentException("Work manager cannot be null");
+ }
+ this.jcaWorkManager = jcaWorkManager;
+
+ }
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener is used to register interest in
+ * callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ */
+ public <T extends Runnable> void scheduleWork(T work) {
+ scheduleWork(work, null);
+ }
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener is used to register interest in
+ * callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ * @param listener Notification listener for callbacks.
+ */
+ public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
+
+ if (work == null) {
+ throw new IllegalArgumentException("Work cannot be null");
+ }
+
+ JcaWork<T> jcaWork = new JcaWork<T>(work);
+ try {
+ if (listener == null) {
+ jcaWorkManager.scheduleWork(jcaWork);
+ } else {
+ JcaWorkListener<T> jcaWorkListener = new JcaWorkListener<T>(listener);
+ // TODO Clarify the usage of timeout and execution context
+ jcaWorkManager.scheduleWork(jcaWork, -1, null, jcaWorkListener);
+ }
+ } catch (WorkRejectedException ex) {
+ if (listener != null) {
+ listener.workRejected(work);
+ } else {
+ throw new WorkSchedulerException(ex);
+ }
+ } catch (WorkException ex) {
+ throw new WorkSchedulerException(ex);
+ }
+
+ }
+
+ /*
+ * Worklistener for keeping track of work status callbacks.
+ *
+ */
+ private class JcaWorkListener<T extends Runnable> implements WorkListener {
+
+ // Notification listener
+ private NotificationListener<T> listener;
+
+ /*
+ * Initializes the notification listener.
+ */
+ public JcaWorkListener(NotificationListener<T> listener) {
+ this.listener = listener;
+ }
+
+ /*
+ * Callback when the work is accepted.
+ */
+ public void workAccepted(WorkEvent workEvent) {
+ T work = getWork(workEvent);
+ listener.workAccepted(work);
+ }
+
+ /*
+ * Callback when the work is rejected.
+ */
+ public void workRejected(WorkEvent workEvent) {
+ T work = getWork(workEvent);
+ listener.workRejected(work);
+ }
+
+ /*
+ * Callback when the work is started.
+ */
+ public void workStarted(WorkEvent workEvent) {
+ T work = getWork(workEvent);
+ listener.workStarted(work);
+ }
+
+ /*
+ * Callback when the work is completed.
+ */
+ public void workCompleted(WorkEvent workEvent) {
+ T work = getWork(workEvent);
+ Exception exception = workEvent.getException();
+ if (exception != null) {
+ listener.workFailed(work, exception);
+ } else {
+ listener.workCompleted(work);
+ }
+ }
+
+ /*
+ * Gets the underlying work from the work event.
+ */
+ @SuppressWarnings("unchecked")
+ private T getWork(WorkEvent workEvent) {
+ JcaWork<T> jcaWork = (JcaWork<T>) workEvent.getWork();
+ return jcaWork.getWork();
+ }
+
+ }
+
+ /*
+ * JCA work wrapper.
+ */
+ private class JcaWork<T extends Runnable> implements Work {
+
+ // Work that is being executed.
+ private T work;
+
+ /*
+ * Initializes the work instance.
+ */
+ public JcaWork(T work) {
+ this.work = work;
+ }
+
+ /*
+ * Releases the work.
+ */
+ public void release() {
+ }
+
+ /*
+ * Performs the work.
+ */
+ public void run() {
+ work.run();
+ }
+
+ /*
+ * Returns the completed work.
+ */
+ public T getWork() {
+ return work;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java
new file mode 100644
index 0000000000..c65ddb12c0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237;
+
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.services.work.NotificationListener;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.services.work.WorkSchedulerException;
+
+import commonj.work.Work;
+import commonj.work.WorkEvent;
+import commonj.work.WorkException;
+import commonj.work.WorkListener;
+import commonj.work.WorkManager;
+import commonj.work.WorkRejectedException;
+
+/**
+ * A work scheduler implementation based on a JSR 237 work manager.
+ * <p/>
+ * <p/>
+ * This needs a JSR 237 work manager implementation available for scheduling work. Instances can be configured with a
+ * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work
+ * manager implementaion available. For example, if the managed environment supports work manager the runtime can use
+ * the appropriate lookup mechanism to inject the work manager implementation. </p>
+ */
+@Scope("MODULE")
+public class Jsr237WorkScheduler implements WorkScheduler {
+
+ /**
+ * Underlying JSR-237 work manager
+ */
+ private WorkManager jsr237WorkManager;
+
+ /**
+ * Initializes the JSR 237 work manager.
+ *
+ * @param jsr237WorkManager JSR 237 work manager.
+ */
+ public Jsr237WorkScheduler(@Autowire WorkManager jsr237WorkManager) {
+ if (jsr237WorkManager == null) {
+ throw new IllegalArgumentException("Work manager cannot be null");
+ }
+ this.jsr237WorkManager = jsr237WorkManager;
+ }
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener is used to register interest in
+ * callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ */
+ public <T extends Runnable> void scheduleWork(T work) {
+ scheduleWork(work, null);
+ }
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener is used to register interest in
+ * callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ * @param listener Notification listener for callbacks.
+ */
+ public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
+
+ if (work == null) {
+ throw new IllegalArgumentException("Work cannot be null");
+ }
+
+ Jsr237Work<T> jsr237Work = new Jsr237Work<T>(work);
+ try {
+ if (listener == null) {
+ jsr237WorkManager.schedule(jsr237Work);
+ } else {
+ Jsr237WorkListener<T> jsr237WorkListener = new Jsr237WorkListener<T>(listener, work);
+ jsr237WorkManager.schedule(jsr237Work, jsr237WorkListener);
+ }
+ } catch (WorkRejectedException ex) {
+ if (listener != null) {
+ listener.workRejected(work);
+ } else {
+ throw new WorkSchedulerException(ex);
+ }
+ } catch (WorkException ex) {
+ throw new WorkSchedulerException(ex);
+ }
+
+ }
+
+ /*
+ * Worklistener for keeping track of work status callbacks.
+ *
+ */
+ private class Jsr237WorkListener<T extends Runnable> implements WorkListener {
+
+ // Notification listener
+ private NotificationListener<T> listener;
+
+ // Work
+ private T work;
+
+ /*
+ * Initializes the notification listener.
+ */
+ public Jsr237WorkListener(NotificationListener<T> listener, T work) {
+ this.listener = listener;
+ this.work = work;
+ }
+
+ /*
+ * Callback when the work is accepted.
+ */
+ public void workAccepted(WorkEvent workEvent) {
+ T work = getWork();
+ listener.workAccepted(work);
+ }
+
+ /*
+ * Callback when the work is rejected.
+ */
+ public void workRejected(WorkEvent workEvent) {
+ T work = getWork();
+ listener.workRejected(work);
+ }
+
+ /*
+ * Callback when the work is started.
+ */
+ public void workStarted(WorkEvent workEvent) {
+ T work = getWork();
+ listener.workStarted(work);
+ }
+
+ /*
+ * Callback when the work is completed.
+ */
+ public void workCompleted(WorkEvent workEvent) {
+ T work = getWork();
+ Exception exception = workEvent.getException();
+ if (exception != null) {
+ listener.workFailed(work, exception);
+ } else {
+ listener.workCompleted(work);
+ }
+ }
+
+ /*
+ * Gets the underlying work from the work event.
+ */
+ private T getWork() {
+ return work;
+ }
+
+ }
+
+ /*
+ * JCA work wrapper.
+ */
+ private class Jsr237Work<T extends Runnable> implements Work {
+
+ // Work that is being executed.
+ private T work;
+
+ /*
+ * Initializes the work instance.
+ */
+ public Jsr237Work(T work) {
+ this.work = work;
+ }
+
+ /*
+ * Returns the completed work.
+ */
+ public T getWork() {
+ return work;
+ }
+
+ /*
+ * Release the work.
+ */
+ public void release() {
+ }
+
+ /*
+ * Work attributes are not daemon.
+ */
+ public boolean isDaemon() {
+ return false;
+ }
+
+ /*
+ * Runs the work.
+ */
+ public void run() {
+ work.run();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java
new file mode 100644
index 0000000000..c391d0b597
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237.workmanager;
+
+import commonj.work.WorkEvent;
+import commonj.work.WorkException;
+import commonj.work.WorkItem;
+
+/**
+ * Default immutable implementation of the <code>WorkEvent</code> class.
+ */
+class DefaultWorkEvent implements WorkEvent {
+
+ // Work item for this event
+ private WorkItem workItem;
+
+ // Exception if something has gone wrong
+ private WorkException exception;
+
+ /**
+ * Instantiates the event.
+ *
+ * @param workItem Work item for this event.
+ */
+ public DefaultWorkEvent(final DefaultWorkItem workItem) {
+ this.workItem = workItem;
+ this.exception = workItem.getException();
+ }
+
+ /**
+ * Returns the work type based on whether the work was accepted, started,
+ * rejected or completed.
+ *
+ * @return Work type.
+ */
+ public int getType() {
+ return workItem.getStatus();
+ }
+
+ /**
+ * Returns the work item associated with this work type.
+ *
+ * @return Work item.
+ */
+ public WorkItem getWorkItem() {
+ return workItem;
+ }
+
+ /**
+ * Returns the exception if the work completed with an exception.
+ *
+ * @return Work exception.
+ */
+ public WorkException getException() {
+ return exception;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java
new file mode 100644
index 0000000000..0adc005bb0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237.workmanager;
+
+import commonj.work.Work;
+import commonj.work.WorkException;
+import commonj.work.WorkItem;
+
+/**
+ * An identity based immutable implementation of the <code>WorkItem</code>
+ * interface.
+ *
+ */
+class DefaultWorkItem implements WorkItem {
+
+ // Id scoped for the VM
+ private String id;
+
+ // Status
+ private int status = -1;
+
+ // Result
+ private Work result;
+
+ // Original work
+ private Work originalWork;
+
+ // Exception
+ private WorkException exception;
+
+ /**
+ * Instantiates an id for this item.
+ *
+ * @param id of this work event.
+ */
+ protected DefaultWorkItem(final String id, final Work orginalWork) {
+ this.id = id;
+ this.originalWork = orginalWork;
+ }
+
+ /**
+ * Returns the id.
+ *
+ * @return Id of this item.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the original work.
+ *
+ * @return Original work.
+ */
+ public Work getOriginalWork() {
+ return originalWork;
+ }
+
+ /**
+ * Returns the work result if the work completed.
+ *
+ * @return Work.
+ * @throws WorkException If the work completed with an exception.
+ */
+ public Work getResult() throws WorkException {
+ return result;
+ }
+
+ /**
+ * Sets the result.
+ *
+ * @param result Result.
+ */
+ protected void setResult(final Work result) {
+ this.result = result;
+ }
+
+ /**
+ * Returns the exception if work completed with an exception.
+ *
+ * @return Work exception.
+ */
+ protected WorkException getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the exception.
+ *
+ * @param exception Exception.
+ */
+ protected void setException(final WorkException exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * Returns the work type based on whether the work was accepted, started,
+ * rejected or completed.
+ *
+ * @return Work status.
+ */
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param status Status.
+ */
+ protected void setStatus(final int status) {
+ this.status = status;
+ }
+
+ /**
+ * @see Object#hashCode()
+ */
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param obj Object to be compared.
+ * @return true if this object is the same as the obj argument; false
+ * otherwise..
+ */
+ public boolean equals(final Object obj) {
+ return (obj != null) && (obj.getClass() == DefaultWorkItem.class) && ((DefaultWorkItem) obj).id.equals(id);
+ }
+
+ /**
+ * Compares this object with the specified object for order. Returns a
+ * negative integer, zero, or a positive integer as this object is less
+ * than, equal to, or greater than the specified object.
+ *
+ * @param o Object to be compared.
+ * @return A negative integer, zero, or a positive integer as this object
+ * is less than, equal to, or greater than the specified object.
+ * @throws ClassCastException needs better documentation.
+ */
+ public int compareTo(final Object o) {
+ if (o.getClass() != DefaultWorkItem.class) {
+ throw new ClassCastException(o.getClass().getName());
+ } else {
+ return ((DefaultWorkItem) o).getId().compareTo(getId());
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java
new file mode 100644
index 0000000000..1a7639b41d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237.workmanager;
+
+import java.rmi.server.UID;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Property;
+
+import commonj.work.Work;
+import commonj.work.WorkEvent;
+import commonj.work.WorkException;
+import commonj.work.WorkItem;
+import commonj.work.WorkListener;
+import commonj.work.WorkManager;
+import commonj.work.WorkRejectedException;
+
+/**
+ * A thread-pool based implementation for the JSR-237 work manager.
+ * <p/>
+ * <p/>
+ * This implementation supports only local work.
+ * <p/>
+ * TODO Elaborate the implementation. </p>
+ */
+public class ThreadPoolWorkManager implements WorkManager {
+
+ // Map of work items currently handled by the work manager
+ private Map<DefaultWorkItem, WorkListener> workItems = new ConcurrentHashMap<DefaultWorkItem, WorkListener>();
+
+ // Thread-pool
+ private ExecutorService executor;
+
+ /**
+ * Initializes the thread-pool.
+ *
+ * @param threadPoolSize Thread-pool size.
+ */
+ public ThreadPoolWorkManager(@Property(name = "poolSize") int threadPoolSize) {
+ executor = Executors.newFixedThreadPool(threadPoolSize);
+ }
+
+ /**
+ * Schedules a unit of work asynchronously.
+ *
+ * @param work Work that needs to be scheduled.
+ * @return Work Work item representing the asynchronous work
+ */
+ public WorkItem schedule(Work work) throws WorkException {
+ return schedule(work, null);
+ }
+
+ /**
+ * Schedules a unit of work asynchronously.
+ *
+ * @param work Work that needs to be scheduled.
+ * @param workListener Work listener for callbacks.
+ * @return Work Work item representing the asynchronous work
+ */
+ public WorkItem schedule(Work work, WorkListener workListener) throws WorkRejectedException {
+
+ DefaultWorkItem workItem = new DefaultWorkItem(new UID().toString(), work);
+ if (workListener != null) {
+ workItems.put(workItem, workListener);
+ }
+ workAccepted(workItem, work);
+ if (scheduleWork(work, workItem)) {
+ return workItem;
+ } else {
+ workItem.setStatus(WorkEvent.WORK_REJECTED);
+ if (workListener != null) {
+ workListener.workRejected(new DefaultWorkEvent(workItem));
+ }
+ throw new WorkRejectedException("Unable to schedule work");
+ }
+ }
+
+ /**
+ * Wait for all the specified units of work to finish.
+ *
+ * @param works Units of the work that need to finish.
+ * @param timeout Timeout for waiting for the units of work to finish.
+ */
+ public boolean waitForAll(Collection works, long timeout) {
+ throw new UnsupportedOperationException("waitForAll not supported");
+ }
+
+ /**
+ * Wait for any of the specified units of work to finish.
+ *
+ * @param works Units of the work that need to finish.
+ * @param timeout Timeout for waiting for the units of work to finish.
+ */
+ public Collection waitForAny(Collection works, long timeout) {
+ throw new UnsupportedOperationException("waitForAny not supported");
+ }
+
+ /**
+ * Method provided for subclasses to indicate a work accptance.
+ *
+ * @param workItem Work item representing the work that was accepted.
+ * @param work Work that was accepted.
+ */
+ private void workAccepted(final DefaultWorkItem workItem, final Work work) {
+ WorkListener listener = workItems.get(workItem);
+ if (listener != null) {
+ workItem.setStatus(WorkEvent.WORK_ACCEPTED);
+ WorkEvent event = new DefaultWorkEvent(workItem);
+ listener.workAccepted(event);
+ }
+ }
+
+ /*
+ * Method to indicate a work start.
+ */
+ private void workStarted(final DefaultWorkItem workItem, final Work work) {
+ WorkListener listener = workItems.get(workItem);
+ if (listener != null) {
+ workItem.setStatus(WorkEvent.WORK_STARTED);
+ WorkEvent event = new DefaultWorkEvent(workItem);
+ listener.workStarted(event);
+ }
+ }
+
+ /*
+ * Method to indicate a work completion.
+ */
+ private void workCompleted(final DefaultWorkItem workItem, final Work work) {
+ workCompleted(workItem, work, null);
+ }
+
+ /*
+ * Method to indicate a work completion.
+ */
+ private void workCompleted(final DefaultWorkItem workItem, final Work work, final WorkException exception) {
+ WorkListener listener = workItems.get(workItem);
+ if (listener != null) {
+ workItem.setStatus(WorkEvent.WORK_COMPLETED);
+ workItem.setResult(work);
+ workItem.setException(exception);
+ WorkEvent event = new DefaultWorkEvent(workItem);
+ listener.workCompleted(event);
+ workItems.remove(workItem);
+ }
+ }
+
+ /*
+ * Schedules the work using the threadpool.
+ */
+ private boolean scheduleWork(final Work work, final DefaultWorkItem workItem) {
+ try {
+ executor.execute(new DecoratingWork(workItem, work));
+ return true;
+ } catch (RejectedExecutionException ex) {
+ return false;
+ }
+ }
+
+ /*
+ * Class that decorates the original worker so that it can get callbacks when work is done.
+ */
+ private final class DecoratingWork implements Runnable {
+
+ // Work item for this work.
+ private DefaultWorkItem workItem;
+
+ // The original work.
+ private Work decoratedWork;
+
+ /*
+ * Initializes the work item and underlying work.
+ */
+ private DecoratingWork(final DefaultWorkItem workItem, final Work decoratedWork) {
+ this.workItem = workItem;
+ this.decoratedWork = decoratedWork;
+ }
+
+ /*
+ * Overrides the run method.
+ */
+ public void run() {
+ workStarted(workItem, decoratedWork);
+ try {
+ decoratedWork.run();
+ workCompleted(workItem, decoratedWork);
+ } catch (Throwable th) {
+ workCompleted(workItem, decoratedWork, new WorkException(th.getMessage(), th));
+ }
+ }
+
+ }
+
+ @Destroy
+ public void destroy() {
+ executor.shutdown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java
new file mode 100644
index 0000000000..a8c57db9d1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.util;
+
+import java.io.File;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URLClassLoader;
+
+/**
+ * Functions to create & manipulate classloaders.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public final class ClassLoaderHelper {
+ /**
+ * Hide constructor
+ */
+ private ClassLoaderHelper() {
+ }
+
+ /**
+ * Create a classloader for the supplied classpath.
+ *
+ * @param path a list of file/directory names separated by the platform path separator
+ * @param parent the parent for the new classloader
+ * @return a classloader that will load classes from the supplied path
+ */
+ public static ClassLoader createClassLoader(ClassLoader parent, String path) {
+ String[] files = path.split(File.pathSeparator);
+ return createClassLoader(parent, files);
+ }
+
+ /**
+ * Create a classloader for a classpath supplied as individual file names.
+ *
+ * @param files a list of file/directory names
+ * @param parent the parent for the new classloader
+ * @return a classloader that will load classes from the supplied path
+ */
+ public static ClassLoader createClassLoader(ClassLoader parent, String[] files) {
+ URL[] urls = new URL[files.length];
+ for (int i = 0; i < files.length; i++) {
+ try {
+ File file = new File(files[i]);
+ urls[i] = file.toURI().toURL();
+ } catch (MalformedURLException e) {
+ // just ignore this value
+ continue;
+ }
+ }
+
+ return new URLClassLoader(urls, parent);
+ }
+
+ /**
+ * Create a classloader for a classpath supplied as a list of files.
+ *
+ * @param files a list of files
+ * @param parent the parent for the new classloader
+ * @return a classloader that will load classes from the supplied path
+ */
+ public static ClassLoader createClassLoader(ClassLoader parent, File[] files) {
+ URL[] urls = new URL[files.length];
+ for (int i = 0; i < files.length; i++) {
+ try {
+ File file = files[i];
+ urls[i] = file.toURI().toURL();
+ } catch (MalformedURLException e) {
+
+ continue;
+ }
+ }
+ return new URLClassLoader(urls, parent);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java
new file mode 100644
index 0000000000..21dea46935
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java
@@ -0,0 +1,439 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Implements various reflection-related operations
+ *
+ * @version $Rev$ $Date$
+ */
+public final class JavaIntrospectionHelper {
+
+ private static final Class[] EMPTY_CLASS_ARRY = new Class[0];
+
+ /**
+ * Hide the constructor
+ */
+ private JavaIntrospectionHelper() {
+ }
+
+
+ /**
+ * Returns a collection of public, and protected fields declared by a class or one of its supertypes
+ */
+ public static Set<Field> getAllPublicAndProtectedFields(Class clazz) {
+ return getAllPublicAndProtectedFields(clazz, new HashSet<Field>());
+ }
+
+ /**
+ * Recursively evaluates the type hierachy to return all fields that are public or protected
+ */
+ private static Set<Field> getAllPublicAndProtectedFields(Class clazz, Set<Field> fields) {
+ if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+ return fields;
+ }
+ fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields);
+ Field[] declaredFields = clazz.getDeclaredFields();
+ for (Field field : declaredFields) {
+ int modifiers = field.getModifiers();
+ if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) && !Modifier.isStatic(modifiers)) {
+ field.setAccessible(true); // ignore Java accessibility
+ fields.add(field);
+ }
+ }
+ return fields;
+ }
+
+ /**
+ * Returns a collection of public and protected methods declared by a class or one of its supertypes. Note that
+ * overriden methods will not be returned in the collection (i.e. only the method override will be). <p/> This
+ * method can potentially be expensive as reflection information is not cached. It is assumed that this method will
+ * be used during a configuration phase.
+ */
+ public static Set<Method> getAllUniquePublicProtectedMethods(Class clazz) {
+ return getAllUniqueMethods(clazz, new HashSet<Method>());
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all unique methods
+ */
+ private static Set<Method> getAllUniqueMethods(Class pClass, Set<Method> methods) {
+ if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
+ return methods;
+ }
+ // we first evaluate methods of the subclass and then move to the parent
+ Method[] declaredMethods = pClass.getDeclaredMethods();
+ for (Method declaredMethod : declaredMethods) {
+ int modifiers = declaredMethod.getModifiers();
+ if ((!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) || Modifier.isStatic(modifiers)) {
+ continue;
+ }
+ if (methods.size() == 0) {
+ methods.add(declaredMethod);
+ } else {
+ List<Method> temp = new ArrayList<Method>();
+ boolean matched = false;
+ for (Method method : methods) {
+ // only add if not already in the set from a supclass (i.e. the
+ // method is not overrided)
+ if (exactMethodMatch(declaredMethod, method)) {
+ matched = true;
+ break;
+ }
+ }
+ if (!matched) {
+ // TODO ignore Java accessibility
+ declaredMethod.setAccessible(true);
+ temp.add(declaredMethod);
+ }
+ methods.addAll(temp);
+ temp.clear();
+ }
+ }
+ // evaluate class hierarchy - this is done last to track inherited methods
+ methods = getAllUniqueMethods(pClass.getSuperclass(), methods);
+ return methods;
+ }
+
+ /**
+ * Finds the closest matching field with the given name, that is, a field of the exact specified type or,
+ * alternately, of a supertype.
+ *
+ * @param name the name of the field
+ * @param type the field type
+ * @param fields the collection of fields to search
+ * @return the matching field or null if not found
+ */
+ public static Field findClosestMatchingField(String name, Class type, Set<Field> fields) {
+ Field candidate = null;
+ for (Field field : fields) {
+ if (field.getName().equals(name)) {
+ if (field.getType().equals(type)) {
+ return field; // exact match
+ } else if (field.getType().isAssignableFrom(type)
+ || (field.getType().isPrimitive() && primitiveAssignable(field.getType(), type))) {
+ // We could have the situation where a field parameter is a primitive and the demarshalled value is
+ // an object counterpart (e.g. Integer and int)
+ // @spec issue
+ // either an interface or super class, so keep a reference until
+ // we know there are no closer types
+ candidate = field;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Finds the closest matching method with the given name, that is, a method taking the exact parameter types or,
+ * alternately, parameter supertypes.
+ *
+ * @param name the name of the method
+ * @param types the method parameter types
+ * @param methods the collection of methods to search
+ * @return the matching method or null if not found
+ */
+ public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods) {
+ if (types == null) {
+ types = EMPTY_CLASS_ARRY;
+ }
+ Method candidate = null;
+ for (Method method : methods) {
+ if (method.getName().equals(name) && method.getParameterTypes().length == types.length) {
+ Class<?>[] params = method.getParameterTypes();
+ boolean disqualify = false;
+ boolean exactMatch = true;
+ for (int i = 0; i < params.length; i++) {
+ if (!params[i].equals(types[i]) && !params[i].isAssignableFrom(types[i])) {
+ // no match
+ disqualify = true;
+ exactMatch = false;
+ break;
+ } else if (!params[i].equals(types[i]) && params[i].isAssignableFrom(types[i])) {
+ // not exact match
+ exactMatch = false;
+ }
+ }
+ if (disqualify) {
+ continue;
+ } else if (exactMatch) {
+ return method;
+ } else {
+ candidate = method;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Searches a collection of fields for one that matches by name and has a multiplicity type. i.e. a List or Array of
+ * interfaces
+ *
+ * @return a matching field or null
+ */
+ public static Field findMultiplicityFieldByName(String name, Set<Field> fields) {
+ for (Field candidate : fields) {
+ if (candidate.getName().equals(name)
+ && (List.class.isAssignableFrom(candidate.getType()) || (candidate.getType().isArray()
+ && candidate.getType().getComponentType() != null && candidate.getType().getComponentType()
+ .isInterface()))) {
+ return candidate;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches a collection of method for one that matches by name and has single parameter of a multiplicity type.
+ * i.e. a List or Array of interfaces
+ *
+ * @return a matching method or null
+ */
+ public static Method findMultiplicityMethodByName(String name, Set<Method> methods) {
+ for (Method candidate : methods) {
+ if (candidate.getName().equals(name)
+ && candidate.getParameterTypes().length == 1
+ && (List.class.isAssignableFrom(candidate.getParameterTypes()[0])
+ || (candidate.getParameterTypes()[0].isArray()
+ && candidate.getParameterTypes()[0].getComponentType() != null
+ && candidate.getParameterTypes()[0].getComponentType().isInterface()))) {
+ return candidate;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines if two methods "match" - that is, they have the same method names and exact parameter types (one is
+ * not a supertype of the other)
+ */
+ public static boolean exactMethodMatch(Method method1, Method method2) {
+ if (!method1.getName().equals(method2.getName())) {
+ return false;
+ }
+ Class[] types1 = method1.getParameterTypes();
+ Class[] types2 = method2.getParameterTypes();
+ if (types1.length == 0 && types2.length == 0) {
+ return true;
+ } else if (types1.length == types2.length) {
+ for (int n = 0; n < types1.length; n++) {
+ if (!types1[n].equals(types2[n])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
+ return clazz.getConstructor((Class[])null);
+ }
+
+ /**
+ * Loads a class corresponding to the class name using the current context class loader.
+ *
+ * @throws ClassNotFoundException if the class was not found on the classpath
+ */
+ public static Class loadClass(String pName) throws ClassNotFoundException {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return Class.forName(pName, true, loader);
+ }
+
+ /**
+ * Returns the simple name of a class - i.e. the class name devoid of its package qualifier
+ *
+ * @param implClass
+ */
+ public static String getBaseName(Class<?> implClass) {
+ String baseName = implClass.getName();
+ int lastDot = baseName.lastIndexOf('.');
+ if (lastDot != -1) {
+ baseName = baseName.substring(lastDot + 1);
+ }
+ return baseName;
+ }
+
+ public static boolean isImmutable(Class clazz) {
+ return String.class == clazz
+ || clazz.isPrimitive()
+ || Number.class.isAssignableFrom(clazz)
+ || Boolean.class.isAssignableFrom(clazz)
+ || Character.class.isAssignableFrom(clazz)
+ || Byte.class.isAssignableFrom(clazz);
+ }
+
+ /**
+ * Takes a property name and converts it to a getter method name according to JavaBean conventions. For example,
+ * property <code>foo<code> is returned as <code>getFoo</code>
+ */
+ public static String toGetter(String name) {
+ return "get" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Takes a setter or getter method name and converts it to a property name according to JavaBean conventions. For
+ * example, <code>setFoo(var)</code> is returned as property <code>foo<code>
+ */
+ public static String toPropertyName(String name) {
+ if (!name.startsWith("set")) {
+ return name;
+ }
+ return Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ }
+
+ /**
+ * Takes a property name and converts it to a setter method name according to JavaBean conventions. For example, the
+ * property <code>foo<code> is returned as <code>setFoo(var)</code>
+ */
+ public static String toSetter(String name) {
+ return "set" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Compares a two types, assuming one is a primitive, to determine if the other is its object counterpart
+ */
+ private static boolean primitiveAssignable(Class memberType, Class param) {
+ if (memberType == Integer.class) {
+ return param == Integer.TYPE;
+ } else if (memberType == Double.class) {
+ return param == Double.TYPE;
+ } else if (memberType == Float.class) {
+ return param == Float.TYPE;
+ } else if (memberType == Short.class) {
+ return param == Short.TYPE;
+ } else if (memberType == Character.class) {
+ return param == Character.TYPE;
+ } else if (memberType == Boolean.class) {
+ return param == Boolean.TYPE;
+ } else if (memberType == Byte.class) {
+ return param == Byte.TYPE;
+ } else if (param == Integer.class) {
+ return memberType == Integer.TYPE;
+ } else if (param == Double.class) {
+ return memberType == Double.TYPE;
+ } else if (param == Float.class) {
+ return memberType == Float.TYPE;
+ } else if (param == Short.class) {
+ return memberType == Short.TYPE;
+ } else if (param == Character.class) {
+ return memberType == Character.TYPE;
+ } else if (param == Boolean.class) {
+ return memberType == Boolean.TYPE;
+ } else if (param == Byte.class) {
+ return memberType == Byte.TYPE;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the generic types represented in the given type. Usage as follows: <code>
+ * JavaIntrospectionHelper.getGenerics(field.getGenericType());
+ * <p/>
+ * JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];); </code>
+ *
+ * @return the generic types in order of declaration or an empty array if the type is not genericized
+ */
+ public static List<? extends Type> getGenerics(Type genericType) {
+ List<Type> classes = new ArrayList<Type>();
+ if (genericType instanceof ParameterizedType) {
+ ParameterizedType ptype = (ParameterizedType) genericType;
+ // get the type arguments
+ Type[] targs = ptype.getActualTypeArguments();
+ for (Type targ : targs) {
+ classes.add(targ);
+ }
+ }
+ return classes;
+ }
+
+ /**
+ * Returns the generic type specified by the class at the given position as in:
+ * <p/>
+ * <code> public class Foo<Bar,Baz>{ //.. }
+ * <p/>
+ * JavaIntrospectionHelper.introspectGeneric(Foo.class,1); <code>
+ * <p/>
+ * will return Baz.
+ */
+ public static Class introspectGeneric(Class<?> clazz, int pos) {
+ assert clazz != null : "No class specified";
+ Type type = clazz.getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ Type[] args = ((ParameterizedType) type).getActualTypeArguments();
+ if (args.length <= pos) {
+ throw new IllegalArgumentException("Invalid index value for generic class " + clazz.getName());
+ }
+ return (Class) ((ParameterizedType) type).getActualTypeArguments()[pos];
+ } else {
+ Type[] interfaces = clazz.getGenericInterfaces();
+ for (Type itype : interfaces) {
+ if (!(itype instanceof ParameterizedType)) {
+ continue;
+ }
+ ParameterizedType interfaceType = (ParameterizedType) itype;
+ return (Class) interfaceType.getActualTypeArguments()[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the set of interfaces implemented by the given class and its ancestors or a blank set if none
+ */
+ public static Set<Class> getAllInterfaces(Class clazz) {
+ Set<Class> implemented = new HashSet<Class>();
+ getAllInterfaces(clazz, implemented);
+ return implemented;
+ }
+
+ private static void getAllInterfaces(Class clazz, Set<Class> implemented) {
+ Class[] interfaces = clazz.getInterfaces();
+ for (Class interfaze : interfaces) {
+ implemented.add(interfaze);
+ }
+ Class<?> superClass = clazz.getSuperclass();
+ // Object has no superclass so check for null
+ if (superClass != null && !superClass.equals(Object.class)) {
+ getAllInterfaces(superClass, implemented);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java
new file mode 100644
index 0000000000..c1766fbb6f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+
+/**
+ * Responsible for bridging an outbound to an inbound invocation chain associated with a source and target respectively
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BridgingInterceptor extends Interceptor {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java
new file mode 100644
index 0000000000..45b580d419
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+
+/**
+ * Contains a target-side invocation chain
+ *
+ * @version $Rev$ $Date$
+ */
+public class InboundInvocationChainImpl extends InvocationChainImpl implements InboundInvocationChain {
+
+ /**
+ * Creates an new target-side chain for the given operation
+ */
+ public InboundInvocationChainImpl(Operation operation) {
+ super(operation);
+ }
+
+ public void prepare() {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java
new file mode 100644
index 0000000000..d940427e5a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Default implementation of an inbound wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class InboundWireImpl implements InboundWire {
+
+ private String serviceName;
+ private ServiceContract serviceContract;
+ private OutboundWire targetWire;
+ private String callbackReferenceName;
+ private Map<Operation<?>, InboundInvocationChain> chains = new HashMap<Operation<?>, InboundInvocationChain>();
+ private Map<Object, Map<Operation<?>, OutboundInvocationChain>> callbackSourceChainMaps =
+ new HashMap<Object, Map<Operation<?>, OutboundInvocationChain>>();
+ private SCAObject container;
+ private Map<Object, Object> msgIdsToAddrs = new ConcurrentHashMap<Object, Object>();
+
+ public Object getTargetService() throws TargetException {
+ if (targetWire != null) {
+ // optimized, no interceptors or handlers on either end
+ return targetWire.getTargetService();
+ }
+ throw new TargetException("Target wire not optimized");
+ }
+
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public void addInterface(Class claz) {
+ throw new UnsupportedOperationException("Additional proxy interfaces not yet supported");
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public Map<Operation<?>, InboundInvocationChain> getInvocationChains() {
+ return chains;
+ }
+
+ public void addInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
+ this.chains.putAll(chains);
+ }
+
+ public void addInvocationChain(Operation<?> operation, InboundInvocationChain chain) {
+ chains.put(operation, chain);
+ }
+
+ public Map<Operation<?>, OutboundInvocationChain> getSourceCallbackInvocationChains(Object targetAddr) {
+ return callbackSourceChainMaps.get(targetAddr);
+ }
+
+ public void addSourceCallbackInvocationChains(Object targetAddr,
+ Map<Operation<?>, OutboundInvocationChain> chains) {
+ callbackSourceChainMaps.put(targetAddr, chains);
+ }
+
+ public void addSourceCallbackInvocationChain(Object targetAddr, Operation operation,
+ OutboundInvocationChain chain) {
+ Map<Operation<?>, OutboundInvocationChain> chains = callbackSourceChainMaps.get(targetAddr);
+ if (chains == null) {
+ chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ callbackSourceChainMaps.put(targetAddr, chains);
+ }
+ chains.put(operation, chain);
+ }
+
+ public void setTargetWire(OutboundWire wire) {
+ targetWire = wire;
+ }
+
+ public String getCallbackReferenceName() {
+ return callbackReferenceName;
+ }
+
+ public void setCallbackReferenceName(String callbackReferenceName) {
+ this.callbackReferenceName = callbackReferenceName;
+ }
+
+ public boolean isOptimizable() {
+ for (InboundInvocationChain chain : chains.values()) {
+ if (chain.getTargetInvoker() != null && !chain.getTargetInvoker().isOptimizable()) {
+ return false;
+ }
+ if (chain.getHeadInterceptor() != null) {
+ Interceptor current = chain.getHeadInterceptor();
+ while (current != null) {
+ if (!current.isOptimizable()) {
+ return false;
+ }
+ current = current.getNext();
+ }
+ }
+ }
+ return true;
+ }
+
+ public SCAObject getContainer() {
+ return container;
+ }
+
+ public void setContainer(SCAObject container) {
+ this.container = container;
+ }
+
+ public void addMapping(Object messageId, Object fromAddress) {
+ this.msgIdsToAddrs.put(messageId, fromAddress);
+ }
+
+ public Object retrieveMapping(Object messageId) {
+ return this.msgIdsToAddrs.get(messageId);
+ }
+
+ public void removeMapping(Object messageId) {
+ this.msgIdsToAddrs.remove(messageId);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
new file mode 100644
index 0000000000..d93426af4c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Contains functionality common to source- and target- side invocation chains
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class InvocationChainImpl implements InvocationChain {
+ protected Operation operation;
+ protected TargetInvoker targetInvoker;
+ protected Interceptor interceptorChainHead;
+ protected Interceptor interceptorChainTail;
+
+
+ // the pointer to a bridged target head interceptor or null if the target has no interceptors
+ protected Interceptor targetInterceptorChainHead;
+
+ public InvocationChainImpl(Operation operation) {
+ assert operation != null : "No operation type specified";
+ this.operation = operation;
+ }
+
+ public Operation getOperation() {
+ return operation;
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ this.targetInvoker = invoker;
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return targetInvoker;
+ }
+
+ public void addInterceptor(Interceptor interceptor) {
+ if (interceptorChainHead == null) {
+ interceptorChainHead = interceptor;
+ } else {
+ interceptorChainTail.setNext(interceptor);
+ }
+ interceptorChainTail = interceptor;
+ }
+
+ public void addInterceptor(int index, Interceptor interceptor) {
+ int i = 0;
+ Interceptor next = interceptorChainHead;
+ Interceptor prev = null;
+ while (next != null && i < index) {
+ prev = next;
+ next = next.getNext();
+ i++;
+ }
+ if (i == index) {
+ if (prev != null) {
+ prev.setNext(interceptor);
+ } else {
+ interceptorChainHead = interceptor;
+ }
+ interceptor.setNext(next);
+ if (next == null) {
+ interceptorChainTail = interceptor;
+ }
+ } else {
+ throw new ArrayIndexOutOfBoundsException(index);
+ }
+ }
+
+ public Interceptor getHeadInterceptor() {
+ return interceptorChainHead;
+ }
+
+ public Interceptor getTailInterceptor() {
+ return interceptorChainTail;
+ }
+
+ public void setTargetInterceptor(Interceptor interceptor) {
+ targetInterceptorChainHead = interceptor;
+ }
+
+ public Interceptor getTargetInterceptor() {
+ return targetInterceptorChainHead;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java
new file mode 100644
index 0000000000..90b17a930c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker passed
+ * inside the wire message. Target invokers are passed from the source in order to allow for caching of target
+ * instances.
+ *
+ * @version $Rev$ $Date$
+ * @see org.apache.tuscany.spi.wire.TargetInvoker
+ */
+public class InvokerInterceptor implements Interceptor {
+
+ public InvokerInterceptor() {
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ TargetInvoker invoker = msg.getTargetInvoker();
+ if (invoker == null) {
+ throw new InvocationRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last one in an target interceptor chain");
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java
new file mode 100644
index 0000000000..fcc57174ab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Bridges interceptors in a non-blocking fashion between an {@link org.apache.tuscany.spi.wire.InboundInvocationChain}
+ * and an {@link org.apache.tuscany.spi.wire.OutboundInvocationChain} by using a {@link
+ * org.apache.tuscany.spi.component.WorkContext}.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class NonBlockingBridgingInterceptor implements BridgingInterceptor {
+
+ private static final ContextBinder BINDER = new ContextBinder();
+ private static final Message RESPONSE = new ImmutableMessage();
+
+ private WorkScheduler workScheduler;
+ private WorkContext workContext;
+ private Interceptor next;
+
+ public NonBlockingBridgingInterceptor(WorkScheduler workScheduler, WorkContext workContext) {
+ this.workScheduler = workScheduler;
+ this.workContext = workContext;
+ }
+
+ public NonBlockingBridgingInterceptor(WorkScheduler workScheduler, WorkContext workContext, Interceptor next) {
+ this.workScheduler = workScheduler;
+ this.workContext = workContext;
+ this.next = next;
+ }
+
+ public Message invoke(final Message msg) {
+ final CompositeContext currentContext = CurrentCompositeContext.getContext();
+ // Schedule the invocation of the next interceptor in a new Work instance
+ try {
+ workScheduler.scheduleWork(new Runnable() {
+ public void run() {
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(null);
+ CompositeContext oldContext = CurrentCompositeContext.getContext();
+ try {
+ BINDER.setContext(currentContext);
+ next.invoke(msg);
+ } catch (Exception e) {
+ // REVIEW uncomment when it is available
+ // monitor.executionError(e);
+ e.printStackTrace();
+ } finally {
+ BINDER.setContext(oldContext);
+ }
+ }
+ });
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return RESPONSE;
+ }
+
+ public Interceptor getNext() {
+ return next;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next = next;
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+
+ private static class ContextBinder extends SCA {
+ public void setContext(CompositeContext context) {
+ setCompositeContext(context);
+ }
+
+ public void start() {
+ throw new AssertionError();
+ }
+
+ public void stop() {
+ throw new AssertionError();
+ }
+ }
+
+ /**
+ * A dummy message passed back on an invocation
+ */
+ private static class ImmutableMessage implements Message {
+
+ public Object getBody() {
+ return null;
+ }
+
+ public void setBody(Object body) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return null;
+ }
+
+ public Message getRelatedCallbackMessage() {
+ return null;
+ }
+
+ public Object getFromAddress() {
+ return null;
+ }
+
+ public void setFromAddress(Object fromAddress) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getMessageId() {
+ return null;
+ }
+
+ public void setMessageId(Object messageId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getCorrelationId() {
+ return null;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFault() {
+ return false;
+ }
+
+ public void setBodyWithFault(Object fault) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundAutowire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundAutowire.java
new file mode 100644
index 0000000000..c2824b3c88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundAutowire.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * A specialized outbound wire that uses an autowire algorithm to return reference to the target.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OutboundAutowire extends OutboundWire {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java
new file mode 100644
index 0000000000..a9d83cb7a0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+/**
+ * Contains a outgoing invocation pipeline for a service operation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OutboundInvocationChainImpl extends InvocationChainImpl implements OutboundInvocationChain {
+
+ /**
+ * Creates an new outbound chain
+ */
+ public OutboundInvocationChainImpl(Operation operation) {
+ super(operation);
+ }
+
+ public void prepare() {
+ if (interceptorChainHead != null) {
+ if (targetInterceptorChainHead != null) {
+ // Connect source interceptor chain directly to target interceptor chain
+ interceptorChainTail.setNext(targetInterceptorChainHead);
+ }
+ } else {
+ // no source interceptor chain or source handlers, connect to target interceptor chain or channel
+ if (targetInterceptorChainHead != null) {
+ interceptorChainHead = targetInterceptorChainHead;
+ interceptorChainTail = targetInterceptorChainHead;
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java
new file mode 100644
index 0000000000..4dc5241171
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Default implementation of an outbound wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class OutboundWireImpl implements OutboundWire {
+
+ private ServiceContract serviceContract;
+ private Class<?>[] callbackInterfaces;
+ private Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ private Map<Operation<?>, InboundInvocationChain> callbackTargetChains =
+ new HashMap<Operation<?>, InboundInvocationChain>();
+ private String referenceName;
+ private QualifiedName targetName;
+ private InboundWire targetWire;
+ private SCAObject container;
+
+ public Object getTargetService() throws TargetException {
+ if (targetWire != null) {
+ // optimized, no interceptors or handlers on either end
+ return targetWire.getTargetService();
+ }
+ throw new TargetException("Target wire not optimized");
+ }
+
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public void addInterface(Class<?> claz) {
+ throw new UnsupportedOperationException("Additional proxy interfaces not yet supported");
+ }
+
+ public void setCallbackInterface(Class<?> interfaze) {
+ callbackInterfaces = new Class[]{interfaze};
+ }
+
+ public Class<?> getCallbackInterface() {
+ return callbackInterfaces[0];
+ }
+
+ public void addCallbackInterface(Class<?> claz) {
+ throw new UnsupportedOperationException("Additional callback interfaces not yet supported");
+ }
+
+ public Class[] getImplementedCallbackInterfaces() {
+ return callbackInterfaces;
+ }
+
+ public void setTargetWire(InboundWire wire) {
+ this.targetWire = wire;
+ }
+
+ public Map<Operation<?>, OutboundInvocationChain> getInvocationChains() {
+ return chains;
+ }
+
+ public void addInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
+ this.chains.putAll(chains);
+ }
+
+ public void addInvocationChain(Operation<?> operation, OutboundInvocationChain chain) {
+ chains.put(operation, chain);
+ }
+
+ public Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains() {
+ return callbackTargetChains;
+ }
+
+ public void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
+ callbackTargetChains.putAll(chains);
+ }
+
+ public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) {
+ callbackTargetChains.put(operation, chain);
+ }
+
+ public String getReferenceName() {
+ return referenceName;
+ }
+
+ public void setReferenceName(String referenceName) {
+ this.referenceName = referenceName;
+ }
+
+ public QualifiedName getTargetName() {
+ return targetName;
+ }
+
+ public void setTargetName(QualifiedName targetName) {
+ this.targetName = targetName;
+ }
+
+ public boolean isOptimizable() {
+ for (OutboundInvocationChain chain : chains.values()) {
+ if (chain.getHeadInterceptor() != null) {
+ Interceptor current = chain.getHeadInterceptor();
+ while (current != null && current != chain.getTargetInterceptor()) {
+ if (!current.isOptimizable()) {
+ return false;
+ }
+ current = current.getNext();
+ }
+ }
+ }
+
+ for (InboundInvocationChain chain : callbackTargetChains.values()) {
+ if (chain.getTargetInvoker() != null && !chain.getTargetInvoker().isOptimizable()) {
+ return false;
+ }
+ if (chain.getHeadInterceptor() != null) {
+ Interceptor current = chain.getHeadInterceptor();
+ while (current != null) {
+ if (!current.isOptimizable()) {
+ return false;
+ }
+ current = current.getNext();
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public SCAObject getContainer() {
+ return container;
+ }
+
+ public void setContainer(SCAObject container) {
+ this.container = container;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/PojoTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/PojoTargetInvoker.java
new file mode 100644
index 0000000000..4c967e6c3f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/PojoTargetInvoker.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.findClosestMatchingMethod;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
+
+/**
+ * Base class for dispatching to a Java based component implementation. Subclasses implement a strategy for resolving
+ * implementation instances.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class PojoTargetInvoker implements TargetInvoker {
+
+ protected Method operation;
+ protected boolean cacheable;
+
+ public PojoTargetInvoker(Method operation) {
+ assert operation != null : "Operation method cannot be null";
+ this.operation = operation;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object instance = getInstance();
+ if (!operation.getDeclaringClass().isInstance(instance)) {
+ Set<Method> methods = getAllUniquePublicProtectedMethods(instance.getClass());
+ Method newOperation = findClosestMatchingMethod(operation.getName(),
+ operation.getParameterTypes(), methods);
+ if (newOperation != null) {
+ operation = newOperation;
+ }
+ }
+ if (payload != null && !payload.getClass().isArray()) {
+ return operation.invoke(instance, payload);
+ } else {
+ return operation.invoke(instance, (Object[]) payload);
+ }
+ } catch (IllegalAccessException e) {
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable(); // we only need to check if the scopes are correct
+ }
+
+ @Override
+ public PojoTargetInvoker clone() throws CloneNotSupportedException {
+ try {
+ PojoTargetInvoker clone = (PojoTargetInvoker) super.clone();
+ clone.operation = this.operation;
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+
+ protected abstract Object getInstance() throws TargetException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/StaticPojoTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/StaticPojoTargetInvoker.java
new file mode 100644
index 0000000000..d836661ceb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/StaticPojoTargetInvoker.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+
+/**
+ * Caches component instances that do not need to be resolved for every wire, e.g. an wire originating from a lesser
+ * scope intended for a target with a wider scope
+ *
+ * @version $Rev$ $Date$
+ */
+public class StaticPojoTargetInvoker extends PojoTargetInvoker {
+
+ private Object instance;
+
+ public StaticPojoTargetInvoker(Method operation, Object instance) {
+ super(operation);
+ assert instance != null : "Instance cannot be null";
+ this.instance = instance;
+ }
+
+ protected Object getInstance() {
+ return instance;
+ }
+
+ public StaticPojoTargetInvoker clone() throws CloneNotSupportedException {
+ StaticPojoTargetInvoker invoker = (StaticPojoTargetInvoker) super.clone();
+ invoker.instance = null;
+ return invoker;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java
new file mode 100644
index 0000000000..f09bda400a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ * Synchronously bridges interceptors between an {@link org.apache.tuscany.spi.wire.InboundInvocationChain} and an
+ * {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SynchronousBridgingInterceptor implements BridgingInterceptor {
+ private Interceptor next;
+
+ public SynchronousBridgingInterceptor() {
+ }
+
+ public SynchronousBridgingInterceptor(Interceptor next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ return next.invoke(msg);
+ }
+
+ public Interceptor getNext() {
+ return next;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next = next;
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java
new file mode 100644
index 0000000000..d146da6283
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+
+/**
+ * Responsible for invoking on an outbound wire associated with a callback. The handler retrieves the correct outbound
+ * callback wire from the work context.
+ * <p/>
+ * TODO cache target invoker
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKCallbackInvocationHandler extends AbstractOutboundInvocationHandler
+ implements WireInvocationHandler, InvocationHandler {
+
+ private WorkContext context;
+ private InboundWire inboundWire;
+ private Object messageId;
+ private Object correlationId;
+
+ public JDKCallbackInvocationHandler(WorkContext context, InboundWire inboundWire) {
+ this.context = context;
+ this.inboundWire = inboundWire;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ messageId = context.getCurrentMessageId();
+ context.setCurrentMessageId(null);
+ correlationId = context.getCurrentCorrelationId();
+ context.setCurrentCorrelationId(null);
+ Object targetAddress = inboundWire.retrieveMapping(correlationId);
+ if (targetAddress == null) {
+ throw new AssertionError("No from address associated with message id [" + correlationId + "]");
+ }
+ //TODO optimize as this is slow in local invocations
+ Map<Operation<?>, OutboundInvocationChain> sourceCallbackInvocationChains =
+ inboundWire.getSourceCallbackInvocationChains(targetAddress);
+ Operation operation = findOperation(method, sourceCallbackInvocationChains.keySet());
+ OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation);
+ TargetInvoker invoker = chain.getTargetInvoker();
+ return invoke(chain, invoker, args);
+ }
+
+
+ public Object invoke(Method method, Object[] args) throws Throwable {
+ return invoke(null, method, args);
+ }
+
+ protected Object getFromAddress() {
+ return (inboundWire.getContainer() == null) ? null : inboundWire.getContainer().getName();
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
new file mode 100644
index 0000000000..43cbe4be88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.AbstractInboundInvocationHandler;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+
+/**
+ * Receives a request from a proxy and performs an invocation on an {@link org.apache.tuscany.spi.wire.InboundWire} via
+ * an {@link InboundInvocationChain}
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKInboundInvocationHandler extends AbstractInboundInvocationHandler
+ implements WireInvocationHandler, InvocationHandler {
+
+ /*
+ * an association of an operation to chain holder. The holder contains the invocation chain
+ * and a local clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the
+ * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers
+ * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker
+ * is not cacheable, the master associated with the wire chains will be used.
+ */
+ private Map<Method, ChainHolder> chains;
+ private WorkContext context;
+ private Object messageId;
+ private Object correlationId;
+
+ public JDKInboundInvocationHandler(Map<Method, InboundInvocationChain> invocationChains, WorkContext context) {
+ this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
+ for (Map.Entry<Method, InboundInvocationChain> entry : invocationChains.entrySet()) {
+ this.chains.put(entry.getKey(), new ChainHolder(entry.getValue()));
+ }
+ this.context = context;
+ }
+
+ /**
+ * Dispatches a client request made on a proxy
+ */
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ ChainHolder holder = chains.get(method);
+ if (holder == null) {
+ if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) {
+ return "[Proxy - " + Integer.toHexString(hashCode()) + "]";
+ } else if (method.getDeclaringClass().equals(Object.class)
+ && "equals".equals(method.getName())) {
+ // TODO implement
+ throw new UnsupportedOperationException();
+ } else if (Object.class.equals(method.getDeclaringClass())
+ && "hashCode".equals(method.getName())) {
+ return hashCode();
+ // TODO beter hash algorithm
+ }
+ TargetException e = new TargetException("Operation not configured");
+ e.setIdentifier(method.getName());
+ throw e;
+ }
+ InboundInvocationChain chain = holder.chain;
+ TargetInvoker invoker;
+ if (holder.cachedInvoker == null) {
+ assert chain != null;
+ if (chain.getTargetInvoker() == null) {
+ TargetException e = new TargetException("No target invoker configured for operation");
+ e.setIdentifier(chain.getOperation().getName());
+ throw e;
+ }
+ if (chain.getTargetInvoker().isCacheable()) {
+ // clone and store the invoker locally
+ holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
+ invoker = holder.cachedInvoker;
+ } else {
+ invoker = chain.getTargetInvoker();
+ }
+ } else {
+ assert chain != null;
+ invoker = chain.getTargetInvoker();
+ }
+ messageId = context.getCurrentMessageId();
+ context.setCurrentMessageId(null);
+ correlationId = context.getCurrentCorrelationId();
+ context.setCurrentCorrelationId(null);
+ return invoke(chain, invoker, args);
+ }
+
+
+ public Object invoke(Method method, Object[] args) throws Throwable {
+ return invoke(null, method, args);
+ }
+
+ /**
+ * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from
+ * the chain master
+ */
+ private class ChainHolder {
+
+ InboundInvocationChain chain;
+ TargetInvoker cachedInvoker;
+
+ public ChainHolder(InboundInvocationChain config) {
+ this.chain = config;
+ }
+
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
new file mode 100644
index 0000000000..a2ca344624
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+
+/**
+ * Receives a request from a proxy and performs an invocation on an {@link org.apache.tuscany.spi.wire.OutboundWire} via
+ * an {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKOutboundInvocationHandler extends AbstractOutboundInvocationHandler
+ implements WireInvocationHandler, InvocationHandler {
+
+ /*
+ * an association of an operation to chain holder. The holder contains an invocation chain
+ * and a local clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the
+ * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers
+ * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker
+ * is not cacheable, the master associated with the wire chains will be used.
+ */
+ private Map<Method, ChainHolder> chains;
+ private WorkContext context;
+ private Object fromAddress;
+ private Object messageId;
+ private Object correlationId;
+
+ public JDKOutboundInvocationHandler(OutboundWire wire, WorkContext context)
+ throws NoMethodForOperationException {
+ Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
+ this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
+ this.fromAddress = (wire.getContainer() == null) ? null : wire.getContainer().getName();
+ Method[] methods = wire.getServiceContract().getInterfaceClass().getMethods();
+ // TODO optimize this
+ for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
+ Operation operation = entry.getKey();
+ Method method = findMethod(operation, methods);
+ if (method == null) {
+ throw new NoMethodForOperationException(operation.getName());
+ }
+ this.chains.put(method, new ChainHolder(entry.getValue()));
+ }
+
+ this.context = context;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ ChainHolder holder = chains.get(method);
+ if (holder == null) {
+ if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) {
+ return "[Proxy - " + Integer.toHexString(hashCode()) + "]";
+ } else if (method.getDeclaringClass().equals(Object.class)
+ && "equals".equals(method.getName())) {
+ // TODO implement
+ throw new UnsupportedOperationException();
+ } else if (Object.class.equals(method.getDeclaringClass())
+ && "hashCode".equals(method.getName())) {
+ return hashCode();
+ // TODO beter hash algorithm
+ }
+ TargetException e = new TargetException("Operation not configured");
+ e.setIdentifier(method.getName());
+ throw e;
+ }
+ OutboundInvocationChain chain = holder.chain;
+ TargetInvoker invoker;
+
+ if (holder.cachedInvoker == null) {
+ assert chain != null;
+ if (chain.getTargetInvoker() == null) {
+ TargetException e = new TargetException("No target invoker configured for operation");
+ e.setIdentifier(chain.getOperation().getName());
+ throw e;
+ }
+ if (chain.getTargetInvoker().isCacheable()) {
+ // clone and store the invoker locally
+ holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
+ invoker = holder.cachedInvoker;
+ } else {
+ invoker = chain.getTargetInvoker();
+ }
+ } else {
+ assert chain != null;
+ invoker = chain.getTargetInvoker();
+ }
+ messageId = context.getCurrentMessageId();
+ context.setCurrentMessageId(null);
+ correlationId = context.getCurrentCorrelationId();
+ context.setCurrentCorrelationId(null);
+ return invoke(chain, invoker, args);
+ }
+
+ public Object invoke(Method method, Object[] args) throws Throwable {
+ return invoke(null, method, args);
+ }
+
+ protected Object getFromAddress() {
+ return fromAddress;
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+
+ /**
+ * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from
+ * the chain master
+ */
+ private class ChainHolder {
+
+ OutboundInvocationChain chain;
+ TargetInvoker cachedInvoker;
+
+ public ChainHolder(OutboundInvocationChain config) {
+ this.chain = config;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
new file mode 100644
index 0000000000..7c7693ca3e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.ReferenceNotFoundException;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.policy.PolicyBuilderRegistry;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.ProxyCreationException;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+import org.apache.tuscany.spi.wire.WireServiceExtension;
+
+import org.apache.tuscany.core.implementation.composite.CompositeReference;
+import org.apache.tuscany.core.implementation.composite.CompositeService;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+
+/**
+ * the default implementation of a wire service that uses JDK dynamic proxies
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@Scope("MODULE")
+public class JDKWireService extends WireServiceExtension {
+
+ public JDKWireService() {
+ super(null, null);
+ }
+
+ @Constructor({"workContext", "policyregisty"})
+ public JDKWireService(@Autowire WorkContext context, @Autowire PolicyBuilderRegistry policyRegistry) {
+ super(context, policyRegistry);
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public Object createProxy(RuntimeWire wire) throws ProxyCreationException {
+ assert wire != null : "Wire was null";
+ if (wire instanceof InboundWire) {
+ InboundWire inbound = (InboundWire) wire;
+ Class<?> interfaze = wire.getServiceContract().getInterfaceClass();
+ Method[] methods = interfaze.getMethods();
+ Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, context);
+ ClassLoader cl = interfaze.getClassLoader();
+ //FIXME
+ return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
+ } else if (wire instanceof OutboundWire) {
+ OutboundWire outbound = (OutboundWire) wire;
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(outbound, context);
+ Class<?> interfaze = outbound.getServiceContract().getInterfaceClass();
+ ClassLoader cl = interfaze.getClassLoader();
+ return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
+ } else {
+ ProxyCreationException e = new ProxyCreationException("Invalid wire type");
+ e.setIdentifier(wire.getClass().getName());
+ throw e;
+ }
+ }
+
+ public Object createCallbackProxy(ServiceContract<?> contract, InboundWire wire) throws ProxyCreationException {
+ Class<?> interfaze = contract.getCallbackClass();
+ ClassLoader cl = interfaze.getClassLoader();
+ JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(context, wire);
+ return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler));
+ }
+
+ public WireInvocationHandler createHandler(RuntimeWire wire) {
+ assert wire != null : "Wire was null";
+ if (wire instanceof InboundWire) {
+ InboundWire inbound = (InboundWire) wire;
+ Method[] methods = inbound.getServiceContract().getInterfaceClass().getMethods();
+ Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
+ return new JDKInboundInvocationHandler(chains, context);
+ } else if (wire instanceof OutboundWire) {
+ OutboundWire outbound = (OutboundWire) wire;
+ return new JDKOutboundInvocationHandler(outbound, context);
+ } else {
+ ProxyCreationException e = new ProxyCreationException("Invalid wire type");
+ e.setIdentifier(wire.getClass().getName());
+ throw e;
+ }
+ }
+
+ public WireInvocationHandler createCallbackHandler(InboundWire wire) {
+ return new JDKCallbackInvocationHandler(context, wire);
+ }
+
+ public OutboundInvocationChain createOutboundChain(Operation<?> operation) {
+ return new OutboundInvocationChainImpl(operation);
+ }
+
+ public InboundInvocationChain createInboundChain(Operation<?> operation) {
+ return new InboundInvocationChainImpl(operation);
+ }
+
+ public void createWires(Component component, ComponentDefinition<?> definition) {
+ Implementation<?> implementation = definition.getImplementation();
+ ComponentType<?, ?, ?> componentType = implementation.getComponentType();
+ for (ServiceDefinition service : componentType.getServices().values()) {
+ InboundWire inboundWire = createWire(service);
+ inboundWire.setContainer(component);
+ if (componentType instanceof CompositeComponentType<?, ?, ?>) {
+ // If this is the case, then it means that component has already been returned
+ // by CompositeBuilder and thus its children, in particular composite services,
+ // have been registered
+ CompositeComponent compositeComponent = (CompositeComponent) component;
+ Service serviceChild = (Service) compositeComponent.getChild(service.getName());
+ assert serviceChild != null;
+ if (serviceChild instanceof CompositeService) {
+ serviceChild.setInboundWire(inboundWire);
+ // Notice that now the more immediate container of the wire is the composite service
+ inboundWire.setContainer(serviceChild);
+ }
+ }
+ component.addInboundWire(inboundWire);
+ }
+
+ for (ReferenceTarget referenceTarget : definition.getReferenceTargets().values()) {
+ Map<String, ? extends ReferenceDefinition> references = componentType.getReferences();
+ ReferenceDefinition mappedReference = references.get(referenceTarget.getReferenceName());
+ if (mappedReference == null) {
+ String refName = referenceTarget.getReferenceName();
+ ReferenceNotFoundException e = new ReferenceNotFoundException(refName);
+ e.addContextName(refName);
+ e.addContextName(definition.getName());
+ throw e;
+ }
+ OutboundWire wire = createWire(referenceTarget, mappedReference);
+ wire.setContainer(component);
+ component.addOutboundWire(wire);
+ if (componentType instanceof CompositeComponentType<?, ?, ?>) {
+ // If this is the case, then it means that component has already been returned
+ // by CompositeBuilder and thus its children, in particular composite references,
+ // have been registered
+ CompositeComponent compositeComponent = (CompositeComponent) component;
+ Reference reference = (Reference) compositeComponent.getChild(referenceTarget.getReferenceName());
+ assert reference != null;
+ if (reference instanceof CompositeReference) {
+ reference.setOutboundWire(wire);
+ // Notice that now the more immediate container of the wire is the composite reference
+ wire.setContainer(reference);
+ }
+ }
+ }
+ }
+
+ public void createWires(Reference reference, ServiceContract<?> contract) {
+ InboundWire inboundWire = new InboundWireImpl();
+ inboundWire.setServiceContract(contract);
+ inboundWire.setContainer(reference);
+ for (Operation<?> operation : contract.getOperations().values()) {
+ InboundInvocationChain chain = createInboundChain(operation);
+ inboundWire.addInvocationChain(operation, chain);
+ }
+ OutboundWire outboundWire = new OutboundWireImpl();
+
+ // [rfeng] Check if the Reference has the binding contract
+ ServiceContract<?> bindingContract = reference.getBindingServiceContract();
+ if (bindingContract == null) {
+ bindingContract = contract;
+ }
+ outboundWire.setServiceContract(bindingContract);
+ outboundWire.setContainer(reference);
+ for (Operation<?> operation : bindingContract.getOperations().values()) {
+ OutboundInvocationChain chain = createOutboundChain(operation);
+ chain.addInterceptor(new InvokerInterceptor());
+ outboundWire.addInvocationChain(operation, chain);
+ }
+
+ // Notice that we skip inboundWire.setCallbackReferenceName
+ // First, an inbound inboundWire's callbackReferenceName is only retrieved by JavaAtomicComponent
+ // to create a callback injector based on the callback reference member; a composite reference
+ // should not need to do that
+ // Second, a reference definition does not have a callback reference name like a service
+ // definition does
+ reference.setInboundWire(inboundWire);
+ reference.setOutboundWire(outboundWire);
+ }
+
+ public OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def) {
+ //TODO multiplicity
+ if (reference.getTargets().size() != 1) {
+ throw new UnsupportedOperationException();
+ }
+ ServiceContract<?> contract = def.getServiceContract();
+ OutboundWire wire = new OutboundWireImpl();
+ QualifiedName qName = new QualifiedName(reference.getTargets().get(0).toString());
+ wire.setTargetName(qName);
+ wire.setServiceContract(contract);
+ wire.setReferenceName(reference.getReferenceName());
+ for (Operation<?> operation : contract.getOperations().values()) {
+ //TODO handle policy
+ OutboundInvocationChain chain = createOutboundChain(operation);
+ wire.addInvocationChain(operation, chain);
+
+ }
+ if (contract.getCallbackName() != null) {
+ wire.setCallbackInterface(contract.getCallbackClass());
+ for (Operation<?> operation : contract.getCallbackOperations().values()) {
+ InboundInvocationChain callbackTargetChain = createInboundChain(operation);
+ // TODO handle policy
+ //TODO statement below could be cleaner
+ callbackTargetChain.addInterceptor(new InvokerInterceptor());
+ wire.addTargetCallbackInvocationChain(operation, callbackTargetChain);
+ }
+ }
+ return wire;
+ }
+
+ public InboundWire createWire(ServiceDefinition service) {
+ InboundWire wire = new InboundWireImpl();
+ ServiceContract<?> contract = service.getServiceContract();
+ wire.setServiceContract(contract);
+ wire.setServiceName(service.getName());
+ for (Operation<?> operation : contract.getOperations().values()) {
+ InboundInvocationChain chain = createInboundChain(operation);
+ // TODO handle policy
+ //TODO statement below could be cleaner
+ chain.addInterceptor(new InvokerInterceptor());
+ wire.addInvocationChain(operation, chain);
+ }
+ if (contract.getCallbackName() != null) {
+ wire.setCallbackReferenceName(service.getCallbackReferenceName());
+ }
+ return wire;
+ }
+
+ public void createWires(Service service, String targetName, ServiceContract<?> contract) {
+ InboundWire inboundWire = new InboundWireImpl();
+
+ // [rfeng] Check if the Reference has the binding contract
+ ServiceContract<?> bindingContract = service.getBindingServiceContract();
+ if (bindingContract == null) {
+ bindingContract = contract;
+ }
+ inboundWire.setServiceContract(bindingContract);
+ inboundWire.setContainer(service);
+ for (Operation<?> operation : bindingContract.getOperations().values()) {
+ InboundInvocationChain inboundChain = createInboundChain(operation);
+ inboundWire.addInvocationChain(operation, inboundChain);
+ }
+
+ OutboundWire outboundWire = new OutboundWireImpl();
+ outboundWire.setServiceContract(contract);
+ outboundWire.setTargetName(new QualifiedName(targetName));
+ outboundWire.setContainer(service);
+
+ for (Operation<?> operation : contract.getOperations().values()) {
+ OutboundInvocationChain outboundChain = createOutboundChain(operation);
+ outboundWire.addInvocationChain(operation, outboundChain);
+ }
+
+ // Add target callback chain to outbound wire, applicable to both bound and bindless services
+ if (contract.getCallbackName() != null) {
+ outboundWire.setCallbackInterface(contract.getCallbackClass());
+ for (Operation<?> operation : contract.getCallbackOperations().values()) {
+ InboundInvocationChain callbackTargetChain = createInboundChain(operation);
+// TODO handle policy
+//TODO statement below could be cleaner
+ callbackTargetChain.addInterceptor(new InvokerInterceptor());
+ outboundWire.addTargetCallbackInvocationChain(operation, callbackTargetChain);
+ }
+ }
+
+ // Not clear in any case why this is done here and at the parent composite level as well
+ // But for a composite service, make sure that the inbound wire comes from the parent
+ if (!(service instanceof CompositeService)) {
+ service.setInboundWire(inboundWire);
+ }
+ service.setOutboundWire(outboundWire);
+ }
+
+
+ private Map<Method, InboundInvocationChain> createInboundMapping(InboundWire wire, Method[] methods)
+ throws NoMethodForOperationException {
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ for (Map.Entry<Operation<?>, InboundInvocationChain> entry : wire.getInvocationChains().entrySet()) {
+ Operation<?> operation = entry.getKey();
+ InboundInvocationChain chain = entry.getValue();
+ Method method = findMethod(operation, methods);
+ if (method == null) {
+ NoMethodForOperationException e = new NoMethodForOperationException();
+ e.setIdentifier(operation.getName());
+ }
+ chains.put(method, chain);
+ }
+ return chains;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
new file mode 100644
index 0000000000..5a123ee814
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import org.apache.tuscany.spi.wire.ProxyCreationException;
+
+/**
+ * Thrown when an {@link org.apache.tuscany.spi.model.Operation} cannot be mapped to a method on an interface
+ * @version $Rev$ $Date$
+ */
+public class NoMethodForOperationException extends ProxyCreationException {
+ public NoMethodForOperationException() {
+ }
+
+ public NoMethodForOperationException(String message) {
+ super(message);
+ }
+
+ public NoMethodForOperationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoMethodForOperationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl
new file mode 100644
index 0000000000..3531df98ad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.Composite">
+
+ <!-- Composite implementation type -->
+ <component name="composite.loader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeLoader"/>
+ </component>
+ <component name="composite.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.ImplementationCompositeLoader"/>
+ </component>
+ <component name="composite.dependencyLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.DependencyLoader"/>
+ </component>
+ <component name="composite.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeComponentTypeLoader"/>
+ </component>
+ <component name="composite.builder">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeBuilder"/>
+ </component>
+ <component name="composite.bindlessbuilder">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeBindlessBuilder"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl
new file mode 100644
index 0000000000..0ee347aa91
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.DataBinding">
+
+ <component name="databinding.wirePostProcessor">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.DataBindingWirePostProcessor" />
+ </component>
+
+ <component name="databinding.javaInterfaceProcessor">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.DataBindingJavaInterfaceProcessor" />
+ </component>
+
+ <!-- DataBinding registry -->
+ <component name="databinding.registry">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.DataBindingRegistryImpl" />
+ </component>
+
+ <!-- DataBinding registry -->
+ <component name="databinding.mediator">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.MediatorImpl" />
+ </component>
+
+ <!-- Transformer registry -->
+ <component name="databinding.transformerRegistry" initLevel="90">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.TransformerRegistryImpl" />
+ </component>
+
+ <component name="dataType.loader">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.DataTypeLoader" />
+ </component>
+
+ <!-- Simple databindings -->
+ <component name="databinding.dom">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.SimpleDataBinding" />
+ <property name="className">org.w3c.dom.Node</property>
+ </component>
+
+ <!-- Transformers -->
+
+ <component name="transformer.Input2InputTransformer">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.Input2InputTransformer" />
+ </component>
+
+ <component name="transformer.Output2OutputTransformer">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.Output2OutputTransformer" />
+ </component>
+
+ <component name="transformer.InputSource2Node">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.InputSource2Node" />
+ </component>
+
+ <component name="transformer.InputSource2SAX">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.InputSource2SAX" />
+ </component>
+
+ <component name="transformer.InputStream2Node">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.InputStream2Node" />
+ </component>
+
+ <component name="transformer.InputStream2SAX">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.InputStream2SAX" />
+ </component>
+
+ <component name="transformer.Node2Object">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Node2Object" />
+ </component>
+
+ <component name="transformer.Node2OutputStream">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Node2OutputStream" />
+ </component>
+
+ <component name="transformer.Node2String">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Node2String" />
+ </component>
+
+ <component name="transformer.Node2Writer">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Node2Writer" />
+ </component>
+
+ <component name="transformer.Node2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Node2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.Object2Node">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Object2Node" />
+ </component>
+
+ <component name="transformer.Reader2Node">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Reader2Node" />
+ </component>
+
+ <component name="transformer.Reader2SAX">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Reader2SAX" />
+ </component>
+
+ <component name="transformer.SAX2DOMPipe">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.SAX2DOMPipe" />
+ </component>
+
+ <component name="transformer.Source2ResultTransformer">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Source2ResultTransformer" />
+ </component>
+
+ <component name="transformer.StreamDataPipe">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.StreamDataPipe" />
+ </component>
+
+ <component name="transformer.String2Node">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.String2Node" />
+ </component>
+
+ <component name="transformer.String2SAX">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.String2SAX" />
+ </component>
+
+ <component name="transformer.String2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.String2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.Writer2ReaderDataPipe">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.Writer2ReaderDataPipe" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2Node">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.XMLStreamReader2Node" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2SAX">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.XMLStreamReader2SAX" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2String">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.xml.XMLStreamReader2String" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl
new file mode 100644
index 0000000000..7efa6997f2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.Implementation">
+
+ <!-- Foundation implementation processors -->
+ <component name="implementation.ImplementationProcessorService">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl"/>
+ </component>
+ <component name="implementation.Constructor">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.ConstructorProcessor"/>
+ </component>
+ <component name="implementation.Destroy">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.DestroyProcessor"/>
+ </component>
+ <component name="implementation.Init">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.InitProcessor"/>
+ </component>
+ <component name="implementation.Scope">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.ScopeProcessor"/>
+ </component>
+ <component name="implementation.Property">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.PropertyProcessor"/>
+ </component>
+ <component name="implementation.Reference">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.ReferenceProcessor"/>
+ </component>
+ <component name="implementation.Service">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.ServiceProcessor"/>
+ </component>
+ <component name="implementation.HeuristicPojo">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor"/>
+ </component>
+ <component name="implementation.Monitor">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.processor.MonitorProcessor"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl
new file mode 100644
index 0000000000..6f889cabb9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Configuration for Java IDL support.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.InterfaceJava">
+
+ <component name="interfaceJava.interfaceProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl"/>
+ </component>
+ <component name="interfaceJava.loader">
+ <system:implementation.system class="org.apache.tuscany.core.idl.java.InterfaceJavaLoader"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl
new file mode 100644
index 0000000000..29ef9200f7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.JavaImplementation">
+
+ <!-- Java implementation type -->
+ <component name="java.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.java.JavaImplementationLoader"/>
+ </component>
+ <component name="java.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.java.JavaComponentTypeLoader"/>
+ </component>
+ <component name="java.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.java.JavaComponentBuilder"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl
new file mode 100644
index 0000000000..0b6917e181
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default loader configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.Loader">
+
+ <!-- Foundation element loader implementations -->
+ <component name="elementLoader.component">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ComponentLoader"/>
+ </component>
+ <component name="elementLoader.componentType">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ComponentTypeElementLoader"/>
+ </component>
+ <component name="elementLoader.include">
+ <system:implementation.system class="org.apache.tuscany.core.loader.IncludeLoader"/>
+ </component>
+ <component name="elementLoader.property">
+ <system:implementation.system class="org.apache.tuscany.core.loader.PropertyLoader"/>
+ </component>
+ <component name="elementLoader.reference">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ReferenceLoader"/>
+ </component>
+ <component name="elementLoader.service">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ServiceLoader"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl
new file mode 100644
index 0000000000..a624ac94c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.core.SystemImplementation">
+
+ <!-- System implementation type -->
+ <component name="system.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.system.loader.SystemBindingLoader"/>
+ </component>
+
+ <component name="system.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.system.loader.SystemComponentTypeLoader"/>
+ </component>
+
+ <component name="system.compositeComponentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.system.loader.SystemCompositeComponentTypeLoader"/>
+ </component>
+ <component name="system.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.system.loader.SystemImplementationLoader"/>
+ </component>
+ <component name="system.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder"/>
+ </component>
+ <component name="system.compositeBuilder">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.system.builder.SystemCompositeBuilder"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
new file mode 100644
index 0000000000..deb4ae3f62
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.deployer.DeployerImpl;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+
+/**
+ * Verifies the default bootstrapper can be instantiated
+ *
+ * @version $Rev$ $Date$
+ */
+public class BootstrapperTestCase extends TestCase {
+ private Bootstrapper bootstrapper;
+
+ public void testDeployerBootstrap() {
+ DeployerImpl deployer = (DeployerImpl) bootstrapper.createDeployer();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), null);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java
new file mode 100644
index 0000000000..5a33950cc4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.builder.ComponentBuilder;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BuilderRegistryTestCase extends TestCase {
+ private DeploymentContext deploymentContext;
+ private BuilderRegistryImpl registry;
+
+ public void testRegistrationWithoutGenerics() {
+ RawBuilder builder = new RawBuilder();
+ registry.register(CompositeImplementation.class, builder);
+ CompositeImplementation implementation = new CompositeImplementation();
+ ComponentDefinition<CompositeImplementation> componentDefinition =
+ new ComponentDefinition<CompositeImplementation>(implementation);
+ componentDefinition.getImplementation().setComponentType(new CompositeComponentType());
+ registry.build(null, componentDefinition, deploymentContext);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new BuilderRegistryImpl();
+ WireService service = EasyMock.createNiceMock(WireService.class);
+ registry.setWireService(service);
+ deploymentContext = new RootDeploymentContext(null, null, null, null);
+ }
+
+ public static class GenerifiedBuilder implements ComponentBuilder<CompositeImplementation> {
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<CompositeImplementation> componentDefinition,
+ DeploymentContext deploymentContext) {
+ return null;
+ }
+ }
+
+ public static class RawBuilder implements ComponentBuilder<CompositeImplementation> {
+ public Component build(CompositeComponent parent,
+ ComponentDefinition componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
new file mode 100644
index 0000000000..967c17ece0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
@@ -0,0 +1,416 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectorImplTestCase extends TestCase {
+
+ private ConnectorImpl connector;
+ private ServiceContract contract;
+ private Operation<Type> operation;
+ private Interceptor headInterceptor;
+ private Interceptor tailInterceptor;
+
+ public void testConnectReferenceWires() {
+
+ // create the inbound wire and chain
+ InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+ inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ inboundChain.setTargetInvoker(null);
+ inboundChain.prepare();
+ EasyMock.replay(inboundChain);
+ Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
+ inboundChains.put(operation, inboundChain);
+ InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains).atLeastOnce();
+ EasyMock.replay(inboundWire);
+
+ OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+ EasyMock.replay(outboundChain);
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ outboundChains.put(operation, outboundChain);
+ OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+ EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
+ EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+ EasyMock.replay(outboundWire);
+
+ Reference reference = EasyMock.createMock(Reference.class);
+ EasyMock.expect(reference.getParent()).andReturn(null);
+ EasyMock.expect(reference.createTargetInvoker(contract, operation)).andReturn(null);
+ EasyMock.expect(reference.getInboundWire()).andReturn(inboundWire);
+ EasyMock.expect(reference.getOutboundWire()).andReturn(outboundWire);
+ EasyMock.replay(reference);
+
+ connector.connect(reference);
+
+ EasyMock.verify(reference);
+ EasyMock.verify(inboundWire);
+ EasyMock.verify(outboundWire);
+ EasyMock.verify(inboundChain);
+ EasyMock.verify(outboundChain);
+ }
+
+ public void testConnectServiceWires() {
+ // create the inbound wire and chain for the target
+ InboundInvocationChain targetChain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(targetChain.getOperation()).andReturn(operation).atLeastOnce();
+ EasyMock.expect(targetChain.getHeadInterceptor()).andReturn(headInterceptor);
+ targetChain.prepare();
+ EasyMock.replay(targetChain);
+ Map<Operation<?>, InboundInvocationChain> targetChains = new HashMap<Operation<?>, InboundInvocationChain>();
+ targetChains.put(operation, targetChain);
+ InboundWire targetWire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(targetWire.getInvocationChains()).andReturn(targetChains);
+ targetWire.getSourceCallbackInvocationChains("source");
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+
+ // create the target
+ AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(target.getScope()).andReturn(Scope.MODULE);
+ EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
+ target.getInboundWire(EasyMock.eq("FooService"));
+ EasyMock.expectLastCall().andReturn(targetWire).atLeastOnce();
+ target.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation));
+ EasyMock.expectLastCall().andReturn(null);
+ EasyMock.replay(target);
+
+ EasyMock.expect(targetWire.getContainer()).andReturn(target);
+ EasyMock.replay(targetWire);
+
+ // create the parent composite
+ CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
+ EasyMock.expect(parent.getChild("target")).andReturn(target);
+ EasyMock.replay(parent);
+
+ // create the inbound wire and chain for the source service
+ InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+ inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ inboundChain.setTargetInvoker(null);
+ EasyMock.replay(inboundChain);
+ Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
+ inboundChains.put(operation, inboundChain);
+ InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains).atLeastOnce();
+ EasyMock.replay(inboundWire);
+
+ // create the outbound wire and chain for the source service
+ OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+ outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ outboundChain.prepare();
+ outboundChain.setTargetInvoker(null);
+ EasyMock.expect(outboundChain.getOperation()).andReturn(operation);
+ EasyMock.replay(outboundChain);
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ outboundChains.put(operation, outboundChain);
+ OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+ outboundWire.getTargetCallbackInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
+ EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+
+ // create the service
+ Service service = EasyMock.createMock(Service.class);
+ EasyMock.expect(service.getName()).andReturn("source");
+ EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.expect(service.getParent()).andReturn(parent).atLeastOnce();
+ EasyMock.expect(service.getInboundWire()).andReturn(inboundWire).atLeastOnce();
+ EasyMock.expect(service.getScope()).andReturn(Scope.COMPOSITE);
+ EasyMock.expect(service.getOutboundWire()).andReturn(outboundWire);
+ EasyMock.replay(service);
+
+ EasyMock.expect(outboundWire.getContainer()).andReturn(service);
+ EasyMock.replay(outboundWire);
+
+ connector.connect(service);
+
+ EasyMock.verify(service);
+ EasyMock.verify(inboundWire);
+ EasyMock.verify(outboundWire);
+ EasyMock.verify(inboundChain);
+ EasyMock.verify(outboundChain);
+ }
+
+ /**
+ * Verifies connecting a wire from an atomic component to a target atomic component with one synchronous operation
+ */
+ public void testConnectAtomicComponentToAtomicComponentSyncWire() throws Exception {
+
+ // create the inbound wire and chain
+ InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+ EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+ EasyMock.replay(inboundChain);
+ Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
+ inboundChains.put(operation, inboundChain);
+ InboundWire targetWire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
+ targetWire.getSourceCallbackInvocationChains("source");
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+
+ // create the target
+ AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(target.getScope()).andReturn(Scope.MODULE);
+ target.getInboundWire(EasyMock.eq("FooService"));
+ EasyMock.expectLastCall().andReturn(targetWire);
+ target.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation));
+ EasyMock.expectLastCall().andReturn(null);
+ EasyMock.replay(target);
+
+ EasyMock.expect(targetWire.getContainer()).andReturn(target);
+ EasyMock.replay(targetWire);
+
+ // create the parent composite
+ CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
+ EasyMock.expect(parent.getChild("target")).andReturn(target);
+ EasyMock.replay(parent);
+
+ // create the outbound wire and chain from the source component
+ OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
+ outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ outboundChain.setTargetInvoker(null);
+ outboundChain.prepare();
+ EasyMock.replay(outboundChain);
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ outboundChains.put(operation, outboundChain);
+ OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+ EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
+ EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+ outboundWire.getTargetCallbackInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+
+ Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
+ List<OutboundWire> list = new ArrayList<OutboundWire>();
+ list.add(outboundWire);
+ outboundWires.put("fooService", list);
+
+ // create the source
+ AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.expect(source.getScope()).andReturn(Scope.MODULE);
+ EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
+ EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires);
+ EasyMock.expect(source.getName()).andReturn("source");
+ source.getInboundWires();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ EasyMock.replay(source);
+
+ EasyMock.expect(outboundWire.getContainer()).andReturn(source);
+ EasyMock.replay(outboundWire);
+
+ connector.connect(source);
+ EasyMock.verify(outboundWire);
+ EasyMock.verify(targetWire);
+ EasyMock.verify(outboundChain);
+ EasyMock.verify(inboundChain);
+ EasyMock.verify(source);
+ EasyMock.verify(target);
+ }
+
+ public void testConnectInboundAtomicComponentWires() {
+ // create the inbound wire and chain
+ InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(chain.getOperation()).andReturn(operation).atLeastOnce();
+ chain.setTargetInvoker(null);
+ chain.prepare();
+ EasyMock.replay(chain);
+ Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
+ inboundChains.put(operation, chain);
+ InboundWire wire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(wire.getServiceName()).andReturn("FooService");
+ EasyMock.expect(wire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(wire.getInvocationChains()).andReturn(inboundChains);
+ EasyMock.replay(wire);
+
+ Map<String, InboundWire> wires = new HashMap<String, InboundWire>();
+ wires.put("FooService", wire);
+
+ AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(source.getParent()).andReturn(null);
+ source.getOutboundWires();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ source.getInboundWires();
+ EasyMock.expectLastCall().andReturn(wires);
+ source.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation));
+ EasyMock.expectLastCall().andReturn(null);
+ EasyMock.replay(source);
+
+ connector.connect(source);
+
+ EasyMock.verify(source);
+ EasyMock.verify(wire);
+ EasyMock.verify(chain);
+ }
+
+ public void testOutboundToInboundOptimization() {
+ InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(inboundWire.getContainer()).andReturn(null);
+ inboundWire.getInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ EasyMock.replay(inboundWire);
+
+ OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+ outboundWire.getInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ outboundWire.setTargetWire(inboundWire);
+ EasyMock.expect(outboundWire.getContainer()).andReturn(null);
+ EasyMock.expect(outboundWire.getServiceContract()).andReturn(null);
+ EasyMock.replay(outboundWire);
+
+ connector.connect(outboundWire, inboundWire, true);
+ EasyMock.verify(inboundWire);
+ EasyMock.verify(outboundWire);
+ }
+
+ public void testOutboundToInboundChainConnect() {
+
+ TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.replay(invoker);
+
+ InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+ EasyMock.replay(inboundChain);
+
+ OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+ outboundChain.prepare();
+ outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ outboundChain.setTargetInvoker(invoker);
+ EasyMock.replay(outboundChain);
+ connector.connect(outboundChain, inboundChain, invoker, false);
+ EasyMock.verify(outboundChain);
+ }
+
+ public void testInboundToOutboundChainConnect() {
+ InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+ inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ EasyMock.replay(inboundChain);
+
+ OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+ outboundChain.prepare();
+ outboundChain.setTargetInterceptor(headInterceptor);
+ EasyMock.replay(outboundChain);
+ connector.connect(inboundChain, outboundChain);
+ EasyMock.verify(inboundChain);
+ }
+
+ public void testOutboundWireToInboundReferenceTarget() {
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("foo");
+ EasyMock.replay(component);
+ // create the inbound wire and chain
+ InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+ EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+ EasyMock.replay(inboundChain);
+ Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
+ inboundChains.put(operation, inboundChain);
+ InboundWire targetWire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
+ targetWire.getSourceCallbackInvocationChains("foo");
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ Reference target = EasyMock.createMock(Reference.class);
+ EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), EasyMock.isA(Operation.class)))
+ .andReturn(null);
+ EasyMock.replay(target);
+
+ EasyMock.expect(targetWire.getContainer()).andReturn(target);
+ EasyMock.replay(targetWire);
+
+ // create the outbound wire and chain from the source component
+ OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
+ outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
+ outboundChain.setTargetInvoker(null);
+ outboundChain.prepare();
+ EasyMock.replay(outboundChain);
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ outboundChains.put(operation, outboundChain);
+ OutboundWire sourceWire = EasyMock.createMock(OutboundWire.class);
+ EasyMock.expect(sourceWire.getContainer()).andReturn(component);
+ EasyMock.expect(sourceWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.expect(sourceWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
+ EasyMock.expect(sourceWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+ sourceWire.getTargetCallbackInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ EasyMock.replay(sourceWire);
+
+ connector.connect(sourceWire, targetWire, false);
+ EasyMock.verify(inboundChain);
+ EasyMock.verify(targetWire);
+ EasyMock.verify(target);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ connector = new ConnectorImpl();
+ contract = new JavaServiceContract(String.class);
+ operation = new Operation<Type>("bar", null, null, null);
+ headInterceptor = EasyMock.createMock(Interceptor.class);
+ EasyMock.replay(headInterceptor);
+ tailInterceptor = EasyMock.createMock(Interceptor.class);
+ EasyMock.replay(tailInterceptor);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
new file mode 100644
index 0000000000..366a4a57b2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectorPostProcessTestCase extends TestCase {
+
+ public void testInboundToOutboundPostProcessCalled() throws Exception {
+ OutboundWire owire = createNiceMock(OutboundWire.class);
+ replay(owire);
+ InboundWire iwire = createNiceMock(InboundWire.class);
+ Map<Operation<?>, InboundInvocationChain> chains = new HashMap<Operation<?>, InboundInvocationChain>();
+ expect(iwire.getInvocationChains()).andReturn(chains);
+ replay(iwire);
+ WirePostProcessorRegistry registry = createMock(WirePostProcessorRegistry.class);
+ registry.process(EasyMock.eq(iwire), EasyMock.eq(owire));
+ replay(registry);
+ WireService wireService = createMock(WireService.class);
+ wireService.checkCompatibility((ServiceContract<?>) EasyMock.anyObject(),
+ (ServiceContract<?>) EasyMock.anyObject(), EasyMock.eq(false));
+ expectLastCall().anyTimes();
+ replay(wireService);
+ ConnectorImpl connector = new ConnectorImpl(wireService, registry, null, null);
+ connector.connect(iwire, owire, false);
+ verify(registry);
+ }
+
+ public void testOutboundToInboundPostProcessCalled() throws Exception {
+ Component source = createNiceMock(Component.class);
+ expect(source.getName()).andReturn("Component");
+ replay(source);
+
+ OutboundWire owire = createNiceMock(OutboundWire.class);
+ EasyMock.expect(owire.getContainer()).andReturn(source);
+
+ Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ expect(owire.getInvocationChains()).andReturn(chains);
+ Map<Operation<?>, InboundInvocationChain> ichains = new HashMap<Operation<?>, InboundInvocationChain>();
+ expect(owire.getTargetCallbackInvocationChains()).andReturn(ichains);
+ replay(owire);
+ InboundWire iwire = createNiceMock(InboundWire.class);
+ expect(iwire.getSourceCallbackInvocationChains("Component")).andReturn(chains);
+ replay(iwire);
+ WirePostProcessorRegistry registry = createMock(WirePostProcessorRegistry.class);
+ registry.process(EasyMock.eq(owire), EasyMock.eq(iwire));
+ replay(registry);
+ WireService wireService = createMock(WireService.class);
+ wireService.checkCompatibility((ServiceContract<?>) EasyMock.anyObject(),
+ (ServiceContract<?>) EasyMock.anyObject(), EasyMock.eq(false));
+ expectLastCall().anyTimes();
+ replay(wireService);
+ ConnectorImpl connector = new ConnectorImpl(wireService, registry, null, null);
+
+ connector.connect(owire, iwire, false);
+ verify(registry);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java
new file mode 100644
index 0000000000..c12bca58ea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Verifies connection strategies between {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}s and {@link
+ * org.apache.tuscany.spi.wire.InboundInvocationChain}s
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class InboundtoOutboundConnectTestCase extends TestCase {
+ private Operation operation;
+
+ public void testNoInterceptorsNoHandlers() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ InboundInvocationChain inboundChain = setupInbound(null);
+ OutboundInvocationChain outboundChain = setupOutbound(null);
+ String[] val = new String[]{"foo"};
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invokeTarget(EasyMock.eq(val))).andReturn(val);
+ replay(invoker);
+ connector.connect(inboundChain, outboundChain);
+ inboundChain.setTargetInvoker(invoker);
+ inboundChain.prepare();
+ inboundChain.getTargetInvoker().invokeTarget(val);
+ verify(invoker);
+ }
+
+
+ /**
+ * Verifies an invocation with a single source interceptor
+ */
+ public void testSourceInterceptor() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ List<Interceptor> interceptors = new ArrayList<Interceptor>();
+ interceptors.add(interceptor);
+
+ InboundInvocationChain inboundChain = setupInbound(interceptors);
+ OutboundInvocationChain outboundChain = setupOutbound(null);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ replay(invoker);
+ assertEquals(0, interceptor.getCount());
+ connector.connect(inboundChain, outboundChain);
+ inboundChain.setTargetInvoker(invoker);
+ inboundChain.prepare();
+ msg.setTargetInvoker(inboundChain.getTargetInvoker());
+ assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
+ assertEquals(1, interceptor.getCount());
+ verify(invoker);
+ }
+
+ /**
+ * Verifies an invocation with a single target interceptor
+ */
+ public void testTargetInterceptor() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ List<Interceptor> interceptors = new ArrayList<Interceptor>();
+ interceptors.add(interceptor);
+
+ InboundInvocationChain inboundChain = setupInbound(interceptors);
+ OutboundInvocationChain outboundChain = setupOutbound(null);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ replay(invoker);
+ assertEquals(0, interceptor.getCount());
+ connector.connect(inboundChain, outboundChain);
+ inboundChain.setTargetInvoker(invoker);
+ inboundChain.prepare();
+ msg.setTargetInvoker(inboundChain.getTargetInvoker());
+ assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
+ assertEquals(1, interceptor.getCount());
+ verify(invoker);
+ }
+
+ /**
+ * Verifies an invocation with a source and target interceptor
+ */
+ public void testSourceTargetInterceptor() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ List<Interceptor> sourceInterceptors = new ArrayList<Interceptor>();
+ sourceInterceptors.add(sourceInterceptor);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ List<Interceptor> targetInterceptors = new ArrayList<Interceptor>();
+ targetInterceptors.add(targetInterceptor);
+
+ OutboundInvocationChain outboundChain = setupOutbound(sourceInterceptors);
+ InboundInvocationChain inboundChain = setupInbound(targetInterceptors);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ replay(invoker);
+ assertEquals(0, sourceInterceptor.getCount());
+ assertEquals(0, targetInterceptor.getCount());
+ connector.connect(inboundChain, outboundChain);
+ inboundChain.setTargetInvoker(invoker);
+ inboundChain.prepare();
+ msg.setTargetInvoker(inboundChain.getTargetInvoker());
+ assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
+ assertEquals(1, sourceInterceptor.getCount());
+ assertEquals(1, targetInterceptor.getCount());
+ verify(invoker);
+ }
+
+ public InboundInvocationChain setupInbound(List<Interceptor> interceptors) {
+
+ InboundInvocationChainImpl chain = new InboundInvocationChainImpl(operation);
+ if (interceptors != null) {
+ for (Interceptor interceptor : interceptors) {
+ chain.addInterceptor(interceptor);
+ }
+ }
+ return chain;
+ }
+
+ public OutboundInvocationChain setupOutbound(List<Interceptor> interceptors) {
+
+ OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(operation);
+ if (interceptors != null) {
+ for (Interceptor interceptor : interceptors) {
+ chain.addInterceptor(interceptor);
+ }
+ }
+ chain.addInterceptor(new InvokerInterceptor()); // add tail interceptor
+ return chain;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+ operation = contract.getOperations().get("echo");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
new file mode 100644
index 0000000000..009eba0fbd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Verifies connection strategies between {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}s and {@link
+ * org.apache.tuscany.spi.wire.InboundInvocationChain}s
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class OutboundToInboundConnectTestCase extends TestCase {
+
+ public void testNoInterceptorsNoHandlers() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ InboundInvocationChain inboundChain = setupTarget(null);
+ OutboundInvocationChain outboundChain = setupSource(null);
+ String[] val = new String[]{"foo"};
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invokeTarget(EasyMock.eq(val))).andReturn(val);
+ replay(invoker);
+ connector.connect(outboundChain, inboundChain, invoker, false);
+ inboundChain.prepare();
+ assertEquals(val, outboundChain.getTargetInvoker().invokeTarget(val));
+ verify(invoker);
+ }
+
+
+ /**
+ * Verifies an invocation with a single source interceptor
+ */
+ public void testSourceInterceptor() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ List<Interceptor> interceptors = new ArrayList<Interceptor>();
+ interceptors.add(interceptor);
+ OutboundInvocationChain outboundChain = setupSource(interceptors);
+ InboundInvocationChain inboundChain = setupTarget(null);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ replay(invoker);
+ assertEquals(0, interceptor.getCount());
+ connector.connect(outboundChain, inboundChain, invoker, false);
+ inboundChain.prepare();
+ msg.setTargetInvoker(outboundChain.getTargetInvoker());
+ assertEquals(msg, outboundChain.getHeadInterceptor().invoke(msg));
+ assertEquals(1, interceptor.getCount());
+ verify(invoker);
+ }
+
+ /**
+ * Verifies an invocation with a single target interceptor
+ */
+ public void testTargetInterceptor() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ List<Interceptor> interceptors = new ArrayList<Interceptor>();
+ interceptors.add(interceptor);
+ OutboundInvocationChain outboundChain = setupSource(null);
+ InboundInvocationChain inboundChain = setupTarget(interceptors);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ replay(invoker);
+ assertEquals(0, interceptor.getCount());
+ connector.connect(outboundChain, inboundChain, invoker, false);
+ inboundChain.prepare();
+ msg.setTargetInvoker(outboundChain.getTargetInvoker());
+ assertEquals(msg, outboundChain.getHeadInterceptor().invoke(msg));
+ assertEquals(1, interceptor.getCount());
+ verify(invoker);
+ }
+
+ /**
+ * Verifies an invocation with a source and target interceptor
+ */
+ public void testSourceTargetInterceptor() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ List<Interceptor> sourceInterceptors = new ArrayList<Interceptor>();
+ sourceInterceptors.add(sourceInterceptor);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ List<Interceptor> targetInterceptors = new ArrayList<Interceptor>();
+ targetInterceptors.add(targetInterceptor);
+ OutboundInvocationChain outboundChain = setupSource(sourceInterceptors);
+ InboundInvocationChain inboundChain = setupTarget(targetInterceptors);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = createNiceMock(TargetInvoker.class);
+ expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ replay(invoker);
+ assertEquals(0, sourceInterceptor.getCount());
+ assertEquals(0, targetInterceptor.getCount());
+ connector.connect(outboundChain, inboundChain, invoker, false);
+ inboundChain.prepare();
+ msg.setTargetInvoker(outboundChain.getTargetInvoker());
+ assertEquals(msg, outboundChain.getHeadInterceptor().invoke(msg));
+ assertEquals(1, sourceInterceptor.getCount());
+ assertEquals(1, targetInterceptor.getCount());
+ verify(invoker);
+ }
+
+
+ public InboundInvocationChain setupTarget(List<Interceptor> interceptors) {
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+ Operation operation = contract.getOperations().get("echo");
+ InboundInvocationChainImpl chain = new InboundInvocationChainImpl(operation);
+ if (interceptors != null) {
+ for (Interceptor interceptor : interceptors) {
+ chain.addInterceptor(interceptor);
+ }
+ }
+ chain.addInterceptor(new InvokerInterceptor()); // add tail interceptor
+ return chain;
+ }
+
+ public OutboundInvocationChain setupSource(List<Interceptor> interceptors) {
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+ Operation operation = contract.getOperations().get("echo");
+ OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(operation);
+ if (interceptors != null) {
+ for (Interceptor interceptor : interceptors) {
+ chain.addInterceptor(interceptor);
+ }
+ }
+ return chain;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
new file mode 100644
index 0000000000..3e0e5c7bce
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.spi.builder.WirePostProcessor;
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WirePostProcessorRegistryImplTestCase extends TestCase {
+
+ public void testRegisterUnregister() throws Exception {
+ WirePostProcessorRegistry registry = new WirePostProcessorRegistryImpl();
+ OutboundWire owire = EasyMock.createMock(OutboundWire.class);
+ InboundWire iwire = EasyMock.createMock(InboundWire.class);
+ WirePostProcessor processor = createMock(WirePostProcessor.class);
+ processor.process(EasyMock.eq(owire), EasyMock.eq(iwire));
+ EasyMock.replay(processor);
+ registry.register(processor);
+ registry.process(owire, iwire);
+ registry.unregister(processor);
+ registry.process(owire, iwire);
+ verify(processor);
+ }
+
+ public void testProcessInboundToOutbound() throws Exception {
+ WirePostProcessorRegistry registry = new WirePostProcessorRegistryImpl();
+ OutboundWire owire = EasyMock.createMock(OutboundWire.class);
+ InboundWire iwire = EasyMock.createMock(InboundWire.class);
+ WirePostProcessor processor = createMock(WirePostProcessor.class);
+ processor.process(EasyMock.eq(iwire), EasyMock.eq(owire));
+ EasyMock.replay(processor);
+ registry.register(processor);
+ registry.process(iwire, owire);
+ verify(processor);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java
new file mode 100644
index 0000000000..79b9757c2c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.event;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EventTestCase extends TestCase {
+
+ private CompositeComponent component;
+
+ public void testCompositeStart() {
+ CompositeStart event = new CompositeStart(this, component);
+ assertEquals(component, event.getComposite());
+ }
+
+ public void testCompositeStop() {
+ CompositeStop event = new CompositeStop(this, component);
+ assertEquals(component, event.getComposite());
+ }
+
+ public void testHttpSessionStart() {
+ Object id = new Object();
+ HttpSessionEvent event = new HttpSessionStart(this, id);
+ assertEquals(this, event.getSource());
+ assertEquals(id, event.getId());
+ }
+
+ public void testHttpSessionEnd() {
+ Object id = new Object();
+ HttpSessionEvent event = new HttpSessionEnd(this, id);
+ assertEquals(this, event.getSource());
+ assertEquals(id, event.getId());
+ }
+
+ public void testRequestStart() {
+ RequestStart event = new RequestStart(this);
+ assertEquals(this, event.getSource());
+ }
+
+ public void testReequestEnd() {
+ RequestEnd event = new RequestEnd(this);
+ assertEquals(this, event.getSource());
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ component = EasyMock.createNiceMock(CompositeComponent.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java
new file mode 100644
index 0000000000..a99dbf072a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.TrueFilter;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractScopeContainerTestCase extends TestCase {
+
+ public void testSetWorkContext() {
+ TestContainer container = new TestContainer("foo");
+ WorkContext ctx = new WorkContextImpl();
+ container.setWorkContext(ctx);
+ assertEquals(ctx, container.getWorkContext());
+
+ }
+
+ public void testFireListener() {
+ TestContainer container = new TestContainer("foo");
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ Event event = new TestEvent();
+ listener.onEvent(EasyMock.eq(event));
+ EasyMock.replay(listener);
+ container.addListener(listener);
+ container.publish(event);
+ EasyMock.verify(listener);
+ }
+
+ public void testRemoveListener() {
+ TestContainer container = new TestContainer("foo");
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ EasyMock.replay(listener);
+ Event event = new TestEvent();
+ container.addListener(listener);
+ container.removeListener(listener);
+ container.publish(event);
+ EasyMock.verify(listener);
+ }
+
+ public void testFalseFilterListener() {
+ TestContainer container = new TestContainer("foo");
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ Event event = new TestEvent();
+ EasyMock.replay(listener);
+ container.addListener(new FalseFilter(), listener);
+ container.publish(event);
+ EasyMock.verify(listener);
+ }
+
+ public void testTrueFilterListener() {
+ TestContainer container = new TestContainer("foo");
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ Event event = new TestEvent();
+ listener.onEvent(EasyMock.eq(event));
+ EasyMock.replay(listener);
+ container.addListener(new TrueFilter(), listener);
+ container.publish(event);
+ EasyMock.verify(listener);
+ }
+
+ public void testToString() {
+ TestContainer container = new TestContainer("foo");
+ assertNotNull(container.toString());
+ }
+
+ public void testGetName() {
+ TestContainer container = new TestContainer("foo");
+ assertEquals("foo", container.getName());
+ }
+
+
+ private class TestContainer extends AbstractScopeContainer {
+
+ public TestContainer(String name) {
+ super(name, null);
+ }
+
+ protected InstanceWrapper getInstanceWrapper(AtomicComponent component) {
+ return null;
+ }
+
+ public Scope getScope() {
+ return null;
+ }
+
+ public void register(AtomicComponent component) {
+
+ }
+
+ public void onEvent(Event event) {
+
+ }
+
+ public WorkContext getWorkContext() {
+ return super.getWorkContext();
+ }
+ }
+
+ private class TestEvent implements Event {
+ public Object getSource() {
+ return null;
+ }
+ }
+
+ private class FalseFilter implements EventFilter {
+
+ public boolean match(Event event) {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java
new file mode 100644
index 0000000000..dc8da77490
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.mock.component.SessionScopeInitDestroyComponent;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class BasicHttpSessionScopeTestCase extends TestCase {
+
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+ private PojoObjectFactory<?> factory;
+
+ public void testLifecycleManagement() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ HttpSessionScopeContainer scopeContext = new HttpSessionScopeContainer(workContext);
+ scopeContext.start();
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+ // start the request
+ Object session = new Object();
+ workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ SessionScopeInitDestroyComponent o1 =
+ (SessionScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ assertFalse(o1.isDestroyed());
+ SessionScopeInitDestroyComponent o2 =
+ (SessionScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertSame(o1, o2);
+ scopeContext.onEvent(new HttpSessionEnd(this, session));
+ assertTrue(o1.isDestroyed());
+ scopeContext.stop();
+ }
+
+ public void testSessionIsolation() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ HttpSessionScopeContainer scopeContext = new HttpSessionScopeContainer(workContext);
+ scopeContext.start();
+
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+
+ Object session1 = new Object();
+ workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ SessionScopeInitDestroyComponent o1 =
+ (SessionScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+
+ Object session2 = new Object();
+ workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ SessionScopeInitDestroyComponent o2 =
+ (SessionScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertNotSame(o1, o2);
+
+ scopeContext.onEvent(new HttpSessionEnd(this, session1));
+ assertTrue(o1.isDestroyed());
+ assertFalse(o2.isDestroyed());
+ scopeContext.onEvent(new HttpSessionEnd(this, session2));
+ assertTrue(o2.isDestroyed());
+ scopeContext.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new PojoObjectFactory<SessionScopeInitDestroyComponent>(
+ SessionScopeInitDestroyComponent.class.getConstructor((Class[]) null));
+ initInvoker = new MethodEventInvoker<Object>(
+ SessionScopeInitDestroyComponent.class.getMethod("init", (Class[]) null));
+ destroyInvoker = new MethodEventInvoker<Object>(
+ SessionScopeInitDestroyComponent.class.getMethod("destroy", (Class[]) null));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private SystemAtomicComponent createContext(ScopeContainer scopeContainer) {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scopeContainer);
+ configuration.addServiceInterface(SessionScopeInitDestroyComponent.class);
+ configuration.setInstanceFactory(factory);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ SystemAtomicComponentImpl context = new SystemAtomicComponentImpl("foo", configuration);
+ context.start();
+ return context;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicModuleScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicModuleScopeTestCase.java
new file mode 100644
index 0000000000..a4db2aef85
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicModuleScopeTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.mock.component.ModuleScopeInitDestroyComponent;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class BasicModuleScopeTestCase extends TestCase {
+
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+ private PojoObjectFactory<?> factory;
+
+ public void testLifecycleManagement() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ModuleScopeContainer scopeContext = new ModuleScopeContainer(workContext);
+ scopeContext.start();
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+ // start the request
+ ModuleScopeInitDestroyComponent o1 =
+ (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ assertFalse(o1.isDestroyed());
+ ModuleScopeInitDestroyComponent o2 =
+ (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertEquals(o1, o2);
+ scopeContext.onEvent(new CompositeStop(this, null));
+ assertTrue(o1.isDestroyed());
+ scopeContext.stop();
+ }
+
+ public void testModuleIsolation() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ModuleScopeContainer scopeContext = new ModuleScopeContainer(workContext);
+ scopeContext.start();
+
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+
+ ModuleScopeInitDestroyComponent o1 =
+ (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ assertFalse(o1.isDestroyed());
+
+ ModuleScopeInitDestroyComponent o2 =
+ (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertSame(o1, o2);
+ scopeContext.onEvent(new CompositeStop(this, null));
+ assertTrue(o1.isDestroyed());
+ scopeContext.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new PojoObjectFactory<ModuleScopeInitDestroyComponent>(
+ ModuleScopeInitDestroyComponent.class.getConstructor((Class[]) null));
+ initInvoker = new MethodEventInvoker<Object>(ModuleScopeInitDestroyComponent.class.getMethod(
+ "init", (Class[]) null));
+ destroyInvoker = new MethodEventInvoker<Object>(ModuleScopeInitDestroyComponent.class.getMethod(
+ "destroy", (Class[]) null));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private SystemAtomicComponent createContext(ScopeContainer scopeContainer) {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scopeContainer);
+ configuration.addServiceInterface(ModuleScopeInitDestroyComponent.class);
+ configuration.setInstanceFactory(factory);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ SystemAtomicComponentImpl context = new SystemAtomicComponentImpl("foo", configuration);
+ context.start();
+ return context;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java
new file mode 100644
index 0000000000..cb6a7c1673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.mock.component.RequestScopeInitDestroyComponent;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class BasicRequestScopeTestCase extends TestCase {
+
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+ private PojoObjectFactory<?> factory;
+
+ public void testLifecycleManagement() throws Exception {
+ RequestScopeContainer scopeContext = new RequestScopeContainer(null);
+ scopeContext.start();
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+ // start the request
+ RequestScopeInitDestroyComponent o1 =
+ (RequestScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ assertFalse(o1.isDestroyed());
+ RequestScopeInitDestroyComponent o2 =
+ (RequestScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertSame(o1, o2);
+ scopeContext.onEvent(new RequestEnd(this));
+ assertTrue(o1.isDestroyed());
+ scopeContext.stop();
+ }
+
+ public void testRequestIsolation() throws Exception {
+ RequestScopeContainer scopeContext = new RequestScopeContainer(null);
+ scopeContext.start();
+
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+
+ RequestScopeInitDestroyComponent o1 =
+ (RequestScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ scopeContext.onEvent(new RequestEnd(this));
+ assertTrue(o1.isDestroyed());
+
+ RequestScopeInitDestroyComponent o2 =
+ (RequestScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertNotSame(o1, o2);
+ scopeContext.onEvent(new RequestEnd(this));
+ assertTrue(o2.isDestroyed());
+ scopeContext.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new PojoObjectFactory<RequestScopeInitDestroyComponent>(
+ RequestScopeInitDestroyComponent.class.getConstructor((Class[]) null));
+ initInvoker = new MethodEventInvoker<Object>(
+ RequestScopeInitDestroyComponent.class.getMethod("init", (Class[]) null));
+ destroyInvoker = new MethodEventInvoker<Object>(
+ RequestScopeInitDestroyComponent.class.getMethod("destroy", (Class[]) null));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private SystemAtomicComponent createContext(ScopeContainer scopeContainer) {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scopeContainer);
+ configuration.addServiceInterface(RequestScopeInitDestroyComponent.class);
+ configuration.setInstanceFactory(factory);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ SystemAtomicComponentImpl component = new SystemAtomicComponentImpl("foo", configuration);
+ scopeContainer.register(component);
+ return component;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java
new file mode 100644
index 0000000000..a38abdc390
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.mock.component.StatelessComponent;
+import org.apache.tuscany.core.mock.component.StatelessComponentImpl;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+
+/**
+ * Unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicStatelessScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ StatelessScopeContainer scope = new StatelessScopeContainer(ctx);
+ scope.start();
+ SystemAtomicComponent context1 =
+ MockFactory.createAtomicComponent("comp1", scope, StatelessComponentImpl.class);
+ scope.register(context1);
+ SystemAtomicComponent context2 =
+ MockFactory.createAtomicComponent("comp2", scope, StatelessComponentImpl.class);
+ scope.register(context2);
+ StatelessComponentImpl comp1 = (StatelessComponentImpl) scope.getInstance(context1);
+ Assert.assertNotNull(comp1);
+ StatelessComponentImpl comp2 = (StatelessComponentImpl) scope.getInstance(context2);
+ Assert.assertNotNull(comp2);
+ Assert.assertNotSame(comp1, comp2);
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterRequest() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ StatelessScopeContainer scope = new StatelessScopeContainer(ctx);
+
+ scope.start();
+ SystemAtomicComponent context1 =
+ MockFactory.createAtomicComponent("comp1", scope, StatelessComponentImpl.class);
+ scope.register(context1);
+ StatelessComponent comp1 = (StatelessComponentImpl) scope.getInstance(context1);
+ Assert.assertNotNull(comp1);
+ SystemAtomicComponent context2 =
+ MockFactory.createAtomicComponent("comp2", scope, StatelessComponentImpl.class);
+ scope.register(context2);
+ StatelessComponentImpl comp2 = (StatelessComponentImpl) scope.getInstance(context2);
+ Assert.assertNotNull(comp2);
+ scope.stop();
+ }
+
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ StatelessScopeContainer scope = new StatelessScopeContainer(ctx);
+ scope.start();
+ scope.stop();
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java
new file mode 100644
index 0000000000..ec23914acc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.mock.component.OrderedDependentPojo;
+import org.apache.tuscany.core.mock.component.OrderedDependentPojoImpl;
+import org.apache.tuscany.core.mock.component.OrderedInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+
+/**
+ * Tests dependencies are initalized and destroyed in the proper order (i.e. LIFO)
+ *
+ * @version $Rev$ $Date$
+ */
+public class DependencyLifecycleTestCase extends TestCase {
+
+ public void testInitDestroyOrderModuleScope() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ModuleScopeContainer scopeCtx = new ModuleScopeContainer(ctx);
+ scopeCtx.start();
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source",
+ OrderedDependentPojoImpl.class,
+ scopeCtx,
+ "target",
+ OrderedInitPojoImpl.class,
+ scopeCtx);
+ for (AtomicComponent component : contexts.values()) {
+ scopeCtx.register(component);
+ }
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ scopeCtx.register(sourceComponent);
+ scopeCtx.register(targetComponent);
+ scopeCtx.onEvent(new CompositeStart(this, null));
+ OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
+ OrderedInitPojo target = (OrderedInitPojo) scopeCtx.getInstance(targetComponent);
+ assertNotNull(source.getPojo());
+ assertNotNull(target);
+ assertEquals(2, source.getNumberInstantiated());
+ scopeCtx.onEvent(new CompositeStop(this, null));
+ assertEquals(0, source.getNumberInstantiated());
+ scopeCtx.stop();
+ }
+
+ public void testInitDestroyOrderAfterStartModuleScope() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ModuleScopeContainer scopeCtx = new ModuleScopeContainer(ctx);
+ scopeCtx.start();
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source",
+ OrderedDependentPojoImpl.class,
+ scopeCtx,
+ "target",
+ OrderedInitPojoImpl.class,
+ scopeCtx);
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ scopeCtx.onEvent(new CompositeStart(this, null));
+ scopeCtx.register(sourceComponent);
+ scopeCtx.register(targetComponent);
+ OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
+ OrderedInitPojo target = (OrderedInitPojo) scopeCtx.getInstance(targetComponent);
+ assertNotNull(source.getPojo());
+ assertNotNull(target);
+ assertEquals(2, source.getNumberInstantiated());
+ scopeCtx.onEvent(new CompositeStop(this, null));
+ assertEquals(0, source.getNumberInstantiated());
+ scopeCtx.stop();
+ }
+
+
+ public void testInitDestroyOrderSessionScope() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ HttpSessionScopeContainer scopeCtx = new HttpSessionScopeContainer(ctx);
+ scopeCtx.start();
+ Object session = new Object();
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source",
+ OrderedDependentPojoImpl.class,
+ scopeCtx,
+ "target",
+ OrderedInitPojoImpl.class,
+ scopeCtx);
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ scopeCtx.register(sourceComponent);
+ scopeCtx.register(targetComponent);
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
+ assertNotNull(source.getPojo());
+ assertEquals(2, source.getNumberInstantiated());
+ scopeCtx.onEvent(new HttpSessionEnd(this, session));
+ assertEquals(0, source.getNumberInstantiated());
+ scopeCtx.stop();
+ }
+
+
+ public void testInitDestroyOrderAfterStartSessionScope() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ HttpSessionScopeContainer scopeCtx = new HttpSessionScopeContainer(ctx);
+ scopeCtx.start();
+ Object session = new Object();
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source",
+ OrderedDependentPojoImpl.class,
+ scopeCtx,
+ "target",
+ OrderedInitPojoImpl.class,
+ scopeCtx);
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ scopeCtx.register(sourceComponent);
+ scopeCtx.register(targetComponent);
+ OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
+ assertNotNull(source.getPojo());
+ assertEquals(2, source.getNumberInstantiated());
+ scopeCtx.onEvent(new HttpSessionEnd(this, session));
+ assertEquals(0, source.getNumberInstantiated());
+ scopeCtx.stop();
+ }
+
+ public void testInitDestroyOrderRequestScope() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ RequestScopeContainer scopeCtx = new RequestScopeContainer(ctx);
+ scopeCtx.start();
+ scopeCtx.onEvent(new RequestStart(this));
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source",
+ OrderedDependentPojoImpl.class,
+ scopeCtx,
+ "target",
+ OrderedInitPojoImpl.class,
+ scopeCtx);
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ scopeCtx.register(sourceComponent);
+ scopeCtx.register(targetComponent);
+ OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
+ assertNotNull(source.getPojo());
+ assertEquals(2, source.getNumberInstantiated());
+ scopeCtx.onEvent(new RequestEnd(this));
+ assertEquals(0, source.getNumberInstantiated());
+ scopeCtx.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java
new file mode 100644
index 0000000000..4fe99e841c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.core.mock.component.OrderedEagerInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl;
+import org.apache.tuscany.core.mock.component.RequestScopeDestroyOnlyComponent;
+import org.apache.tuscany.core.mock.component.RequestScopeInitDestroyComponent;
+import org.apache.tuscany.core.mock.component.RequestScopeInitOnlyComponent;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+
+/**
+ * Lifecycle unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpSessionScopeInstanceLifecycleTestCase extends TestCase {
+
+ public void testInitDestroy() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent initDestroyContext = MockFactory.createAtomicComponent("InitDestroy",
+ scope,
+ RequestScopeInitDestroyComponent.class);
+ initDestroyContext.start();
+
+ SystemAtomicComponent initOnlyContext = MockFactory.createAtomicComponent("InitOnly",
+ scope,
+ RequestScopeInitOnlyComponent.class);
+ initOnlyContext.start();
+
+ SystemAtomicComponent destroyOnlyContext = MockFactory.createAtomicComponent("DestroyOnly",
+ scope,
+ RequestScopeDestroyOnlyComponent.class);
+ destroyOnlyContext.start();
+
+ Object session = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ scope.onEvent(new HttpSessionStart(this, session));
+ RequestScopeInitDestroyComponent initDestroy =
+ (RequestScopeInitDestroyComponent) scope.getInstance(initDestroyContext);
+ Assert.assertNotNull(initDestroy);
+
+ RequestScopeInitOnlyComponent initOnly =
+ (RequestScopeInitOnlyComponent) scope.getInstance(initOnlyContext);
+ Assert.assertNotNull(initOnly);
+
+ RequestScopeDestroyOnlyComponent destroyOnly =
+ (RequestScopeDestroyOnlyComponent) scope.getInstance(destroyOnlyContext);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // expire module
+ scope.onEvent(new HttpSessionEnd(this, session));
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ public void testDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx =
+ MockFactory.createAtomicComponent("one", scope, OrderedInitPojoImpl.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx =
+ MockFactory.createAtomicComponent("two", scope, OrderedInitPojoImpl.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx =
+ MockFactory.createAtomicComponent("three", scope, OrderedInitPojoImpl.class);
+ scope.register(threeCtx);
+
+ Object session = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ scope.onEvent(new HttpSessionStart(this, session));
+ OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // expire module
+ scope.onEvent(new HttpSessionEnd(this, session));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testEagerInitDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx =
+ MockFactory.createAtomicComponent("one", scope, OrderedEagerInitPojo.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx =
+ MockFactory.createAtomicComponent("two", scope, OrderedEagerInitPojo.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx =
+ MockFactory.createAtomicComponent("three", scope, OrderedEagerInitPojo.class);
+ scope.register(threeCtx);
+
+ Object session = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ scope.onEvent(new HttpSessionStart(this, session));
+ OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+
+ OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+
+ OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+
+ // expire module
+ scope.onEvent(new HttpSessionEnd(this, session));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java
new file mode 100644
index 0000000000..0c781cac85
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Verifies the scope container properly disposes resources and canbe restarted
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class HttpSessionScopeRestartTestCase extends TestCase {
+
+ public void testRestart() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx);
+ scope.start();
+ MethodEventInvoker<Object> initInvoker = new MethodEventInvoker<Object>(
+ HttpSessionScopeRestartTestCase.InitDestroyOnce.class.getMethod("init"));
+ MethodEventInvoker<Object> destroyInvoker =
+ new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("destroy"));
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.addServiceInterface(HttpSessionScopeRestartTestCase.InitDestroyOnce.class);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
+ configuration.setInstanceFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
+ SystemAtomicComponent context = new SystemAtomicComponentImpl("InitDestroy", configuration);
+ context.start();
+
+ Object session = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session);
+ scope.onEvent(new HttpSessionStart(this, session));
+ Object instance = context.getServiceInstance();
+ assertSame(instance, context.getServiceInstance());
+
+ scope.onEvent(new HttpSessionEnd(this, session));
+ scope.stop();
+ context.stop();
+
+ scope.start();
+ scope.onEvent(new HttpSessionStart(this, session));
+ context.start();
+ assertNotSame(instance, context.getServiceInstance());
+ scope.onEvent(new HttpSessionEnd(this, session));
+ scope.stop();
+ context.stop();
+ }
+
+ public static class InitDestroyOnce {
+
+ private boolean initialized;
+ private boolean destroyed;
+
+ public InitDestroyOnce() {
+ }
+
+ public void init() {
+ if (!initialized) {
+ initialized = true;
+ } else {
+ fail("Scope did not clean up properly - Init called more than once");
+ }
+ }
+
+ public void destroy() {
+ if (!destroyed) {
+ destroyed = true;
+ } else {
+ fail("Scope did not clean up properly - Destroyed called more than once");
+ }
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java
new file mode 100644
index 0000000000..5071196d5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.Lifecycle;
+import org.apache.tuscany.spi.component.AtomicComponent;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InstanceWrapperTestCase extends TestCase {
+
+
+ public void testExceptionInit() throws Exception {
+ AtomicComponent component = getComponent();
+ InstanceWrapper wrapper = new InstanceWrapperImpl(component, new Object());
+ try {
+ wrapper.start();
+ fail();
+ } catch (SomeException e) {
+ // expected
+ }
+ assertEquals(Lifecycle.ERROR, wrapper.getLifecycleState());
+ EasyMock.verify(component);
+ }
+
+ public void testNonStart() throws Exception {
+ AtomicComponent comp = EasyMock.createNiceMock(AtomicComponent.class); // class-level one has an expects
+ InstanceWrapper wrapper = new InstanceWrapperImpl(comp, new Object());
+ try {
+ wrapper.getInstance();
+ fail();
+ } catch (IllegalStateException e) {
+ // expected
+ }
+ }
+
+ private AtomicComponent getComponent() throws Exception {
+ // do not use setUp() since we do not need this in all testcases
+ AtomicComponent comp = EasyMock.createMock(AtomicComponent.class);
+ comp.init(EasyMock.isA(Object.class));
+ EasyMock.expectLastCall().andThrow(new SomeException());
+ EasyMock.replay(comp);
+ return comp;
+ }
+
+ private class SomeException extends RuntimeException {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeInstanceLifecycleTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeInstanceLifecycleTestCase.java
new file mode 100644
index 0000000000..fce04967fc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeInstanceLifecycleTestCase.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.mock.component.ModuleScopeDestroyOnlyComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.core.mock.component.OrderedEagerInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+
+/**
+ * Lifecycle unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeInstanceLifecycleTestCase extends TestCase {
+
+ public void testInitDestroy() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ModuleScopeContainer scope = new ModuleScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent initDestroyContext = MockFactory.createAtomicComponent("InitDestroy",
+ scope,
+ ModuleScopeInitDestroyComponent.class);
+ initDestroyContext.start();
+
+ SystemAtomicComponent initOnlyContext = MockFactory.createAtomicComponent("InitOnly",
+ scope,
+ ModuleScopeInitOnlyComponent.class);
+ initOnlyContext.start();
+
+ SystemAtomicComponent destroyOnlyContext = MockFactory.createAtomicComponent("DestroyOnly",
+ scope,
+ ModuleScopeDestroyOnlyComponent.class);
+ destroyOnlyContext.start();
+
+ scope.onEvent(new CompositeStart(this, null));
+ ModuleScopeInitDestroyComponent initDestroy =
+ (ModuleScopeInitDestroyComponent) scope.getInstance(initDestroyContext);
+ Assert.assertNotNull(initDestroy);
+
+ ModuleScopeInitOnlyComponent initOnly = (ModuleScopeInitOnlyComponent) scope.getInstance(initOnlyContext);
+ Assert.assertNotNull(initOnly);
+
+ ModuleScopeDestroyOnlyComponent destroyOnly =
+ (ModuleScopeDestroyOnlyComponent) scope.getInstance(destroyOnlyContext);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // expire module
+ scope.onEvent(new CompositeStop(this, null));
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ public void testDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ModuleScopeContainer scope = new ModuleScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx = MockFactory.createAtomicComponent("one",
+ scope,
+ OrderedInitPojoImpl.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx = MockFactory.createAtomicComponent("two",
+ scope,
+ OrderedInitPojoImpl.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx = MockFactory.createAtomicComponent("three",
+ scope,
+ OrderedInitPojoImpl.class);
+ scope.register(threeCtx);
+
+ scope.onEvent(new CompositeStart(this, null));
+ OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // expire module
+ scope.onEvent(new CompositeStop(this, null));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testEagerInitDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ModuleScopeContainer scope = new ModuleScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx = MockFactory.createAtomicComponent("one",
+ scope,
+ OrderedEagerInitPojo.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx = MockFactory.createAtomicComponent("two",
+ scope,
+ OrderedEagerInitPojo.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx = MockFactory.createAtomicComponent("three",
+ scope,
+ OrderedEagerInitPojo.class);
+ scope.register(threeCtx);
+
+ scope.onEvent(new CompositeStart(this, null));
+ OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+
+ OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+
+ OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+
+ // expire module
+ scope.onEvent(new CompositeStop(this, null));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactoryTestCase.java
new file mode 100644
index 0000000000..69ebc96d95
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeObjectFactoryTestCase.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeObjectFactoryTestCase extends TestCase {
+
+ public void testCreation() {
+ ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class);
+ registry.registerFactory(EasyMock.isA(Scope.class), EasyMock.isA(ModuleScopeObjectFactory.class));
+
+ assertNotNull(new ModuleScopeObjectFactory(registry).getInstance());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeRestartTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeRestartTestCase.java
new file mode 100644
index 0000000000..4c57b81953
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ModuleScopeRestartTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Verifies the scope container properly disposes resources and canbe restarted
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ModuleScopeRestartTestCase extends TestCase {
+
+ public void testRestart() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ModuleScopeContainer scope = new ModuleScopeContainer(ctx);
+ scope.start();
+ MethodEventInvoker<Object> initInvoker =
+ new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("init"));
+ MethodEventInvoker<Object> destroyInvoker =
+ new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("destroy"));
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.addServiceInterface(InitDestroyOnce.class);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
+ configuration.setInstanceFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
+ SystemAtomicComponent context = new SystemAtomicComponentImpl("InitDestroy", configuration);
+ context.start();
+
+ scope.onEvent(new CompositeStart(this, null));
+ Object instance = context.getServiceInstance();
+ assertSame(instance, context.getServiceInstance());
+
+ scope.onEvent(new CompositeStop(this, null));
+ scope.stop();
+ context.stop();
+
+ scope.start();
+ scope.onEvent(new CompositeStart(this, null));
+ context.start();
+ assertNotSame(instance, context.getServiceInstance());
+ scope.onEvent(new CompositeStop(this, null));
+ scope.stop();
+ context.stop();
+ }
+
+ public static class InitDestroyOnce {
+
+ private boolean initialized;
+ private boolean destroyed;
+
+ public InitDestroyOnce() {
+ }
+
+ public void init() {
+ if (!initialized) {
+ initialized = true;
+ } else {
+ fail("Scope did not clean up properly - Init called more than once");
+ }
+ }
+
+ public void destroy() {
+ if (!destroyed) {
+ destroyed = true;
+ } else {
+ fail("Scope did not clean up properly - Destroyed called more than once");
+ }
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java
new file mode 100644
index 0000000000..52f27ee869
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.mock.component.OrderedEagerInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl;
+import org.apache.tuscany.core.mock.component.RequestScopeDestroyOnlyComponent;
+import org.apache.tuscany.core.mock.component.RequestScopeInitDestroyComponent;
+import org.apache.tuscany.core.mock.component.RequestScopeInitOnlyComponent;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+
+/**
+ * Lifecycle unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeInstanceLifecycleTestCase extends TestCase {
+
+ public void testInitDestroy() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ RequestScopeContainer scope = new RequestScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent initDestroyContext = MockFactory
+ .createAtomicComponent("InitDestroy", scope, RequestScopeInitDestroyComponent.class);
+ initDestroyContext.start();
+
+ SystemAtomicComponent initOnlyContext =
+ MockFactory.createAtomicComponent("InitOnly", scope, RequestScopeInitOnlyComponent.class);
+ initOnlyContext.start();
+
+ SystemAtomicComponent destroyOnlyContext = MockFactory
+ .createAtomicComponent("DestroyOnly", scope, RequestScopeDestroyOnlyComponent.class);
+ destroyOnlyContext.start();
+
+ scope.onEvent(new RequestStart(this));
+ RequestScopeInitDestroyComponent initDestroy =
+ (RequestScopeInitDestroyComponent) scope.getInstance(initDestroyContext);
+ Assert.assertNotNull(initDestroy);
+
+ RequestScopeInitOnlyComponent initOnly = (RequestScopeInitOnlyComponent) scope.getInstance(initOnlyContext);
+ Assert.assertNotNull(initOnly);
+
+ RequestScopeDestroyOnlyComponent destroyOnly =
+ (RequestScopeDestroyOnlyComponent) scope.getInstance(destroyOnlyContext);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // expire module
+ scope.onEvent(new RequestEnd(this));
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ public void testDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ RequestScopeContainer scope = new RequestScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx =
+ MockFactory.createAtomicComponent("one", scope, OrderedInitPojoImpl.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx =
+ MockFactory.createAtomicComponent("two", scope, OrderedInitPojoImpl.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx =
+ MockFactory.createAtomicComponent("three", scope, OrderedInitPojoImpl.class);
+ scope.register(threeCtx);
+
+ scope.onEvent(new RequestStart(this));
+ OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // expire module
+ scope.onEvent(new RequestEnd(this));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testEagerInitDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ RequestScopeContainer scope = new RequestScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx =
+ MockFactory.createAtomicComponent("one", scope, OrderedEagerInitPojo.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx =
+ MockFactory.createAtomicComponent("two", scope, OrderedEagerInitPojo.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx =
+ MockFactory.createAtomicComponent("three", scope, OrderedEagerInitPojo.class);
+ scope.register(threeCtx);
+
+ scope.onEvent(new RequestStart(this));
+ OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+
+ OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+
+ OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+
+ // expire module
+ scope.onEvent(new RequestEnd(this));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java
new file mode 100644
index 0000000000..b4b835e742
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Verifies the scope container properly disposes resources and canbe restarted
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class RequestScopeRestartTestCase extends TestCase {
+
+ public void testRestart() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ RequestScopeContainer scope = new RequestScopeContainer(ctx);
+ scope.start();
+ MethodEventInvoker<Object> initInvoker =
+ new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("init"));
+ MethodEventInvoker<Object> destroyInvoker =
+ new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("destroy"));
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.addServiceInterface(InitDestroyOnce.class);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
+ configuration.setInstanceFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
+ SystemAtomicComponent context = new SystemAtomicComponentImpl("InitDestroy", configuration);
+ context.start();
+
+ Object instance = context.getServiceInstance();
+ assertSame(instance, context.getServiceInstance());
+
+ scope.onEvent(new RequestEnd(this));
+ scope.stop();
+ context.stop();
+
+ scope.start();
+ context.start();
+ assertNotSame(instance, context.getServiceInstance());
+ scope.onEvent(new RequestEnd(this));
+ scope.stop();
+ context.stop();
+ }
+
+ public static class InitDestroyOnce {
+
+ private boolean initialized;
+ private boolean destroyed;
+
+ public InitDestroyOnce() {
+ }
+
+ public void init() {
+ if (!initialized) {
+ initialized = true;
+ } else {
+ fail("Scope did not clean up properly - Init called more than once");
+ }
+ }
+
+ public void destroy() {
+ if (!destroyed) {
+ destroyed = true;
+ } else {
+ fail("Scope did not clean up properly - Destroyed called more than once");
+ }
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
new file mode 100644
index 0000000000..d6000dd8c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeNotFoundException;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+
+/**
+ * Verifies retrieval of standard scope contexts from the default scope registry
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ScopeRegistryTestCase extends TestCase {
+ public void testScopeContextCreation() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+ scopeRegistry.registerFactory(Scope.REQUEST, new RequestScopeObjectFactory());
+ scopeRegistry.registerFactory(Scope.SESSION, new HttpSessionScopeObjectFactory(scopeRegistry));
+ ScopeContainer request = scopeRegistry.getScopeContainer(Scope.REQUEST);
+ assertTrue(request instanceof RequestScopeContainer);
+ assertSame(request, scopeRegistry.getScopeContainer(Scope.REQUEST));
+ ScopeContainer session = scopeRegistry.getScopeContainer(Scope.SESSION);
+ assertTrue(session instanceof HttpSessionScopeContainer);
+ assertSame(session, scopeRegistry.getScopeContainer(Scope.SESSION));
+ assertNotSame(request, session);
+ }
+
+ public void testDeregisterFactory() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+ RequestScopeObjectFactory factory = new RequestScopeObjectFactory();
+ scopeRegistry.registerFactory(Scope.REQUEST, factory);
+ scopeRegistry.deregisterFactory(Scope.REQUEST);
+ try {
+ scopeRegistry.getScopeContainer(Scope.REQUEST);
+ fail();
+ } catch (ScopeNotFoundException e) {
+ // expected
+ }
+ }
+
+ public void testScopeNotRegistered() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+ try {
+ scopeRegistry.getScopeContainer(Scope.REQUEST);
+ fail();
+ } catch (ScopeNotFoundException e) {
+ // expected
+ }
+ try {
+ scopeRegistry.getScopeContainer(Scope.SESSION);
+ fail();
+ } catch (ScopeNotFoundException e) {
+ // expected
+ }
+ try {
+ scopeRegistry.getScopeContainer(Scope.STATELESS);
+ fail();
+ } catch (ScopeNotFoundException e) {
+ // expected
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java
new file mode 100644
index 0000000000..c69ce63b8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeContainerTestCase extends TestCase {
+
+ public void testBadStopWithoutStart() throws Exception {
+ StatelessScopeContainer container = new StatelessScopeContainer();
+ try {
+ container.stop();
+ fail();
+ } catch (IllegalStateException e) {
+ //expected
+ }
+ }
+
+ public void testBadDoubleStart() throws Exception {
+ StatelessScopeContainer container = new StatelessScopeContainer();
+ try {
+ container.start();
+ container.start();
+ fail();
+ } catch (IllegalStateException e) {
+ //expected
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java
new file mode 100644
index 0000000000..75f1682713
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeObjectFactoryTestCase extends TestCase {
+
+ public void testCreation() {
+ ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class);
+ registry.registerFactory(EasyMock.isA(Scope.class), EasyMock.isA(StatelessScopeObjectFactory.class));
+ assertNotNull(new StatelessScopeObjectFactory(registry).getInstance());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
new file mode 100644
index 0000000000..456bb5be78
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WorkContextTestCase extends TestCase {
+
+ public void testRemoteComponent() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ CompositeComponent component = EasyMock.createNiceMock(CompositeComponent.class);
+ CompositeComponent component2 = EasyMock.createNiceMock(CompositeComponent.class);
+ ctx.setRemoteComponent(component);
+ assertEquals(component, ctx.getRemoteComponent());
+ ctx.setRemoteComponent(component2);
+ assertEquals(component2, ctx.getRemoteComponent());
+ }
+
+ public void testNonSetRemoteComponent() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ assertNull(ctx.getRemoteComponent());
+ }
+
+ public void testIndentifier() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ Object id = new Object();
+ ctx.setIdentifier(this, id);
+ assertEquals(id, ctx.getIdentifier(this));
+ }
+
+ public void testClearIndentifier() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ Object id = new Object();
+ ctx.setIdentifier(this, id);
+ ctx.clearIdentifier(this);
+ assertNull(ctx.getIdentifier(this));
+ }
+
+ public void testClearIndentifiers() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ Object id = new Object();
+ Object id2 = new Object();
+ ctx.setIdentifier(id, id);
+ ctx.setIdentifier(id2, id2);
+ ctx.clearIdentifiers();
+ assertNull(ctx.getIdentifier(id));
+ assertNull(ctx.getIdentifier(id2));
+ }
+
+ public void testClearNonExistentIndentifier() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ctx.clearIdentifier(this);
+ }
+
+ public void testNullIndentifier() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ Object id = new Object();
+ ctx.setIdentifier(this, id);
+ ctx.clearIdentifier(null);
+ assertEquals(id, ctx.getIdentifier(this));
+ }
+
+ public void testNoIndentifier() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ assertNull(ctx.getIdentifier(this));
+ }
+
+ public void testSetGetMessageIds() {
+ WorkContext context = new WorkContextImpl();
+ context.setCurrentMessageId("msg-009");
+ context.setCurrentCorrelationId("msg-005");
+ assertEquals(context.getCurrentMessageId(), "msg-009");
+ assertEquals(context.getCurrentCorrelationId(), "msg-005");
+ context.setCurrentMessageId(null);
+ context.setCurrentCorrelationId(null);
+ assertNull(context.getCurrentMessageId());
+ assertNull(context.getCurrentCorrelationId());
+ }
+
+ public void testSetGetMessageIdsInNewThread() throws InterruptedException {
+ WorkContext context = new WorkContextImpl();
+ context.setCurrentMessageId("msg-009");
+ context.setCurrentCorrelationId("msg-005");
+ assertEquals(context.getCurrentMessageId(), "msg-009");
+ assertEquals(context.getCurrentCorrelationId(), "msg-005");
+ context.setIdentifier("TX", "002");
+ ChildThread t = new ChildThread(context);
+ t.start();
+ t.join();
+ assertTrue(t.passed);
+ context.setCurrentMessageId(null);
+ context.setCurrentCorrelationId(null);
+ assertNull(context.getCurrentMessageId());
+ assertNull(context.getCurrentCorrelationId());
+ }
+
+ private static class ChildThread extends Thread {
+ private WorkContext context;
+ private boolean passed = true;
+
+ private ChildThread(WorkContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public void run() {
+ try {
+ assertNull(context.getCurrentMessageId());
+ assertNull(context.getCurrentCorrelationId());
+ assertEquals("002", context.getIdentifier("TX"));
+ } catch (AssertionError e) {
+ passed = false;
+ }
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java
new file mode 100644
index 0000000000..720a3ef61e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.easymock.EasyMock;
+
+/**
+ *
+ */
+public class DataBindingInterceptorTestCase extends TestCase {
+ private DataBindingInteceptor interceptor;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @SuppressWarnings("unchecked")
+ public final void testInvoke() {
+ DataType<Class> type1 = new DataType<Class>("xml:string", String.class, String.class);
+ List<DataType<Class>> types1 = new ArrayList<DataType<Class>>();
+ types1.add(type1);
+ DataType<List<DataType<Class>>> inputType1 =
+ new DataType<List<DataType<Class>>>("xml:string", Object[].class, types1);
+
+ DataType<Class> type2 = new DataType<Class>("foo", Foo.class, Foo.class);
+ List<DataType<Class>> types2 = new ArrayList<DataType<Class>>();
+ types2.add(type2);
+ DataType<List<DataType<Class>>> inputType2 =
+ new DataType<List<DataType<Class>>>("foo", Object[].class, types2);
+
+ Operation<Class> operation1 =
+ new Operation<Class>("call", inputType1, type1, null, false, "xml:string");
+ Operation<Class> operation2 =
+ new Operation<Class>("call", inputType2, type2, null, false, "org.w3c.dom.Node");
+
+ DataType<DataType> outputType1 =
+ new DataType<DataType>("idl:output", Object.class, operation1.getOutputType());
+ DataType<DataType> outputType2 =
+ new DataType<DataType>("idl:output", Object.class, operation2.getOutputType());
+
+ OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+ InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+ CompositeComponent composite = EasyMock.createMock(CompositeComponent.class);
+ Component component = EasyMock.createMock(Component.class);
+ EasyMock.expect(component.getParent()).andReturn(composite).once();
+ EasyMock.expect(outboundWire.getContainer()).andReturn(component);
+ EasyMock.replay(outboundWire, inboundWire, composite, component);
+
+ interceptor = new DataBindingInteceptor(outboundWire, operation1, inboundWire, operation2);
+ Mediator mediator = createMock(Mediator.class);
+ Object[] source = new Object[] {"<foo>bar</foo>"};
+ Foo foo = new Foo();
+ foo.bar = "bar";
+ Object[] target = new Object[] {foo};
+ expect(mediator.mediate(EasyMock.same(source),
+ EasyMock.same(inputType1),
+ EasyMock.same(inputType2),
+ EasyMock.isA(Map.class))).andReturn(target);
+ // expect(mediator.mediate(target[0], type2,
+ // type1)).andReturn(source[0]);
+ expect(mediator.mediate(EasyMock.same(target[0]),
+ EasyMock.eq(outputType2),
+ EasyMock.eq(outputType1),
+ EasyMock.isA(Map.class))).andReturn(source[0]);
+ replay(mediator);
+ interceptor.setMediator(mediator);
+ Message msg = createMock(Message.class);
+ msg.setBody(EasyMock.anyObject());
+ expectLastCall().anyTimes();
+ expect(msg.getBody()).andReturn(source).once().andReturn(target[0]).once().andReturn(source[0]);
+ expect(msg.isFault()).andReturn(false).once();
+ replay(msg);
+ Interceptor next = createMock(Interceptor.class);
+ expect(next.invoke(msg)).andReturn(msg);
+ replay(next);
+ interceptor.setNext(next);
+ interceptor.invoke(msg);
+ String result = (String)msg.getBody();
+ Assert.assertEquals(source[0], result);
+ EasyMock.verify(mediator, msg, next);
+ }
+
+ private static class Foo {
+ private String bar;
+
+ public String getBar() {
+ return bar;
+ }
+
+ public void setBar(String bar) {
+ this.bar = bar;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java
new file mode 100644
index 0000000000..6cbc8f01c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.annotation.DataContext;
+import org.apache.tuscany.api.annotation.DataType;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.osoa.sca.annotations.Remotable;
+import org.w3c.dom.Node;
+
+/**
+ *
+ */
+public class DataBindingJavaInterfaceProcessorTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * @throws InvalidServiceContractException
+ */
+ public final void testVisitInterface() throws InvalidServiceContractException {
+ DataBindingJavaInterfaceProcessor processor = new DataBindingJavaInterfaceProcessor();
+ JavaServiceContract contract = new JavaServiceContract(MockInterface.class);
+ Map<String, Operation<Type>> operations = new HashMap<String, Operation<Type>>();
+ Operation<Type> operation = new Operation<Type>("call", null, null, null, false, null);
+ Operation<Type> operation1 = new Operation<Type>("call1", null, null, null, false, null);
+ operations.put("call", operation);
+ operations.put("call1", operation1);
+ contract.setOperations(operations);
+ processor.visitInterface(MockInterface.class, null, contract);
+ Assert.assertEquals("org.w3c.dom.Node", contract.getDataBinding());
+ Assert.assertEquals("element", (String)contract.getMetaData().get("nodeType"));
+ Assert.assertEquals("org.w3c.dom.Node", contract.getOperations().get("call").getDataBinding());
+ Assert.assertEquals("xml:string", contract.getOperations().get("call1").getDataBinding());
+ }
+
+ @DataType(name = "org.w3c.dom.Node", context = {@DataContext(key = "nodeType", value = "element")})
+ @Remotable
+ public static interface MockInterface {
+ Node call(Node msg);
+
+ @DataType(name = "xml:string")
+ String call1(String msg);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java
new file mode 100644
index 0000000000..6941e10a0c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.easymock.EasyMock;
+
+/**
+ * Testcase for DataBindingLoader
+ */
+public class DataBindingLoaderTestCase extends TestCase {
+ private XMLStreamReader reader;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public final void testLoad() throws LoaderException, XMLStreamException {
+ reader = EasyMock.createMock(XMLStreamReader.class);
+ // EasyMock.expect(reader.getEventType()).andReturn(XMLStreamConstants.START_ELEMENT);
+ EasyMock.expect(reader.hasNext()).andReturn(true).anyTimes();
+ EasyMock.expect(reader.getName()).andReturn(DataTypeLoader.DATA_BINDING);
+ EasyMock.expect(reader.getAttributeValue(null, "name")).andReturn("ABC");
+ EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ EasyMock.replay(reader);
+
+ ModelObject mo = new DataTypeLoader(null).load(null, reader, null);
+ Assert.assertTrue(mo instanceof DataType);
+ Assert.assertEquals("ABC", ((DataType<?>)mo).getDataBinding());
+ EasyMock.verify(reader);
+
+ EasyMock.reset(reader);
+
+ // EasyMock.expect(reader.getEventType()).andReturn(XMLStreamConstants.START_ELEMENT);
+ EasyMock.expect(reader.hasNext()).andReturn(true).anyTimes();
+ EasyMock.expect(reader.getName()).andReturn(DataTypeLoader.DATA_BINDING);
+ EasyMock.expect(reader.getAttributeValue(null, "name")).andReturn(null);
+ EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ EasyMock.replay(reader);
+ try {
+ mo = new DataTypeLoader(null).load(null, reader, null);
+ Assert.fail("InvalidValueException should have been thrown");
+ } catch (InvalidValueException e) {
+ Assert.assertTrue(true);
+ }
+ EasyMock.verify(reader);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java
new file mode 100644
index 0000000000..30af31b1cb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.model.DataType;
+import org.easymock.EasyMock;
+import org.xml.sax.ContentHandler;
+
+/**
+ *
+ */
+public class DataBindingRegistryImplTestCase extends TestCase {
+ private DataBindingRegistry registry;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new DataBindingRegistryImpl();
+ }
+
+ public void testRegistry() {
+ DataBinding db1 = createMock(DataBinding.class);
+ expect(db1.getName()).andReturn(ContentHandler.class.getName()).anyTimes();
+ DataType<Class> dataType1 = new DataType<Class>(ContentHandler.class, ContentHandler.class);
+ expect(db1.introspect(ContentHandler.class)).andReturn(dataType1);
+ expect(db1.introspect((Class)EasyMock.anyObject())).andReturn(null).anyTimes();
+ replay(db1);
+
+ registry.register(db1);
+
+ DataBinding db2 = createMock(DataBinding.class);
+ expect(db2.getName()).andReturn(XMLStreamReader.class.getName()).anyTimes();
+ DataType<Class> dataType2 = new DataType<Class>(XMLStreamReader.class, XMLStreamReader.class);
+ expect(db2.introspect(XMLStreamReader.class)).andReturn(dataType2);
+ expect(db2.introspect((Class)EasyMock.anyObject())).andReturn(null).anyTimes();
+ replay(db2);
+
+ registry.register(db2);
+
+ String name = db1.getName();
+ DataBinding db3 = registry.getDataBinding(name);
+ Assert.assertTrue(db1 == db3);
+
+ DataType<?> dt = registry.introspectType(ContentHandler.class);
+ Assert.assertEquals(dataType1, dt);
+ Assert.assertTrue(dt.getDataBinding().equalsIgnoreCase(name));
+
+ registry.unregister(name);
+ DataBinding db4 = registry.getDataBinding(name);
+ Assert.assertNull(db4);
+
+ dt = registry.introspectType(ContentHandler.class);
+ Assert.assertNull(dt);
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java
new file mode 100644
index 0000000000..de5c537274
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.annotation.DataContext;
+import org.apache.tuscany.api.annotation.DataType;
+
+public class DataBindingTestCase extends TestCase {
+ @SuppressWarnings("unused")
+ public void testDataType() throws Exception {
+ Class<Test> testClass = Test.class;
+ DataType d = testClass.getAnnotation(DataType.class);
+ Assert.assertEquals(d.name(), "sdo");
+ Assert.assertEquals(d.context().length, 0);
+
+ Method method = testClass.getMethod("test", new Class[] {Object.class});
+ DataType d2 = method.getAnnotation(DataType.class);
+ Assert.assertEquals(d2.name(), "jaxb");
+ Assert.assertEquals(d2.context()[0].key(), "contextPath");
+ Assert.assertEquals(d2.context()[0].value(), "com.example.ipo.jaxb");
+ }
+
+ @DataType(name = "sdo")
+ private static interface Test {
+ @DataType(name = "jaxb", context = {@DataContext(key = "contextPath", value = "com.example.ipo.jaxb")})
+ Object test(Object object);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java
new file mode 100644
index 0000000000..44ae07034f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.easymock.EasyMock;
+import org.w3c.dom.Node;
+
+/**
+ *
+ */
+public class DataBindingWirePostProcessorTestCase extends TestCase {
+ private DataBindingWirePostProcessor processor;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ Mediator mediator = new MediatorImpl();
+ this.processor = new DataBindingWirePostProcessor(mediator);
+ }
+
+ public void testProcess1() {
+ InboundWire inboundWire = createMock(InboundWire.class);
+ OutboundWire outboundWire = createMock(OutboundWire.class);
+
+ Component component = createMock(Component.class);
+ CompositeComponent composite = createMock(CompositeComponent.class);
+ expect(component.getParent()).andReturn(composite);
+ expect(inboundWire.getContainer()).andReturn(component);
+ expect(outboundWire.getContainer()).andReturn(component);
+
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ DataType<Type> type1 = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ types.add(type1);
+ DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
+ DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
+ Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
+ ServiceContract<Type> outboundContract = new JavaServiceContract(null);
+ outboundContract.setDataBinding(String.class.getName());
+ op1.setServiceContract(outboundContract);
+
+ OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
+ outboundChains.put(op1, outboundChain);
+ expect(outboundWire.getInvocationChains()).andReturn(outboundChains);
+ outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());
+
+ Map<Operation<?>, InboundInvocationChain> inboundChains =
+ new HashMap<Operation<?>, InboundInvocationChain>();
+ DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
+ List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
+ types2.add(type2);
+ DataType<List<DataType<Type>>> inputType2 =
+ new DataType<List<DataType<Type>>>(Object[].class, types2);
+ DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
+ Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
+ ServiceContract<Type> inboundContract = new JavaServiceContract(null);
+ inboundContract.setDataBinding(Node.class.getName());
+ op2.setServiceContract(inboundContract);
+
+ InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
+ inboundChains.put(op2, inboundChain);
+ expect(inboundWire.getInvocationChains()).andReturn(inboundChains);
+
+ ServiceContract<Type> contract = new JavaServiceContract();
+ Map<String, Operation<Type>> operations = Collections.emptyMap();
+ contract.setCallbackOperations(operations);
+ expect(outboundWire.getServiceContract()).andReturn(contract);
+
+ EasyMock.replay(composite, component, inboundWire, outboundWire, inboundChain, outboundChain);
+
+ processor.process(outboundWire, inboundWire);
+ }
+
+ public void testProcess2() {
+ InboundWire inboundWire = createMock(InboundWire.class);
+ OutboundWire outboundWire = createMock(OutboundWire.class);
+
+ Reference reference = createMock(Reference.class);
+ CompositeComponent composite = createMock(CompositeComponent.class);
+ expect(reference.getParent()).andReturn(composite);
+ expect(inboundWire.getContainer()).andReturn(reference).anyTimes();
+ expect(outboundWire.getContainer()).andReturn(reference).anyTimes();
+
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ DataType<Type> type1 = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ types.add(type1);
+ DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
+ DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
+ Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
+ ServiceContract<Type> outboundContract = new JavaServiceContract(null);
+ outboundContract.setDataBinding(String.class.getName());
+ op1.setServiceContract(outboundContract);
+
+ OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
+ outboundChains.put(op1, outboundChain);
+ expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+ outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());
+
+ Map<Operation<?>, InboundInvocationChain> inboundChains =
+ new HashMap<Operation<?>, InboundInvocationChain>();
+ DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
+ List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
+ types2.add(type2);
+ DataType<List<DataType<Type>>> inputType2 =
+ new DataType<List<DataType<Type>>>(Object[].class, types2);
+ DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
+ Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
+ ServiceContract<Type> inboundContract = new JavaServiceContract(null);
+ inboundContract.setDataBinding(Node.class.getName());
+ op2.setServiceContract(inboundContract);
+
+ InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
+ inboundChains.put(op2, inboundChain);
+ expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes();
+
+ ServiceContract<Type> contract = new JavaServiceContract();
+ Map<String, Operation<Type>> operations = Collections.emptyMap();
+ contract.setCallbackOperations(operations);
+ expect(inboundWire.getServiceContract()).andReturn(contract);
+ expect(inboundChain.getTailInterceptor()).andReturn(null);
+
+ EasyMock.replay(composite, reference, inboundWire, outboundWire, inboundChain, outboundChain);
+
+ processor.process(inboundWire, outboundWire);
+ }
+
+ public void testProcess3() {
+ InboundWire inboundWire = createMock(InboundWire.class);
+ OutboundWire outboundWire = createMock(OutboundWire.class);
+
+ Service service = createMock(Service.class);
+ CompositeComponent composite = createMock(CompositeComponent.class);
+ expect(service.getParent()).andReturn(composite);
+ expect(inboundWire.getContainer()).andReturn(service).anyTimes();
+ expect(outboundWire.getContainer()).andReturn(service).anyTimes();
+
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
+ DataType<Type> type1 = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ types.add(type1);
+ DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
+ DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
+ Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
+ ServiceContract<Type> outboundContract = new JavaServiceContract(null);
+ outboundContract.setDataBinding(String.class.getName());
+ op1.setServiceContract(outboundContract);
+
+ OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
+ outboundChains.put(op1, outboundChain);
+ expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+ // outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)
+ // EasyMock.anyObject());
+
+ Map<Operation<?>, InboundInvocationChain> inboundChains =
+ new HashMap<Operation<?>, InboundInvocationChain>();
+ DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
+ List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
+ types2.add(type2);
+ DataType<List<DataType<Type>>> inputType2 =
+ new DataType<List<DataType<Type>>>(Object[].class, types2);
+ DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
+ Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
+ ServiceContract<Type> inboundContract = new JavaServiceContract(null);
+ inboundContract.setDataBinding(Node.class.getName());
+ op2.setServiceContract(inboundContract);
+
+ InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
+ inboundChains.put(op2, inboundChain);
+ expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes();
+ inboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());
+
+ ServiceContract<Type> contract = new JavaServiceContract();
+ Map<String, Operation<Type>> operations = Collections.emptyMap();
+ contract.setCallbackOperations(operations);
+ expect(inboundWire.getServiceContract()).andReturn(contract);
+
+ EasyMock.replay(composite, service, inboundWire, outboundWire, inboundChain, outboundChain);
+
+ processor.process(inboundWire, outboundWire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java
new file mode 100755
index 0000000000..70244df8e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.impl.DirectedGraph.Edge;
+import org.apache.tuscany.core.databinding.impl.DirectedGraph.Vertex;
+
+public class DirectedGraphTestCase extends TestCase {
+ private DirectedGraph<String, Object> graph;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ graph = new DirectedGraph<String, Object>();
+ graph.addEdge("a", "b", null, 3);
+ graph.addEdge("b", "c", null, 1);
+ graph.addEdge("a", "c", null, 8);
+ graph.addEdge("a", "d", null, 3);
+ graph.addEdge("b", "d", null, 2);
+ graph.addEdge("c", "b", null, 1);
+ graph.addEdge("c", "d", null, 2);
+ graph.addEdge("d", "b", null, 1);
+ graph.addEdge("a", "e", null, 8);
+ graph.addEdge("c", "c", null, 2);
+ }
+
+ public void testGraph() {
+ // System.out.println(graph);
+
+ Vertex vertex = graph.getVertex("a");
+ Assert.assertNotNull(vertex);
+ Assert.assertEquals(vertex.getValue(), "a");
+
+ Assert.assertNull(graph.getVertex("1"));
+
+ Edge edge = graph.getEdge("a", "b");
+ Assert.assertNotNull(edge);
+ Assert.assertEquals(edge.getWeight(), 3);
+
+ edge = graph.getEdge("b", "a");
+ Assert.assertNull(edge);
+
+ DirectedGraph<String, Object>.Path path = graph.getShortestPath("a", "c");
+
+ List<DirectedGraph<String, Object>.Edge> edges = path.getEdges();
+ Assert.assertEquals(edges.size(), 2);
+ Assert.assertEquals(edges.get(0), graph.getEdge("a", "b"));
+ Assert.assertEquals(edges.get(1), graph.getEdge("b", "c"));
+
+ Assert.assertEquals(path.getWeight(), 4);
+
+ DirectedGraph<String, Object>.Path path2 = graph.getShortestPath("b", "e");
+ Assert.assertNull(path2);
+
+ DirectedGraph<String, Object>.Path path3 = graph.getShortestPath("a", "a");
+ Assert.assertTrue(path3.getWeight() == 0 && path3.getEdges().isEmpty());
+
+ DirectedGraph<String, Object>.Path path4 = graph.getShortestPath("c", "c");
+ Assert.assertTrue(path4.getWeight() == 2 && path4.getEdges().size() == 1);
+
+ // System.out.println(path);
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java
new file mode 100644
index 0000000000..abd15a1947
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.core.databinding.xml.Node2Object;
+import org.apache.tuscany.core.databinding.xml.Node2String;
+import org.apache.tuscany.core.databinding.xml.Object2Node;
+import org.apache.tuscany.core.databinding.xml.String2Node;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.idl.WrapperInfo;
+import org.apache.tuscany.spi.model.DataType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class IDLTransformerTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<order1"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</order1>";
+
+ private static final String OPERATION_KEY = org.apache.tuscany.spi.model.Operation.class.getName();
+
+ private static final String URI_ORDER_XSD = "http://example.com/order.xsd";
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testTransform() throws Exception {
+ List<DataType<QName>> types0 = new ArrayList<DataType<QName>>();
+ DataType<QName> wrapperType =
+ new DataType<QName>(null, Object.class, new QName(URI_ORDER_XSD, "checkOrderStatus"));
+ types0.add(wrapperType);
+ DataType<List<DataType<QName>>> inputType0 =
+ new DataType<List<DataType<QName>>>("idl:input", Object[].class, types0);
+
+ List<DataType<QName>> types1 = new ArrayList<DataType<QName>>();
+ DataType<QName> customerIdType =
+ new DataType<QName>(null, Object.class, new QName(URI_ORDER_XSD, "customerId"));
+ DataType<QName> orderType =
+ new DataType<QName>(null, Object.class, new QName(URI_ORDER_XSD, "order"));
+ DataType<QName> flagType = new DataType<QName>(null, Object.class, new QName(URI_ORDER_XSD, "flag"));
+ types1.add(customerIdType);
+ types1.add(orderType);
+ types1.add(flagType);
+ DataType<List<DataType<QName>>> inputType =
+ new DataType<List<DataType<QName>>>("idl:input", Object[].class, types1);
+
+ DataType<QName> statusType =
+ new DataType<QName>(null, Object.class, new QName(URI_ORDER_XSD, "status"));
+ DataType<QName> responseType =
+ new DataType<QName>(null, Object.class, new QName(URI_ORDER_XSD, "checkOrderStatusResponse"));
+
+ org.apache.tuscany.spi.model.Operation<QName> op =
+ new org.apache.tuscany.spi.model.Operation<QName>("checkOrderStatus", inputType0, responseType,
+ null);
+ op.setDataBinding(DOMDataBinding.NAME);
+
+ inputType0.setMetadata(OPERATION_KEY, op);
+ op.setWrapperStyle(true);
+ ElementInfo inputElement =
+ new ElementInfo(new QName(URI_ORDER_XSD, "checkOrderStatus"), new TypeInfo(null, false, null));
+ wrapperType.setMetadata(ElementInfo.class.getName(), inputElement);
+
+ ElementInfo customerId =
+ new ElementInfo(new QName("", "customerId"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES
+ .get("string"));
+ ElementInfo order =
+ new ElementInfo(new QName("", "order"), new TypeInfo(new QName(URI_ORDER_XSD), false, null));
+ ElementInfo flag =
+ new ElementInfo(new QName("", "flag"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.get("int"));
+
+ customerIdType.setMetadata(ElementInfo.class.getName(), customerId);
+ orderType.setMetadata(ElementInfo.class.getName(), order);
+ flagType.setMetadata(ElementInfo.class.getName(), flag);
+
+ customerIdType.setMetadata(OPERATION_KEY, op);
+ orderType.setMetadata(OPERATION_KEY, op);
+ flagType.setMetadata(OPERATION_KEY, op);
+
+ List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
+ inputElements.add(customerId);
+ inputElements.add(order);
+ inputElements.add(flag);
+
+ ElementInfo statusElement =
+ new ElementInfo(new QName("", "status"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.get("string"));
+
+ statusType.setMetadata(ElementInfo.class.getName(), statusElement);
+ statusType.setMetadata(OPERATION_KEY, op);
+
+ List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
+ outputElements.add(statusElement);
+
+ ElementInfo outputElement =
+ new ElementInfo(new QName(URI_ORDER_XSD, "checkOrderStatusResponse"), new TypeInfo(null, false,
+ null));
+
+ responseType.setMetadata(ElementInfo.class.getName(), inputElement);
+ responseType.setMetadata(OPERATION_KEY, op);
+
+ WrapperInfo wrapperInfo =
+ new WrapperInfo(inputElement, outputElement, inputElements, outputElements, inputType, statusType);
+ op.setWrapper(wrapperInfo);
+ op.setDataBinding(DOMDataBinding.NAME);
+
+ MediatorImpl m = new MediatorImpl();
+ TransformerRegistryImpl tr = new TransformerRegistryImpl();
+ tr.registerTransformer(new String2Node());
+ tr.registerTransformer(new Node2String());
+ tr.registerTransformer(new Node2Object());
+ tr.registerTransformer(new Object2Node());
+ m.setTransformerRegistry(tr);
+ DataBindingRegistry dataBindingRegistry = new DataBindingRegistryImpl();
+ dataBindingRegistry.register(new DOMDataBinding());
+ m.setDataBindingRegistry(dataBindingRegistry);
+
+ Object[] source = new Object[] {"cust001", IPO_XML, Integer.valueOf(1)};
+ Input2InputTransformer t = new Input2InputTransformer();
+ t.setDataBindingRegistry(dataBindingRegistry);
+ t.setMediator(m);
+
+ TransformationContext context = new TransformationContextImpl();
+ List<DataType<Class>> types = new ArrayList<DataType<Class>>();
+ types.add(new DataType<Class>(Object.class.getName(), String.class, String.class));
+ types.add(new DataType<Class>("java.lang.String", String.class, String.class));
+ types.add(new DataType<Class>(Object.class.getName(), int.class, int.class));
+ DataType<List<DataType<Class>>> inputType1 =
+ new DataType<List<DataType<Class>>>("idl:input", Object[].class, types);
+ context.setSourceDataType(inputType1);
+ context.setTargetDataType(op.getInputType());
+ Object[] results = t.transform(source, context);
+ assertEquals(1, results.length);
+ assertTrue(results[0] instanceof Element);
+ Element element = (Element)results[0];
+ assertEquals("http://example.com/order.xsd", element.getNamespaceURI());
+ assertEquals("checkOrderStatus", element.getLocalName());
+
+ TransformationContext context1 = new TransformationContextImpl();
+ DataType<DataType> sourceType =
+ new DataType<DataType>("idl:output", Object.class, op.getOutputType());
+ sourceType.setMetadata(OPERATION_KEY, op.getOutputType().getMetadata(OPERATION_KEY));
+
+ context1.setSourceDataType(sourceType);
+ DataType<DataType> targetType =
+ new DataType<DataType>("idl:output", Object.class,
+ new DataType<Class>("java.lang.Object", String.class, String.class));
+ context1.setTargetDataType(targetType);
+
+ Document factory = DOMHelper.newDocument();
+ Element responseElement =
+ factory.createElementNS("http://example.com/order.wsdl", "p:checkOrderStatusResponse");
+ Element status = factory.createElement("status");
+ responseElement.appendChild(status);
+ status.appendChild(factory.createTextNode("shipped"));
+ Output2OutputTransformer t2 = new Output2OutputTransformer();
+ t2.setMediator(m);
+ t2.setDataBindingRegistry(dataBindingRegistry);
+ Object st = t2.transform(responseElement, context1);
+ assertEquals("shipped", st);
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java
new file mode 100644
index 0000000000..3cb7f243a9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.impl;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.xml.Node2String;
+import org.apache.tuscany.core.databinding.xml.Node2Writer;
+import org.apache.tuscany.core.databinding.xml.SAX2DOMPipe;
+import org.apache.tuscany.core.databinding.xml.String2SAX;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.apache.tuscany.spi.model.DataType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for MediatorImpl
+ */
+public class MediatorImplTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + "<state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + "<USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private MediatorImpl mediator;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ TransformerRegistry registry = new TransformerRegistryImpl();
+ registry.registerTransformer(new String2SAX());
+ registry.registerTransformer(new SAX2DOMPipe());
+ registry.registerTransformer(new Node2String());
+ registry.registerTransformer(new Node2Writer());
+
+ mediator = new MediatorImpl();
+ mediator.setTransformerRegistry(registry);
+
+ DataBindingRegistry dataBindingRegistry = new DataBindingRegistryImpl();
+ mediator.setDataBindingRegistry(dataBindingRegistry);
+ }
+
+ private TransformationContext createTransformationContext(Class sourceType, Class targetType) {
+ TransformationContext context = new TransformationContextImpl();
+ DataType sourceDataType = new DataType<Class>(sourceType, sourceType);
+ DataType targetDataType = new DataType<Class>(targetType, targetType);
+ context.setSourceDataType(sourceDataType);
+ context.setTargetDataType(targetDataType);
+ return context;
+ }
+
+ public void testTransform1() {
+ TransformationContext context = createTransformationContext(String.class, Node.class);
+ Object node =
+ mediator.mediate(IPO_XML, context.getSourceDataType(), context.getTargetDataType(), null);
+ Assert.assertTrue(node instanceof Document);
+ Element root = ((Document)node).getDocumentElement();
+ Assert.assertEquals(root.getNamespaceURI(), "http://www.example.com/IPO");
+ Assert.assertEquals(root.getLocalName(), "purchaseOrder");
+ }
+
+ public void testTransform2() {
+ TransformationContext context = createTransformationContext(String.class, Writer.class);
+ Writer writer = new StringWriter();
+ mediator.mediate(IPO_XML, writer, context.getSourceDataType(), context.getTargetDataType(), null);
+ String str = writer.toString();
+ Assert.assertTrue(str != null && str.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java
new file mode 100644
index 0000000000..6250efd897
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+
+/**
+ *
+ */
+public class TransformerRegistryImplTestCase extends TestCase {
+ private TransformerRegistry registry;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new TransformerRegistryImpl();
+ }
+
+ public void testRegisterTransformer1() {
+ Transformer transformer = createMock(Transformer.class);
+ registry.registerTransformer("a", "b", 10, transformer);
+ Transformer t = registry.getTransformer("a", "b");
+ Assert.assertSame(t, transformer);
+ }
+
+ public void testRegisterTransformerTransformer() {
+ Transformer transformer = createMock(Transformer.class);
+ expect(transformer.getSourceDataBinding()).andReturn("a");
+ expect(transformer.getTargetDataBinding()).andReturn("b");
+ expect(transformer.getWeight()).andReturn(10);
+ replay(transformer);
+ registry.registerTransformer(transformer);
+ Transformer t = registry.getTransformer("a", "b");
+ Assert.assertSame(t, transformer);
+ }
+
+ public void testUnregisterTransformer() {
+ Transformer transformer = createMock(Transformer.class);
+ registry.registerTransformer("a", "b", 10, transformer);
+ boolean result = registry.unregisterTransformer("a", "b");
+ Assert.assertTrue(result);
+ Transformer t = registry.getTransformer("a", "b");
+ Assert.assertNull(t);
+ }
+
+ public void testGetTransformerChain() {
+ Transformer t1 = createMock(Transformer.class);
+ expect(t1.getSourceDataBinding()).andReturn("a");
+ expect(t1.getTargetDataBinding()).andReturn("b");
+ expect(t1.getWeight()).andReturn(10);
+ replay(t1);
+ Transformer t2 = createMock(Transformer.class);
+ expect(t2.getSourceDataBinding()).andReturn("b");
+ expect(t2.getTargetDataBinding()).andReturn("c");
+ expect(t2.getWeight()).andReturn(20);
+ replay(t2);
+
+ Transformer t3 = createMock(Transformer.class);
+ expect(t3.getSourceDataBinding()).andReturn("a");
+ expect(t3.getTargetDataBinding()).andReturn("c");
+ expect(t3.getWeight()).andReturn(120);
+ replay(t3);
+
+ registry.registerTransformer(t1);
+ registry.registerTransformer(t2);
+ registry.registerTransformer(t3);
+
+ List<Transformer> l1 = registry.getTransformerChain("a", "b");
+ Assert.assertTrue(l1.size() == 1 && l1.get(0) == t1);
+ List<Transformer> l2 = registry.getTransformerChain("a", "c");
+ Assert.assertTrue(l2.size() == 2 && l2.get(0) == t1 && l2.get(1) == t2);
+ List<Transformer> l3 = registry.getTransformerChain("a", "d");
+ Assert.assertNull(l3);
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java
new file mode 100644
index 0000000000..942b2d67e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.w3c.dom.Node;
+
+public class DOM2StAXTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testTransformation() {
+ String2Node t1 = new String2Node();
+ Node node = t1.transform(IPO_XML, null);
+ Node2XMLStreamReader t2 = new Node2XMLStreamReader();
+ XMLStreamReader reader = t2.transform(node, null);
+ XMLStreamReader2String t3 = new XMLStreamReader2String();
+ String xml = t3.transform(reader, null);
+ Assert.assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java
new file mode 100644
index 0000000000..d4eaf9b2a9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.impl.PipedTransformer;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for DataPipe
+ */
+public class DataPipeTestCase extends TestCase {
+
+ public final void testStreamPipe() throws IOException {
+ byte[] bytes = new byte[] {1, 2, 3};
+ StreamDataPipe pipe = new StreamDataPipe();
+ Assert.assertSame(OutputStream.class, pipe.getSourceType());
+ Assert.assertSame(InputStream.class, pipe.getTargetType());
+ OutputStream os = pipe.getSink();
+ os.write(bytes);
+ byte[] newBytes = new byte[16];
+ int count = pipe.getResult().read(newBytes);
+ Assert.assertEquals(3, count);
+ for (int i = 0; i < bytes.length; i++) {
+ Assert.assertEquals(bytes[i], newBytes[i]);
+ }
+ }
+
+ public final void testWriter2ReaderPipe() throws IOException {
+ String str = "ABC";
+ Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
+ Assert.assertSame(Writer.class, pipe.getSourceType());
+ Assert.assertSame(Reader.class, pipe.getTargetType());
+ pipe.getSink().write(str);
+ char[] buf = new char[16];
+ int count = pipe.getResult().read(buf);
+ Assert.assertEquals(3, count);
+ for (int i = 0; i < str.length(); i++) {
+ Assert.assertEquals(str.charAt(i), buf[i]);
+ }
+ }
+
+ public final void testPiped() throws Exception {
+ Node2Writer node2Writer = new Node2Writer();
+ Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
+ PipedTransformer<Node, Writer, Reader> transformer =
+ new PipedTransformer<Node, Writer, Reader>(node2Writer, pipe);
+ Document document = DOMHelper.newDocument();
+ Element element = document.createElementNS("http://ns1", "root");
+ document.appendChild(element);
+ Reader reader = transformer.transform(document, null);
+ Assert.assertEquals(transformer.getWeight(), node2Writer.getWeight() + pipe.getWeight());
+ Assert.assertEquals(transformer.getSourceDataBinding(), node2Writer.getSourceDataBinding());
+ Assert.assertEquals(transformer.getTargetDataBinding(), pipe.getTargetDataBinding());
+ char[] buf = new char[120];
+ int count = reader.read(buf);
+ String xml = new String(buf, 0, count);
+ Assert.assertTrue(xml.contains("<root xmlns=\"http://ns1\"/>"));
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java
new file mode 100755
index 0000000000..9b9aa3b893
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class Node2StringTestCase extends TestCase {
+ public void testTransformation() throws Exception {
+ Document document = DOMHelper.newDocument();
+ Element element = document.createElementNS("http://ns1", "test");
+ document.appendChild(element);
+
+ new Node2String().transform(document, null);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java
new file mode 100644
index 0000000000..a2318b2faa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.impl.PipedTransformer;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+
+public class PushTransformationTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testTransformation() {
+ String2XMLStreamReader t1 = new String2XMLStreamReader();
+ XMLStreamReader reader = t1.transform(IPO_XML, null);
+ XMLStreamReader2SAX t2 = new XMLStreamReader2SAX();
+ PipedTransformer<XMLStreamReader, ContentHandler, Node> t3 =
+ new PipedTransformer<XMLStreamReader, ContentHandler, Node>(t2, new SAX2DOMPipe());
+ Node node = t3.transform(reader, null);
+ Assert.assertNotNull(node);
+ Node2String t4 = new Node2String();
+ String xml = t4.transform(node, null);
+ Assert.assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java
new file mode 100644
index 0000000000..7d18e83ac6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+/**
+ * Test Case for StAXHelper
+ */
+public class StAXHelperTestCase extends TestCase {
+ private static final String XML =
+ "<a:foo xmlns:a='http://a' name='foo'><bar name='bar'>" + "<doo a:name='doo' xmlns:a='http://doo'/>"
+ + "</bar></a:foo>";
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testHelper() throws Exception {
+ XMLStreamReader reader = StAXHelper.createXMLStreamReader(XML);
+ String xml = StAXHelper.save(reader);
+ reader = StAXHelper.createXMLStreamReader(xml);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java
new file mode 100644
index 0000000000..7e9494d423
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.databinding.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ *
+ */
+public class TraxTransformerTestCase extends TestCase {
+ private URL url;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ url = getClass().getResource("foo.xml");
+ }
+
+ public void testTransformDOM() throws IOException {
+ InputStream is = url.openStream();
+ InputStream2Node t1 = new InputStream2Node();
+ Node node = t1.transform(is, null);
+ is.close();
+ Writer writer = new StringWriter();
+ Node2Writer t2 = new Node2Writer();
+ t2.transform(node, writer, null);
+ String str = writer.toString();
+ StringReader reader = new StringReader(str);
+ Reader2Node t3 = new Reader2Node();
+ node = t3.transform(reader, null);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Node2OutputStream t4 = new Node2OutputStream();
+ t4.transform(node, os, null);
+ InputSource inputSource = new InputSource(new ByteArrayInputStream(os.toByteArray()));
+ InputSource2Node t5 = new InputSource2Node();
+ node = t5.transform(inputSource, null);
+ }
+
+ public void testTransformSAX() throws IOException {
+ MyContentHandler handler = new MyContentHandler();
+ InputStream is = url.openStream();
+ InputStream2SAX t1 = new InputStream2SAX();
+ t1.transform(is, handler, null);
+ is.close();
+
+ String xml = "<foo xmlns=\"http://foo\">bar</foo>";
+
+ InputSource inputSource = new InputSource(new StringReader(xml));
+ InputSource2SAX t2 = new InputSource2SAX();
+ MyContentHandler handler2 = new MyContentHandler();
+ t2.transform(inputSource, handler2, null);
+
+ }
+
+ private static class MyContentHandler extends DefaultHandler {
+
+ @Override
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
+ throws SAXException {
+ super.startElement(namespaceURI, localName, qName, atts);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
new file mode 100644
index 0000000000..f988c5d3a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.deployer;
+
+import java.net.URL;
+import java.util.Map;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Include;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.mock.component.BasicInterface;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Verifies the default boostrap deployer
+ *
+ * @version $Rev$ $Date$
+ */
+public class BootstrapDeployerTestCase extends TestCase {
+ private DeployerImpl deployer;
+ private DeploymentContext deploymentContext;
+ private ComponentDefinition<SystemCompositeImplementation> componentDefinition;
+ private SystemCompositeImplementation implementation;
+
+ public void testBoot1Load() throws LoaderException {
+ CompositeComponent parent = createNiceMock(CompositeComponent.class);
+ URL scdl = BootstrapDeployerTestCase.class.getResource("boot1.scdl");
+ implementation.setScdlLocation(scdl);
+ deployer.load(parent, componentDefinition, deploymentContext);
+ CompositeComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> composite =
+ implementation.getComponentType();
+ assertNotNull(composite);
+ assertEquals("boot1", composite.getName());
+
+ // check parse of <service>
+ Map<String, ServiceDefinition> services = composite.getDeclaredServices();
+ assertEquals(1, services.size()); // included doesn't count
+ services = composite.getServices();
+ assertEquals(2, services.size()); // included counts
+ BoundServiceDefinition serviceDefinition = (BoundServiceDefinition) services.get("service");
+ assertNotNull(serviceDefinition);
+ assertEquals("service", serviceDefinition.getName());
+ assertEquals(BasicInterface.class, serviceDefinition.getServiceContract().getInterfaceClass());
+ assertTrue(serviceDefinition.getBinding() instanceof SystemBinding);
+
+ // check parse of <component>
+ Map<String, ComponentDefinition<? extends Implementation<?>>> components = composite.getDeclaredComponents();
+ assertEquals(1, components.size()); // included doesn't count
+ components = composite.getComponents();
+ assertEquals(2, components.size()); // included counts
+ ComponentDefinition<? extends Implementation<?>> component = components.get("component");
+ assertNotNull(component);
+ PropertyValue<?> propVal = component.getPropertyValues().get("publicProperty");
+ assertEquals("propval", propVal.getValueFactory().getInstance());
+
+ // check introspection of implementation
+ ComponentType<?, ?, ?> componentType = component.getImplementation().getComponentType();
+ assertNotNull(componentType); // details checked in SystemComponentTypeLoaderTestCase
+
+ // check included component
+ Map<String, Include> includes = composite.getIncludes();
+ assertEquals(1, includes.size());
+ Include include = includes.get("boot1-include");
+ assertNotNull(include);
+ CompositeComponentType included = include.getIncluded();
+ assertNotNull(included);
+ assertEquals(1, included.getComponents().size());
+ }
+
+ public void testBoot1Deployment() throws LoaderException {
+ URL scdl = BootstrapDeployerTestCase.class.getResource("boot1.scdl");
+ implementation.setScdlLocation(scdl);
+ CompositeComponent parent = createNiceMock(CompositeComponent.class);
+ parent.register(isA(SCAObject.class));
+ replay(parent);
+ // load the boot1 file using the bootstrap deployer
+ componentDefinition.setName("simple");
+ Component component = deployer.deploy(parent, componentDefinition);
+ assertNotNull(component);
+ verify(parent);
+ }
+
+ public void testBoot2Deployment() throws LoaderException {
+ URL scdl = BootstrapDeployerTestCase.class.getResource("boot2.scdl");
+ implementation.setScdlLocation(scdl);
+ CompositeComponent parent = createNiceMock(CompositeComponent.class);
+ parent.register(isA(SCAObject.class));
+ replay(parent);
+
+ // load the boot2 file using the bootstrap deployer
+ componentDefinition.setName("newDeployer");
+ CompositeComponent component = (CompositeComponent) deployer.deploy(parent, componentDefinition);
+ assertNotNull(component);
+ verify(parent);
+ component.start();
+ Deployer newDeployer = (Deployer) component.getSystemServiceInstance("deployer");
+ assertNotNull(newDeployer);
+
+/* // FIXME
+ // load the boot2 file using the newly loaded deployer
+ parent.reset();
+ parent.expects(once()).method("register").withAnyArguments();
+ componentDefinition.setName("newDeployer2");
+ component = newDeployer.deploy((CompositeComponent) parent.proxy(), componentDefinition);
+ assertNotNull(component);
+ parent.verify();
+ component.start();
+ Deployer newDeployer2 = (Deployer) component.getServiceInstance("deployer");
+ assertNotNull(newDeployer2);
+*/
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
+ Bootstrapper bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), xmlFactory);
+ deployer = (DeployerImpl) bootstrapper.createDeployer();
+ deploymentContext = new RootDeploymentContext(null, xmlFactory, null, null);
+ implementation = new SystemCompositeImplementation();
+ implementation.setClassLoader(getClass().getClassLoader());
+ componentDefinition = new ComponentDefinition<SystemCompositeImplementation>(implementation);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java
new file mode 100644
index 0000000000..e3a7deb10a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.idl.java;
+
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessor;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+import org.easymock.EasyMock;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceProcessorRegistryImplTestCase extends TestCase {
+ private JavaInterfaceProcessorRegistryImpl impl;
+
+ public void testSimpleInterface() throws InvalidServiceContractException {
+ JavaServiceContract contract = impl.introspect(Simple.class);
+ // TODO spec to clairfy interface name
+ assertEquals(JavaIntrospectionHelper.getBaseName(Simple.class), contract.getInterfaceName());
+ assertEquals(Simple.class, contract.getInterfaceClass());
+ Map<String, Operation<Type>> operations = contract.getOperations();
+ assertEquals(1, operations.size());
+ Operation<Type> baseInt = operations.get("baseInt");
+ assertNotNull(baseInt);
+
+ DataType<Type> returnType = baseInt.getOutputType();
+ assertEquals(Integer.TYPE, returnType.getPhysical());
+ assertEquals(Integer.TYPE, returnType.getLogical());
+
+ List<DataType<Type>> parameterTypes = baseInt.getInputType().getLogical();
+ assertEquals(1, parameterTypes.size());
+ DataType<Type> arg0 = parameterTypes.get(0);
+ assertEquals(Integer.TYPE, arg0.getPhysical());
+ assertEquals(Integer.TYPE, arg0.getLogical());
+
+ List<DataType<Type>> faultTypes = baseInt.getFaultTypes();
+ assertEquals(1, faultTypes.size());
+ DataType<Type> fault0 = faultTypes.get(0);
+ assertEquals(IllegalArgumentException.class, fault0.getPhysical());
+ assertEquals(IllegalArgumentException.class, fault0.getLogical());
+ }
+
+ public void testUnregister() throws Exception {
+ JavaInterfaceProcessor processor = createMock(JavaInterfaceProcessor.class);
+ processor.visitInterface(eq(Base.class), EasyMock.same((Class)null), isA(JavaServiceContract.class));
+ expectLastCall().once();
+ replay(processor);
+ impl.registerProcessor(processor);
+ impl.introspect(Base.class);
+ impl.unregisterProcessor(processor);
+ impl.introspect(Base.class);
+ verify(processor);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ impl = new JavaInterfaceProcessorRegistryImpl();
+
+ }
+
+ private static interface Base {
+ int baseInt(int param) throws IllegalArgumentException;
+ }
+
+ private static interface Simple extends Base {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java
new file mode 100644
index 0000000000..fb5e7fbb1f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessor;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl.Monitor;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IntrospectionRegistryTestCase extends TestCase {
+
+ private Monitor monitor;
+
+ public void testRegister() throws Exception {
+ IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(monitor);
+ ImplementationProcessor processor = EasyMock.createNiceMock(ImplementationProcessor.class);
+ registry.registerProcessor(processor);
+ }
+
+ public void testUnegister() throws Exception {
+ IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(monitor);
+ ImplementationProcessor processor = EasyMock.createNiceMock(ImplementationProcessor.class);
+ registry.registerProcessor(processor);
+ registry.unregisterProcessor(processor);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testWalk() throws Exception {
+ IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(monitor);
+ ImplementationProcessor processor = EasyMock.createMock(ImplementationProcessor.class);
+ processor.visitClass(EasyMock.isA(CompositeComponent.class),
+ EasyMock.eq(Bar.class),
+ EasyMock.isA(PojoComponentType.class),
+ EasyMock.isA(DeploymentContext.class));
+ processor.visitConstructor(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Constructor.class),
+ EasyMock.isA(PojoComponentType.class),
+ EasyMock.isA(DeploymentContext.class));
+ processor.visitMethod(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Method.class),
+ EasyMock.isA(PojoComponentType.class),
+ EasyMock.isA(DeploymentContext.class));
+ processor.visitField(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Field.class),
+ EasyMock.isA(PojoComponentType.class),
+ EasyMock.isA(DeploymentContext.class));
+ processor.visitSuperClass(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Class.class),
+ EasyMock.isA(PojoComponentType.class),
+ EasyMock.isA(DeploymentContext.class));
+ processor.visitEnd(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Class.class),
+ EasyMock.isA(PojoComponentType.class),
+ EasyMock.isA(DeploymentContext.class));
+
+ // mock.expects(once()).method("visitClass");
+// mock.expects(once()).method("visitMethod");
+// mock.expects(once()).method("visitField");
+// mock.expects(once()).method("visitConstructor");
+// mock.expects(once()).method("visitSuperClass");
+// mock.expects(once()).method("visitEnd");
+ EasyMock.replay(processor);
+ registry.registerProcessor(processor);
+ registry.introspect(EasyMock.createNiceMock(CompositeComponent.class),
+ Bar.class,
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>(),
+ EasyMock.createNiceMock(DeploymentContext.class));
+ EasyMock.verify(processor);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ monitor = new NullMonitorFactory().getMonitor(Monitor.class);
+ }
+
+ private class Baz {
+
+ }
+
+ private class Bar extends Baz {
+
+ protected String bar;
+
+ public Bar() {
+ }
+
+ public void bar() {
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java
new file mode 100644
index 0000000000..7d9e2a75ee
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Verfies specific autowire resolution scenarios
+ *
+ * @version $Rev$ $Date$
+ */
+public class AutowireResolutionTestCase extends TestCase {
+
+ public void testConstruction() {
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ replay(parent);
+ CompositeComponent component = new CompositeComponentImpl("test", parent, null, null);
+ assertEquals("test", component.getName());
+ assertSame(parent, component.getParent());
+ verify(parent);
+ }
+
+ public void testResolveToSelf() {
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ replay(parent);
+ CompositeComponent component = new CompositeComponentImpl("test", parent, null, null);
+ assertSame(component, component.resolveInstance(CompositeComponent.class));
+ verify(parent);
+ }
+
+ public void testSystemResolveToSelf() {
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ replay(parent);
+ CompositeComponent component = new CompositeComponentImpl("test", parent, null, null);
+ assertSame(component, component.resolveSystemInstance(CompositeComponent.class));
+ verify(parent);
+ }
+
+ public void testResolvedByAutowire() {
+ Foo foo = new Foo() {
+ };
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ EasyMock.expect(parent.resolveInstance(eq(Foo.class))).andReturn(foo);
+ replay(parent);
+ CompositeComponent component = new CompositeComponentImpl("test", parent, null, null);
+ assertSame(foo, component.resolveInstance(Foo.class));
+ verify(parent);
+ }
+
+ public void testSystemResolvedByAutowire() {
+ Foo foo = new Foo() {
+ };
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ EasyMock.expect(parent.resolveSystemInstance(eq(Foo.class))).andReturn(foo);
+ replay(parent);
+ CompositeComponent component = new CompositeComponentImpl("test", parent, null, null);
+ assertSame(foo, component.resolveSystemInstance(Foo.class));
+ verify(parent);
+ }
+
+ /**
+ * Verify parent resolution strategy for application services
+ */
+ public void testNamespaceIsolationAutowire() {
+ Foo foo = new Foo() {
+ };
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.registerJavaObject("foo", Foo.class, foo);
+ CompositeComponent component = new CompositeComponentImpl("test", parent, null, null);
+ assertNull(component.resolveInstance(Foo.class));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public static interface Foo {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java
new file mode 100644
index 0000000000..d565777cd2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.system.component.SystemReference;
+import org.apache.tuscany.core.implementation.system.component.SystemService;
+import org.easymock.EasyMock;
+
+/**
+ * Performs basic autowiring tests to composite artifacts
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class AutowireTestCase extends TestCase {
+
+ /**
+ * Tests autowiring to an system atomic component
+ */
+ public void testSystemAtomicAutowire() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.start();
+
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ interfaces.add(Source2.class);
+ Source originalSource = new SourceImpl();
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+
+ EasyMock.replay(component);
+ parent.register(component);
+
+ Source source = parent.resolveSystemInstance(Source.class);
+ assertNotNull(source);
+ Source2 source2 = parent.resolveSystemInstance(Source2.class);
+ assertSame(source, source2);
+ assertNull(parent.resolveSystemExternalInstance(Source.class));
+ EasyMock.verify(component);
+ }
+
+ /**
+ * Tests autowiring to an system atomic component
+ */
+ public void testAtomicAutowire() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.start();
+
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ interfaces.add(Source2.class);
+ Source originalSource = new SourceImpl();
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+
+ EasyMock.replay(component);
+ parent.register(component);
+
+ Source source = parent.resolveInstance(Source.class);
+ assertNotNull(source);
+ Source2 source2 = parent.resolveInstance(Source2.class);
+ assertSame(source, source2);
+ assertNull(parent.resolveExternalInstance(Source.class));
+ EasyMock.verify(component);
+ }
+
+ /**
+ * Tests autowiring to a system service which is wired to an atomic component.
+ */
+ public void testSystemServiceAutowire() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.start();
+
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ interfaces.add(Source2.class);
+
+ Source serviceSource = new SourceImpl();
+ SystemService component = EasyMock.createMock(SystemService.class);
+ EasyMock.expect(component.getName()).andReturn("service").atLeastOnce();
+ component.getInterface();
+ EasyMock.expectLastCall().andReturn(Source.class).atLeastOnce();
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(serviceSource);
+ EasyMock.replay(component);
+ parent.register(component);
+
+
+ SystemAtomicComponent component2 = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component2.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component2.getServiceInterfaces()).andReturn(interfaces).atLeastOnce();
+ EasyMock.expect(component2.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.replay(component2);
+ parent.register(component2);
+
+ Source source = parent.resolveSystemExternalInstance(Source.class);
+ assertSame(serviceSource, source);
+ Source2 source2 = parent.resolveSystemExternalInstance(Source2.class);
+ assertNull(source2);
+ EasyMock.verify(component);
+ EasyMock.verify(component2);
+ }
+
+ /**
+ * Tests autowiring to a system service which is wired to an atomic component.
+ */
+ public void testServiceAutowire() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.start();
+
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ interfaces.add(Source2.class);
+
+ Source serviceSource = new SourceImpl();
+ Service component = EasyMock.createMock(Service.class);
+ EasyMock.expect(component.getName()).andReturn("service").atLeastOnce();
+ component.getInterface();
+ EasyMock.expectLastCall().andReturn(Source.class).atLeastOnce();
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(serviceSource);
+ EasyMock.replay(component);
+ parent.register(component);
+
+
+ AtomicComponent component2 = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component2.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component2.getServiceInterfaces()).andReturn(interfaces).atLeastOnce();
+ EasyMock.expect(component2.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.replay(component2);
+ parent.register(component2);
+
+ Source source = parent.resolveExternalInstance(Source.class);
+ assertSame(serviceSource, source);
+ Source2 source2 = parent.resolveExternalInstance(Source2.class);
+ assertNull(source2);
+ EasyMock.verify(component);
+ EasyMock.verify(component2);
+ }
+
+
+ /**
+ * Tests autowiring to a system reference
+ */
+ public void testSystemReferenceAutowire() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.start();
+
+ Source refSource = new SourceImpl();
+ SystemReference reference = EasyMock.createMock(SystemReference.class);
+ EasyMock.expect(reference.getName()).andReturn("service").atLeastOnce();
+ EasyMock.expect(reference.getServiceInstance()).andReturn(refSource);
+ EasyMock.expect(reference.isSystem()).andReturn(true).atLeastOnce();
+ reference.getInterface();
+ EasyMock.expectLastCall().andReturn(Source.class);
+ EasyMock.replay(reference);
+ parent.register(reference);
+
+ Source source = parent.resolveSystemInstance(Source.class);
+ assertNotNull(source);
+ assertNull(parent.resolveSystemExternalInstance(Source.class));
+ EasyMock.verify(reference);
+ }
+
+ /**
+ * Tests autowiring to a reference
+ */
+ public void testReferenceAutowire() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ parent.start();
+ Source refSource = new SourceImpl();
+ Reference reference = EasyMock.createMock(Reference.class);
+ EasyMock.expect(reference.getName()).andReturn("service").atLeastOnce();
+ EasyMock.expect(reference.getServiceInstance()).andReturn(refSource);
+ EasyMock.expect(reference.isSystem()).andReturn(false).atLeastOnce();
+ reference.getInterface();
+ EasyMock.expectLastCall().andReturn(Source.class);
+ EasyMock.replay(reference);
+ parent.register(reference);
+
+ Source source = parent.resolveInstance(Source.class);
+ assertNotNull(source);
+ assertNull(parent.resolveExternalInstance(Source.class));
+ EasyMock.verify(reference);
+ }
+
+
+ public static class SourceImpl implements Source, Source2 {
+ public SourceImpl() {
+ }
+ }
+
+ public static interface Source {
+
+ }
+
+ public static interface Source2 {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java
new file mode 100644
index 0000000000..fb665a55f4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.builder.BuilderRegistryImpl;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
+import org.apache.tuscany.core.implementation.java.JavaImplementation;
+import org.apache.tuscany.core.implementation.java.mock.components.OtherTarget;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class CompositeBuilderTestCase extends TestCase {
+ private DeploymentContext deploymentContext;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ScopeContainer mock = createMock();
+ deploymentContext = new RootDeploymentContext(null, null, mock, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuildConnect() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);
+
+ CompositeBuilder builder = new CompositeBuilder();
+ WireService wireService = new JDKWireService();
+ builder.setWireService(wireService);
+ BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl();
+ builderRegistry.setWireService(wireService);
+ JavaComponentBuilder jBuilder = new JavaComponentBuilder();
+ jBuilder.setWireService(wireService);
+ builderRegistry.register(JavaImplementation.class, jBuilder);
+ builderRegistry.register(CompositeImplementation.class, builder);
+ CompositeBindlessBuilder bindlessBuilder = new CompositeBindlessBuilder();
+ bindlessBuilder.setWireService(wireService);
+ builderRegistry.register(bindlessBuilder);
+ builder.setBuilderRegistry(builderRegistry);
+ CompositeComponent component =
+ (CompositeComponent) builder.build(parent, createTopComponentDef(), deploymentContext);
+
+ ConnectorImpl connector = new ConnectorImpl();
+ connector.connect(component);
+
+ deploymentContext.getModuleScope().start();
+ component.start();
+ CompositeComponent sourceComponent = (CompositeComponent) component.getChild("SourceComponent");
+ Source source = (Source) sourceComponent.getServiceInstance("InnerSourceService");
+ assertNotNull(source);
+ AtomicComponent innerSourceComponent = (AtomicComponent) sourceComponent.getChild("InnerSourceComponent");
+ Source innerSourceInstance = (Source) deploymentContext.getModuleScope().getInstance(innerSourceComponent);
+ assertNotNull(innerSourceInstance);
+ component.stop();
+ }
+
+ private ComponentDefinition createTopComponentDef() throws Exception {
+
+ CompositeComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> outerType =
+ new CompositeComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ outerType.add(createSourceComponentDef());
+ outerType.add(createTargetComponentDef());
+
+ CompositeImplementation outerImpl = new CompositeImplementation();
+ outerImpl.setComponentType(outerType);
+
+ return new ComponentDefinition<CompositeImplementation>(outerImpl);
+ }
+
+ private ComponentDefinition<CompositeImplementation> createSourceComponentDef() throws Exception {
+
+ CompositeComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>> innerType =
+ new CompositeComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>>();
+ innerType.add(createInnerSourceComponentDef());
+ ReferenceDefinition reference = new ReferenceDefinition();
+ reference.setName("TargetComponentRef");
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ JavaServiceContract targetContract = registry.introspect(Target.class);
+ reference.setServiceContract(targetContract);
+ innerType.add(reference);
+ BindlessServiceDefinition service = new BindlessServiceDefinition();
+ service.setName("InnerSourceService");
+ JavaServiceContract sourceContract = registry.introspect(Source.class);
+ service.setServiceContract(sourceContract);
+ service.setTarget(new URI("InnerSourceComponent"));
+ innerType.add(service);
+
+ CompositeImplementation innerImpl = new CompositeImplementation();
+ innerImpl.setComponentType(innerType);
+
+ ComponentDefinition<CompositeImplementation> sourceComponentDefinition =
+ new ComponentDefinition<CompositeImplementation>("SourceComponent", innerImpl);
+ ReferenceTarget refTarget = new ReferenceTarget();
+ refTarget.setReferenceName("TargetComponentRef");
+ refTarget.addTarget(new URI("TargetComponent"));
+ sourceComponentDefinition.add(refTarget);
+
+ return sourceComponentDefinition;
+ }
+
+ private ComponentDefinition<JavaImplementation> createInnerSourceComponentDef() throws Exception {
+
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> sourceType =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ sourceType.setImplementationScope(Scope.MODULE);
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setName("targetReference");
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> targetContract = registry.introspect(Target.class);
+ targetContract.setCallbackClass(OtherTarget.class);
+ targetContract.setCallbackName("OtherTarget");
+ reference.setServiceContract(targetContract);
+ reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
+ sourceType.add(reference);
+
+ ServiceContract<?> sourceContract = registry.introspect(Source.class);
+
+ JavaMappedService sourceServiceDefinition = new JavaMappedService();
+ sourceServiceDefinition.setName("Source");
+ sourceServiceDefinition.setServiceContract(sourceContract);
+
+ sourceType.add(sourceServiceDefinition);
+ sourceType.setConstructorDefinition(new ConstructorDefinition<SourceImpl>(SourceImpl.class.getConstructor()));
+ JavaImplementation sourceImpl = new JavaImplementation();
+ sourceImpl.setComponentType(sourceType);
+ sourceImpl.setImplementationClass(SourceImpl.class);
+ ComponentDefinition<JavaImplementation> innerSourceComponentDefinition =
+ new ComponentDefinition<JavaImplementation>("InnerSourceComponent", sourceImpl);
+ ReferenceTarget refTarget = new ReferenceTarget();
+ refTarget.setReferenceName("targetReference");
+ refTarget.addTarget(new URI("TargetComponentRef"));
+ innerSourceComponentDefinition.add(refTarget);
+
+ return innerSourceComponentDefinition;
+ }
+
+ private ComponentDefinition<JavaImplementation> createTargetComponentDef() throws Exception {
+
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> targetType =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ targetType.setImplementationScope(Scope.MODULE);
+
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> targetContract = registry.introspect(Target.class);
+ targetContract.setCallbackClass(OtherTarget.class);
+ targetContract.setCallbackName("OtherTarget");
+
+ JavaMappedService serviceDefinition = new JavaMappedService();
+ serviceDefinition.setName("Target");
+ serviceDefinition.setServiceContract(targetContract);
+ serviceDefinition.setCallbackReferenceName("otherTarget");
+
+ targetType.add(serviceDefinition);
+ targetType.setConstructorDefinition(new ConstructorDefinition<TargetImpl>(TargetImpl.class.getConstructor()));
+ JavaImplementation targetImpl = new JavaImplementation();
+ targetImpl.setComponentType(targetType);
+ targetImpl.setImplementationClass(TargetImpl.class);
+ return new ComponentDefinition<JavaImplementation>("TargetComponent", targetImpl);
+ }
+
+ private ScopeContainer createMock() {
+ ScopeContainer container = EasyMock.createMock(ScopeContainer.class);
+ container.start();
+ container.register(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().anyTimes();
+ EasyMock.expect(container.getScope()).andReturn(Scope.MODULE).anyTimes();
+ EasyMock.expect(container.getInstance(EasyMock.isA(AtomicComponent.class))).andAnswer(new IAnswer<Object>() {
+ private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+ public Object answer() throws Throwable {
+ AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
+ Object instance = cache.get(component);
+ if (instance == null) {
+ instance = component.createInstance();
+ cache.put(component, instance);
+ }
+ return instance;
+ }
+ });
+ EasyMock.replay(container);
+ return container;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java
new file mode 100644
index 0000000000..8694d9ddc6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.component.ComponentNotFoundException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.IllegalTargetException;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentImplBasicTestCase extends TestCase {
+
+ public void testGetScope() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ Assert.assertEquals(Scope.COMPOSITE, composite.getScope());
+ }
+
+ public void testGetChildren() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(new ServiceExtension("foo", null, null, null));
+ Assert.assertEquals(1, composite.getChildren().size());
+ }
+
+ public void testGetServices() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(new ServiceExtension("foo", null, null, null));
+ composite.register(getReference("bar"));
+ Assert.assertEquals(1, composite.getServices().size());
+ }
+
+ public void testGetService() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(new ServiceExtension("foo", null, null, null));
+ composite.start();
+ assertNotNull(composite.getService("foo"));
+ }
+
+ public void testServiceNotFound() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(new ServiceExtension("foo", null, null, null));
+ composite.start();
+ try {
+ composite.getService("bar");
+ fail();
+ } catch (ComponentNotFoundException e) {
+ // expected
+ }
+ }
+
+ public void testNotService() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(getReference("foo"));
+ composite.start();
+ try {
+ composite.getService("foo");
+ fail();
+ } catch (ComponentNotFoundException e) {
+ // expected
+ }
+ }
+
+ public void testTargetNotFound() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(getReference("foo"));
+ composite.start();
+ try {
+ composite.locateService(Foo.class, "foo1");
+ fail();
+ } catch (TargetNotFoundException e) {
+ // expected
+ }
+ }
+
+ public void testReferencesServices() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.register(new ServiceExtension("foo", null, null, null));
+ composite.register(getReference("bar"));
+ Assert.assertEquals(1, composite.getReferences().size());
+ }
+
+ public void testServiceInterfaces() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ Service service1 = getService("foo", Foo.class);
+ composite.register(service1);
+ Service service2 = getService("bar", Bar.class);
+ composite.register(service2);
+
+ List<Class<?>> interfaces = composite.getServiceInterfaces();
+ assertEquals(2, interfaces.size());
+ for (Class o : interfaces) {
+ if (!(Foo.class.isAssignableFrom(o)) && !(Bar.class.isAssignableFrom(o))) {
+ fail();
+ }
+ }
+ }
+
+ public void testGetServiceInstanceByName() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ Service service = createMock(Service.class);
+ EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+ service.getName();
+ expectLastCall().andReturn("foo").anyTimes();
+ service.getInterface();
+ expectLastCall().andReturn(Foo.class);
+ service.getServiceInstance();
+ expectLastCall().andReturn(new Foo() {
+ });
+ replay(service);
+ composite.register(service);
+ assertNotNull(composite.getServiceInstance("foo"));
+ }
+
+ public void testGetServiceInstanceNotFound() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ Service service = getService("foo", Foo.class);
+ composite.register(service);
+ try {
+ composite.getServiceInstance("bar");
+ fail();
+ } catch (TargetNotFoundException e) {
+ //expected
+ }
+ }
+
+ public void testGetServiceInstanceNotService() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ Reference reference = getReference("foo");
+ composite.register(reference);
+ try {
+ composite.getServiceInstance("foo");
+ fail();
+ } catch (IllegalTargetException e) {
+ //expected
+ }
+ }
+
+ public void testOnEvent() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ Event event = new Event() {
+ public Object getSource() {
+ return null;
+ }
+ };
+ RuntimeEventListener listener = createMock(RuntimeEventListener.class);
+ listener.onEvent(isA(CompositeStart.class));
+ listener.onEvent(eq(event));
+ expectLastCall();
+ replay(listener);
+ composite.addListener(listener);
+ composite.start();
+ composite.onEvent(event);
+ }
+
+ public void testPrepare() {
+ CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
+ composite.prepare();
+ }
+
+ private Reference getReference(String name) {
+ Reference reference = EasyMock.createNiceMock(Reference.class);
+ EasyMock.expect(reference.isSystem()).andReturn(false).atLeastOnce();
+ reference.getName();
+ expectLastCall().andReturn(name).anyTimes();
+ reference.getInterface();
+ expectLastCall().andReturn(Object.class).atLeastOnce();
+ replay(reference);
+ return reference;
+ }
+
+ private Service getService(String name, Class<?> interfaze) {
+ Service service = createMock(Service.class);
+ EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+ service.getName();
+ expectLastCall().andReturn(name).anyTimes();
+ service.getInterface();
+ expectLastCall().andReturn(interfaze).atLeastOnce();
+ replay(service);
+ return service;
+ }
+
+ private interface Foo {
+ }
+
+ private interface Bar {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java
new file mode 100644
index 0000000000..c3bf846400
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentImplSystemWireTestCase extends TestCase {
+
+ /**
+ * Verifies system services in a CompositeComponentImpl are wired during the parent composite's prepare callback
+ */
+ public void testSystemServiceWire() {
+ InboundWire inbound = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(inbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class));
+ inbound.getInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ QualifiedName qName = new QualifiedName("target/bar");
+ OutboundWire outbound = EasyMock.createMock(OutboundWire.class);
+ EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce();
+ outbound.getInvocationChains();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ outbound.setTargetWire(EasyMock.eq(inbound));
+ EasyMock.expect(outbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce();
+ List<OutboundWire> wires = new ArrayList<OutboundWire>();
+ wires.add(outbound);
+ Map<String, List<OutboundWire>> wireMap = new HashMap<String, List<OutboundWire>>();
+ wireMap.put("ref", wires);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null);
+ SystemAtomicComponent source = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(source.getScope()).andReturn(Scope.MODULE).atLeastOnce();
+ EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(source.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
+ source.getInboundWires();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
+
+ source.prepare();
+ EasyMock.replay(source);
+
+ EasyMock.expect(outbound.getContainer()).andReturn(source);
+ EasyMock.replay(outbound);
+
+ parent.register(source);
+
+ SystemAtomicComponent target = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(target.getName()).andReturn("target").atLeastOnce();
+ EasyMock.expect(target.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(target.getInboundWire("bar")).andReturn(inbound).atLeastOnce();
+ EasyMock.expect(target.getScope()).andReturn(Scope.MODULE).atLeastOnce();
+ EasyMock.expect(target.getParent()).andReturn(parent).atLeastOnce();
+ target.getInboundWires();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+
+ target.prepare();
+ target.getOutboundWires();
+ EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+ EasyMock.expect(target.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.replay(target);
+
+ EasyMock.expect(inbound.getContainer()).andReturn(target);
+ EasyMock.replay(inbound);
+
+ parent.register(target);
+ parent.prepare();
+ EasyMock.verify(source);
+ EasyMock.verify(target);
+ EasyMock.verify(inbound);
+ EasyMock.verify(outbound);
+ }
+
+
+ /**
+ * Verifies an application component cannot be wired to a system service in the same composite
+ */
+ public void testSystemServiceIsolationWire() {
+ InboundWire inbound = EasyMock.createMock(InboundWire.class);
+ EasyMock.replay(inbound);
+
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ QualifiedName qName = new QualifiedName("target/bar");
+ OutboundWire outbound = EasyMock.createMock(OutboundWire.class);
+ EasyMock.expect(outbound.getReferenceName()).andReturn("foo");
+ EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce();
+ EasyMock.replay(outbound);
+
+ List<OutboundWire> wires = new ArrayList<OutboundWire>();
+ wires.add(outbound);
+ Map<String, List<OutboundWire>> wireMap = new HashMap<String, List<OutboundWire>>();
+ wireMap.put("ref", wires);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null);
+ SystemAtomicComponent source = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(source.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
+ EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
+ EasyMock.replay(source);
+
+ parent.register(source);
+
+ AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(target.getName()).andReturn("target").atLeastOnce();
+ EasyMock.expect(target.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.replay(target);
+
+ parent.register(target);
+ try {
+ parent.prepare();
+ fail();
+ } catch (BuilderConfigException e) {
+ //expected
+ }
+ EasyMock.verify(source);
+ EasyMock.verify(target);
+ EasyMock.verify(inbound);
+ EasyMock.verify(outbound);
+ }
+
+
+ private class Foo {
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java
new file mode 100644
index 0000000000..29df7f0f85
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentImplTestCase extends TestCase {
+
+ public void testSetUri() throws Exception {
+ CompositeComponentImpl component = new CompositeComponentImpl("foo", "foo/bar", null, null, null);
+ assertEquals("foo/bar", component.getURI());
+ }
+
+ public void testRegisterSystemService() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.replay(component);
+ parent.register(component);
+ assertNull(parent.getChild("bar"));
+ assertNotNull(parent.getSystemChild("bar"));
+ EasyMock.verify(component);
+ }
+
+ public void testRegister() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.replay(component);
+ parent.register(component);
+ assertNull(parent.getSystemChild("bar"));
+ assertNotNull(parent.getChild("bar"));
+ EasyMock.verify(component);
+ }
+
+ /**
+ * Verifies a system service and application component can be registered with the same name in a composite
+ */
+ public void testSystemServiceApplicationNamespaceIsolation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.replay(component);
+ parent.register(component);
+ AtomicComponent component2 = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component2.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component2.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component2.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.replay(component2);
+ parent.register(component2);
+ EasyMock.verify(component);
+ EasyMock.verify(component2);
+ }
+
+ public void testSystemServiceLifecycle() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ component.start();
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ component.stop();
+ EasyMock.replay(component);
+ parent.register(component);
+ parent.start();
+ parent.stop();
+ EasyMock.verify(component);
+ }
+
+ public void testComponentLifecycle() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ component.start();
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ component.stop();
+ EasyMock.replay(component);
+ parent.register(component);
+ parent.start();
+ parent.stop();
+ EasyMock.verify(component);
+ }
+
+ public void testSystemServiceAutowire() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ component.start();
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.getServiceInstance()).andReturn(new Foo() {
+ });
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ component.stop();
+ EasyMock.replay(component);
+ parent.register(component);
+ parent.start();
+ assertNull(parent.resolveSystemExternalInstance(Foo.class));
+ assertNotNull(parent.resolveSystemInstance(Foo.class));
+ parent.stop();
+ EasyMock.verify(component);
+ }
+
+
+ public void testAutowire() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Foo.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ component.start();
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.getServiceInstance()).andReturn(new Foo() {
+ });
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ component.stop();
+ EasyMock.replay(component);
+ parent.register(component);
+ parent.start();
+ assertNull(parent.resolveExternalInstance(Foo.class));
+ assertNotNull(parent.resolveInstance(Foo.class));
+ parent.stop();
+ EasyMock.verify(component);
+ }
+
+ private class Foo {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java
new file mode 100644
index 0000000000..0ad1e6f649
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ComponentNotFoundException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Source;
+import org.apache.tuscany.core.mock.component.SourceImpl;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies an atomic component can be resolved from its parent
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class CompositeComponentResolutionTestCase extends TestCase {
+
+ public void testSystemComponentResolution() throws NoSuchMethodException {
+ CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
+ parent.start();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ Source originalSource = new SourceImpl();
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component);
+ parent.register(component);
+ assertNull(parent.getChild("source"));
+ AtomicComponent target = (AtomicComponent) parent.getSystemChild("source");
+ Source source = (Source) target.getServiceInstance();
+ assertNotNull(source);
+ EasyMock.verify(component);
+ }
+
+ public void testLocateSystemService() throws NoSuchMethodException {
+ CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
+ parent.start();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ Source originalSource = new SourceImpl();
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component);
+ parent.register(component);
+ Source source = parent.locateSystemService(Source.class, "source");
+ assertNotNull(source);
+ EasyMock.verify(component);
+ }
+
+ public void testLocateService() throws NoSuchMethodException {
+ CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
+ parent.start();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ Source originalSource = new SourceImpl();
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component);
+ parent.register(component);
+ Source source = parent.locateService(Source.class, "source");
+ assertNotNull(source);
+ EasyMock.verify(component);
+ }
+
+ public void testComponentResolution() throws NoSuchMethodException {
+ CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
+ parent.start();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ Source originalSource = new SourceImpl();
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource);
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component);
+ parent.register(component);
+ assertNull(parent.getSystemChild("source"));
+ AtomicComponent target = (AtomicComponent) parent.getChild("source");
+ Source source = (Source) target.getServiceInstance();
+ assertNotNull(source);
+ EasyMock.verify(component);
+ }
+
+
+ public void testGetService() throws NoSuchMethodException {
+ CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
+ parent.start();
+ Service service = EasyMock.createMock(Service.class);
+ EasyMock.expect(service.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+ service.getInterface();
+ EasyMock.expectLastCall().andReturn(Source.class);
+ EasyMock.replay(service);
+ parent.register(service);
+ assertNotNull(parent.getService("source"));
+ try {
+ parent.getSystemService("source");
+ fail();
+ } catch (ComponentNotFoundException e) {
+ // expected
+ }
+ EasyMock.verify(service);
+ }
+
+ public void testSystemGetService() throws NoSuchMethodException {
+ CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
+ parent.start();
+ Service service = EasyMock.createMock(Service.class);
+ EasyMock.expect(service.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce();
+ service.getInterface();
+ EasyMock.expectLastCall().andReturn(Source.class);
+ EasyMock.replay(service);
+ parent.register(service);
+ assertNotNull(parent.getSystemService("source"));
+ try {
+ parent.getService("source");
+ fail();
+ } catch (ComponentNotFoundException e) {
+ // expected
+ }
+ EasyMock.verify(service);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java
new file mode 100644
index 0000000000..5b0af72caa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Source;
+import org.apache.tuscany.core.mock.component.SourceImpl;
+import org.easymock.EasyMock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class CompositeLifecycleTestCase extends TestCase {
+
+ public void testLifecycle() throws Exception {
+ CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null);
+ composite.start();
+ assertNull(composite.getChild("nothtere"));
+ composite.stop();
+ composite.start();
+ assertNull(composite.getChild("nothtere"));
+ composite.stop();
+ }
+
+ public void testSystemRestart() throws NoSuchMethodException {
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ Source originalSource = new SourceImpl();
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ component.start();
+ component.stop();
+ EasyMock.expectLastCall().times(2);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component);
+
+ CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null);
+ composite.start();
+ composite.register(component);
+
+ AtomicComponent atomicComponent = (AtomicComponent) composite.getSystemChild("source");
+ Source source = (Source) atomicComponent.getServiceInstance();
+ assertNotNull(source);
+ composite.stop();
+ composite.start();
+ atomicComponent = (AtomicComponent) composite.getSystemChild("source");
+ Source source2 = (Source) atomicComponent.getServiceInstance();
+ assertNotNull(source2);
+ composite.stop();
+ EasyMock.verify(component);
+ }
+
+ public void testRestart() throws NoSuchMethodException {
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ Source originalSource = new SourceImpl();
+ AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+ component.start();
+ component.stop();
+ EasyMock.expectLastCall().times(2);
+ EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ EasyMock.expect(component.getServiceInstance()).andReturn(originalSource).atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component);
+
+ CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null);
+ composite.start();
+ composite.register(component);
+
+ AtomicComponent atomicComponent = (AtomicComponent) composite.getChild("source");
+ Source source = (Source) atomicComponent.getServiceInstance();
+ assertNotNull(source);
+ composite.stop();
+ composite.start();
+ atomicComponent = (AtomicComponent) composite.getChild("source");
+ Source source2 = (Source) atomicComponent.getServiceInstance();
+ assertNotNull(source2);
+ composite.stop();
+ EasyMock.verify(component);
+ }
+
+ public void testChildStoppedBeforeParent() {
+ CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
+ CompositeComponent child = new CompositeComponentImpl("child", null, null, null);
+ parent.register(child);
+ parent.start();
+ child.stop();
+ parent.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java
new file mode 100644
index 0000000000..69b8c3f34f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Source;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositePropagationTestCase extends TestCase {
+
+ private CompositeComponent parent;
+ private CompositeComponent child2;
+
+ public void testSystemLifecyclePropagation() throws NoSuchMethodException {
+ parent.start();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ SystemAtomicComponent component = createMock(SystemAtomicComponent.class);
+ expect(component.getName()).andReturn("source").anyTimes();
+ component.stop();
+ expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ replay(component);
+ child2.register(component);
+ parent.stop();
+ verify(component);
+ }
+
+ public void testLifecyclePropagation() throws NoSuchMethodException {
+ parent.start();
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ SystemAtomicComponent component = createMock(SystemAtomicComponent.class);
+ expect(component.getName()).andReturn("source").anyTimes();
+ component.stop();
+ expect(component.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+ replay(component);
+ child2.register(component);
+ parent.stop();
+ verify(component);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ parent = new CompositeComponentImpl("parent", null, null, null);
+ CompositeComponent child1 = new CompositeComponentImpl("child1", parent, null, null);
+ child2 = new CompositeComponentImpl("child2", child1, null, null);
+ child1.register(child2);
+ parent.register(child1);
+ }
+
+ protected void tearDown() throws Exception {
+ parent.stop();
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java
new file mode 100644
index 0000000000..b1e850d703
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceCallbackTargetInvokerInvocationExceptionTestCase extends TestCase {
+ private InboundWire wire;
+ private WorkContext context;
+ private Message message;
+ private OutboundInvocationChain chain;
+ private CompositeReferenceCallbackTargetInvoker invoker;
+
+ /**
+ * Verfies an InvocationTargetException thrown when invoking the target is propagated to the client correctly and
+ * the originating error is unwrapped
+ */
+ public void testThrowableTargetInvocation() throws Exception {
+ Message response = invoker.invoke(message);
+ assertTrue(response.isFault());
+ Object body = response.getBody();
+ assertTrue(SomeException.class.equals(body.getClass()));
+ EasyMock.verify(wire);
+ EasyMock.verify(context);
+ EasyMock.verify(chain);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object id = new Object();
+ Object corrId = new Object();
+ Object targetAddress = new Object();
+ message = new MessageImpl();
+ message.setMessageId(id);
+ message.setCorrelationId(corrId);
+ message.setBody("foo");
+ Message response = new MessageImpl();
+ response.setBody("response");
+ Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+ Interceptor head = new ErrorInterceptor();
+ chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+ EasyMock.replay(chain);
+ Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ chains.put(operation, chain);
+ wire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(wire.retrieveMapping(corrId)).andReturn(targetAddress);
+ EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains);
+ EasyMock.expect(wire.getContainer()).andReturn(null);
+ EasyMock.replay(wire);
+ context = EasyMock.createMock(WorkContext.class);
+ context.setCurrentMessageId(EasyMock.eq(id));
+ context.setCurrentMessageId(EasyMock.isNull());
+ context.setCurrentCorrelationId(corrId);
+ context.setCurrentCorrelationId(EasyMock.isNull());
+ EasyMock.expect(context.getCurrentMessageId()).andReturn(id);
+ EasyMock.expect(context.getCurrentCorrelationId()).andReturn(corrId);
+ EasyMock.replay(context);
+ invoker = new CompositeReferenceCallbackTargetInvoker(operation, wire, context);
+ }
+
+ private class SomeException extends Exception {
+
+ }
+
+ private class ErrorInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ msg.setBodyWithFault(new SomeException());
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java
new file mode 100644
index 0000000000..8e047e3ad1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerTestCase.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceCallbackTargetInvokerTestCase extends TestCase {
+ private InboundWire wire;
+ private WorkContext context;
+ private Message message;
+ private OutboundInvocationChain chain;
+ private Interceptor head;
+ private CompositeReferenceCallbackTargetInvoker invoker;
+
+ /**
+ * Verfies the normal execution path through a callback
+ */
+ public void testNormalPathMessageInvocation() throws Exception {
+ Message response = invoker.invoke(message);
+ assertEquals("response", response.getBody());
+ EasyMock.verify(wire);
+ EasyMock.verify(context);
+ EasyMock.verify(chain);
+ EasyMock.verify(head);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object id = new Object();
+ Object corrId = new Object();
+ Object targetAddress = new Object();
+ message = new MessageImpl();
+ message.setMessageId(id);
+ message.setCorrelationId(corrId);
+ message.setBody("foo");
+ Message response = new MessageImpl();
+ response.setBody("response");
+ Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+ head = EasyMock.createMock(Interceptor.class);
+ EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andReturn(response);
+ EasyMock.replay(head);
+ chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+ EasyMock.replay(chain);
+ Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ chains.put(operation, chain);
+ wire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(wire.retrieveMapping(corrId)).andReturn(targetAddress);
+ EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains);
+ EasyMock.expect(wire.getContainer()).andReturn(null);
+ EasyMock.replay(wire);
+ context = EasyMock.createMock(WorkContext.class);
+ context.setCurrentMessageId(EasyMock.eq(id));
+ context.setCurrentMessageId(EasyMock.isNull());
+ context.setCurrentCorrelationId(corrId);
+ context.setCurrentCorrelationId(EasyMock.isNull());
+ EasyMock.expect(context.getCurrentMessageId()).andReturn(id);
+ EasyMock.expect(context.getCurrentCorrelationId()).andReturn(corrId);
+ EasyMock.replay(context);
+ invoker = new CompositeReferenceCallbackTargetInvoker(operation, wire, context);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java
new file mode 100644
index 0000000000..462b6a5680
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceCallbackTargetInvokerThrowableTestCase.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.Type;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeReferenceCallbackTargetInvokerThrowableTestCase extends TestCase {
+ private InboundWire wire;
+ private WorkContext context;
+ private Message message;
+ private OutboundInvocationChain chain;
+ private Interceptor head;
+ private CompositeReferenceCallbackTargetInvoker invoker;
+
+ /**
+ * Verfies an exception thrown in the target is propagated to the client correctly
+ */
+ public void testThrowableTargetInvocation() throws Exception {
+ Message response = invoker.invoke(message);
+ assertTrue(response.isFault());
+ Object body = response.getBody();
+ if (!(body instanceof UndeclaredThrowableException)) {
+ fail(); // EasyMock wraps the Throwable in an UndeclaredThrowableException
+ }
+ UndeclaredThrowableException e = (UndeclaredThrowableException) body;
+ assertTrue(InsidiousException.class.equals(e.getUndeclaredThrowable().getClass()));
+ EasyMock.verify(wire);
+ EasyMock.verify(context);
+ EasyMock.verify(chain);
+ EasyMock.verify(head);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Object id = new Object();
+ Object corrId = new Object();
+ Object targetAddress = new Object();
+ message = new MessageImpl();
+ message.setMessageId(id);
+ message.setCorrelationId(corrId);
+ message.setBody("foo");
+ Message response = new MessageImpl();
+ response.setBody("response");
+ Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+ head = EasyMock.createMock(Interceptor.class);
+ EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ throw new InsidiousException(); // andThrow() does not seem to work here
+ }
+ });
+ EasyMock.replay(head);
+ chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+ EasyMock.replay(chain);
+ Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ chains.put(operation, chain);
+ wire = EasyMock.createMock(InboundWire.class);
+ EasyMock.expect(wire.retrieveMapping(corrId)).andReturn(targetAddress);
+ EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains);
+ EasyMock.expect(wire.getContainer()).andReturn(null);
+ EasyMock.replay(wire);
+ context = EasyMock.createMock(WorkContext.class);
+ context.setCurrentMessageId(EasyMock.eq(id));
+ context.setCurrentMessageId(EasyMock.isNull());
+ context.setCurrentCorrelationId(corrId);
+ context.setCurrentCorrelationId(EasyMock.isNull());
+ EasyMock.expect(context.getCurrentMessageId()).andReturn(id);
+ EasyMock.expect(context.getCurrentCorrelationId()).andReturn(corrId);
+ EasyMock.replay(context);
+ invoker = new CompositeReferenceCallbackTargetInvoker(operation, wire, context);
+ }
+
+ private class InsidiousException extends Throwable {
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java
new file mode 100644
index 0000000000..fe62691820
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeReferenceTestCase.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class CompositeReferenceTestCase extends TestCase {
+
+ public void testCreateTargetInvoker() throws Exception {
+
+ MyServiceContract serviceContract = new MyServiceContract();
+ CompositeReference compositeReference = new CompositeReference("testCompositeReferemce",
+ null,
+ null,
+ serviceContract,
+ null);
+ Operation operation = new Operation<Type>("sayHi", null, null, null, false, null);
+ TargetInvoker targetInvoker = compositeReference.createTargetInvoker(serviceContract, operation);
+ assertNotNull(targetInvoker);
+ }
+
+ public void testCreateCallbackTargetInvoker() throws Exception {
+
+ MyServiceContract serviceContract = new MyServiceContract();
+ CompositeReference compositeReference = new CompositeReference("testCompositeReferemce",
+ null,
+ null,
+ serviceContract,
+ null);
+ Operation operation = new Operation<Type>("sayHi", null, null, null, false, null);
+ TargetInvoker targetInvoker = compositeReference.createCallbackTargetInvoker(serviceContract, operation);
+ assertNotNull(targetInvoker);
+ }
+
+ class MyServiceContract extends ServiceContract {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java
new file mode 100644
index 0000000000..33235983b9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.DuplicateNameException;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Source;
+import org.easymock.EasyMock;
+
+/**
+ * Verfies children with the same name cannot be registered in the same composite
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateRegistrationTestCase extends TestCase {
+
+ public void testDuplicateRegistration() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);
+ parent.start();
+
+ List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ interfaces.add(Source.class);
+ SystemAtomicComponent component1 = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component1.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component1.isSystem()).andReturn(true).atLeastOnce();
+ component1.stop();
+ EasyMock.expect(component1.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component1);
+
+ SystemAtomicComponent component2 = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component2.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(component2.isSystem()).andReturn(true).atLeastOnce();
+ component2.stop();
+ EasyMock.expect(component2.getServiceInterfaces()).andReturn(interfaces);
+ EasyMock.replay(component2);
+
+ parent.register(component1);
+ try {
+ parent.register(component2);
+ fail();
+ } catch (DuplicateNameException e) {
+ // ok
+ }
+ parent.stop();
+ }
+
+ public void testDuplicateNameSystemService() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Source.class);
+ CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null);
+ SystemAtomicComponent component = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.replay(component);
+ parent.register(component);
+ SystemAtomicComponent component2 = EasyMock.createMock(SystemAtomicComponent.class);
+ EasyMock.expect(component2.getName()).andReturn("bar").atLeastOnce();
+ EasyMock.expect(component2.getServiceInterfaces()).andReturn(services);
+ EasyMock.expect(component2.isSystem()).andReturn(true).atLeastOnce();
+ EasyMock.replay(component2);
+ try {
+ parent.register(component2);
+ fail();
+ } catch (DuplicateNameException e) {
+ // expected
+ }
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java
new file mode 100644
index 0000000000..67efb6fd4c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reportMatcher;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IArgumentMatcher;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.deployer.CompositeClassLoader;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImplementationCompositeLoaderTestCase extends TestCase {
+ private static final QName IMPLEMENTATION_COMPOSITE = new QName(XML_NAMESPACE_1_0, "implementation.composite");
+
+ private ClassLoader cl;
+ private ImplementationCompositeLoader loader;
+ private XMLStreamReader reader;
+ private DeploymentContext context;
+ private ArtifactRepository artifactRepository;
+
+ public void testName() throws LoaderException, XMLStreamException, MalformedURLException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "group")).andReturn(null);
+ expect(reader.getAttributeValue(null, "version")).andReturn(null);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null);
+ expect(reader.getAttributeValue(null, "jarLocation")).andReturn(null);
+ expect(reader.next()).andReturn(END_ELEMENT);
+ replay(reader);
+
+ replay(context);
+ replay(artifactRepository);
+
+ CompositeImplementation impl = loader.load(null, reader, context);
+ verify(reader);
+ verify(context);
+ verify(artifactRepository);
+ assertEquals(name, impl.getName());
+ assertNull(impl.getScdlLocation());
+ assertNull(impl.getClassLoader());
+ }
+
+ public void testWithArtifact() throws LoaderException, XMLStreamException, MalformedURLException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "group")).andReturn("com.example");
+ expect(reader.getAttributeValue(null, "version")).andReturn("1.0");
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null);
+ expect(reader.getAttributeValue(null, "jarLocation")).andReturn(null);
+ expect(reader.next()).andReturn(END_ELEMENT);
+ replay(reader);
+
+ expect(context.getClassLoader()).andReturn(cl);
+ replay(context);
+ URL url = new URL("http://www.example.com/sca/base.jar");
+ artifactRepository.resolve(artifactMatcher(url, "com.example", name, "1.0"));
+ replay(artifactRepository);
+
+ CompositeImplementation impl = loader.load(null, reader, context);
+ verify(reader);
+ verify(context);
+ verify(artifactRepository);
+ assertEquals(name, impl.getName());
+ assertEquals(new URL("jar:http://www.example.com/sca/base.jar!/META-INF/sca/default.scdl"), impl.getScdlLocation());
+ assertTrue(impl.getClassLoader() instanceof CompositeClassLoader);
+ }
+
+ public void testWithScdlLocation() throws LoaderException, XMLStreamException, MalformedURLException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "group")).andReturn(null);
+ expect(reader.getAttributeValue(null, "version")).andReturn(null);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("bar.scdl");
+ expect(reader.getAttributeValue(null, "jarLocation")).andReturn(null);
+ expect(reader.next()).andReturn(END_ELEMENT);
+ replay(reader);
+
+ expect(context.getScdlLocation()).andReturn(new URL("http://www.example.com/sca/base.scdl"));
+ expect(context.getClassLoader()).andReturn(cl);
+ replay(context);
+ replay(artifactRepository);
+
+ CompositeImplementation impl = loader.load(null, reader, context);
+ verify(reader);
+ verify(context);
+ verify(artifactRepository);
+ assertEquals(name, impl.getName());
+ assertEquals(new URL("http://www.example.com/sca/bar.scdl"), impl.getScdlLocation());
+ assertSame(cl, impl.getClassLoader());
+ }
+
+ public void testWithJarLocation() throws LoaderException, XMLStreamException, MalformedURLException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "group")).andReturn(null);
+ expect(reader.getAttributeValue(null, "version")).andReturn(null);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null);
+ expect(reader.getAttributeValue(null, "jarLocation")).andReturn("bar.jar");
+ expect(reader.next()).andReturn(END_ELEMENT);
+ replay(reader);
+
+ expect(context.getScdlLocation()).andReturn(new URL("http://www.example.com/sca/base.scdl"));
+ expect(context.getClassLoader()).andReturn(cl);
+ replay(context);
+ replay(artifactRepository);
+
+ CompositeImplementation impl = loader.load(null, reader, context);
+ verify(reader);
+ verify(context);
+ verify(artifactRepository);
+ assertEquals(name, impl.getName());
+ assertEquals(new URL("jar:http://www.example.com/sca/bar.jar!/META-INF/sca/default.scdl"),
+ impl.getScdlLocation());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ artifactRepository = createMock(ArtifactRepository.class);
+ reader = createMock(XMLStreamReader.class);
+ context = createMock(DeploymentContext.class);
+ cl = getClass().getClassLoader();
+ loader = new ImplementationCompositeLoader(null, artifactRepository);
+ }
+
+ protected static Artifact artifactMatcher(final URL url,
+ final String group,
+ final String name,
+ final String version) {
+ reportMatcher(new IArgumentMatcher() {
+
+ public boolean matches(Object object) {
+ if (!(object instanceof Artifact)) {
+ return false;
+ }
+
+ Artifact artifact = (Artifact) object;
+ boolean match = group.equals(artifact.getGroup()) &&
+ name.equals(artifact.getName()) &&
+ version.equals(artifact.getVersion()) &&
+ "jar".equals(artifact.getType());
+ if (match) {
+ artifact.setUrl(url);
+ }
+ return match;
+ }
+
+ public void appendTo(StringBuffer stringBuffer) {
+ stringBuffer.append(group).append(':').append(name).append(':').append(version);
+ }
+ });
+ return null;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java
new file mode 100644
index 0000000000..c3267f8ec6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.composite;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.DuplicateNameException;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaObjectRegistrationTestCase extends TestCase {
+ private CompositeComponent composite;
+
+ public void testRegistration() throws Exception {
+ MockComponent instance = new MockComponent();
+ composite.registerJavaObject("foo", MockComponent.class, instance);
+ MockComponent resolvedInstance = (MockComponent) composite.getSystemChild("foo").getServiceInstance();
+ assertSame(instance, resolvedInstance);
+ }
+
+ public void testDuplicateRegistration() throws ConfigurationException {
+ MockComponent instance = new MockComponent();
+ composite.registerJavaObject("foo", MockComponent.class, instance);
+ try {
+ composite.registerJavaObject("foo", MockComponent.class, instance);
+ fail();
+ } catch (DuplicateNameException e) {
+ // ok
+ }
+ }
+
+ public void testSystemAutowireToObject() {
+ MockComponent instance = new MockComponent();
+ composite.registerJavaObject("foo", MockComponent.class, instance);
+ assertSame(instance, composite.resolveSystemInstance(MockComponent.class));
+ assertNull(composite.resolveSystemExternalInstance(MockComponent.class));
+ }
+
+ public void testApplicationAutowireToObject() {
+ MockComponent instance = new MockComponent();
+ composite.registerJavaObject("foo", MockComponent.class, instance);
+ assertNull(composite.resolveInstance(MockComponent.class));
+ assertNull(composite.resolveExternalInstance(MockComponent.class));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ composite = new CompositeComponentImpl(null, null, null, null);
+ composite.start();
+ composite.publish(new CompositeStart(this, null));
+ }
+
+ protected void tearDown() throws Exception {
+ composite.publish(new CompositeStop(this, null));
+ composite.stop();
+ super.tearDown();
+ }
+
+ private static class MockComponent {
+ public String hello(String message) {
+ return message;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvokerTestCase.java
new file mode 100644
index 0000000000..77e48991d5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvokerTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import junit.framework.TestCase;
+import static org.apache.tuscany.core.implementation.java.mock.MockFactory.createJavaComponent;
+import org.apache.tuscany.core.implementation.java.mock.components.AsyncTarget;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AsyncJavaTargetInvokerTestCase extends TestCase {
+
+ public void testInvoke() throws Exception {
+ AsyncTarget target = createMock(AsyncTarget.class);
+ target.invoke();
+ expectLastCall().once();
+ replay(target);
+ JavaAtomicComponent component = createJavaComponent(target);
+ AsyncMonitor monitor = createMock(AsyncMonitor.class);
+ replay(monitor);
+
+ Message msg = new MessageImpl();
+ Object id = new Object();
+ msg.setMessageId(id);
+
+ WorkContext context = createMock(WorkContext.class);
+ context.setCurrentMessageId(null);
+ context.setCurrentCorrelationId(id);
+ replay(context);
+ Method method = AsyncTarget.class.getMethod("invoke");
+ method.setAccessible(true);
+ InboundWire wire = createMock(InboundWire.class);
+ AsyncJavaTargetInvoker invoker =
+ new AsyncJavaTargetInvoker(method, wire, component, monitor, context);
+ invoker.invoke(msg);
+ verify(target);
+ }
+
+ public void testClone() throws Exception {
+ AsyncTarget target = createMock(AsyncTarget.class);
+ target.invoke();
+ expectLastCall().once();
+ replay(target);
+ JavaAtomicComponent component = createJavaComponent(target);
+ AsyncMonitor monitor = createMock(AsyncMonitor.class);
+ replay(monitor);
+ WorkScheduler scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+ WorkContext context = createMock(WorkContext.class);
+ InboundWire wire = createMock(InboundWire.class);
+ Method method = AsyncTarget.class.getMethod("invoke");
+ method.setAccessible(true);
+ AsyncJavaTargetInvoker invoker =
+ new AsyncJavaTargetInvoker(method, wire, component, monitor, context);
+ AsyncJavaTargetInvoker clone = invoker.clone();
+ Message msg = new MessageImpl();
+ clone.invoke(msg);
+ verify(target);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java
new file mode 100644
index 0000000000..64a573c6e5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.OtherTarget;
+import org.apache.tuscany.core.implementation.java.mock.components.OtherTargetImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+
+/**
+ * Tests wires that have different interfaces on the source and target side
+ *
+ * @version $Rev$ $Date$
+ */
+public class DifferentInterfaceWireTestCase extends TestCase {
+
+ public void testDifferentInterfaceInjection() throws Exception {
+ Map<String, Member> members = new HashMap<String, Member>();
+ Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+ members.put("target", m);
+ ScopeContainer scope = createMock();
+ scope.start();
+ Map<String, AtomicComponent> contexts =
+ MockFactory.createWiredComponents("source",
+ SourceImpl.class,
+ Target.class,
+ scope,
+ members,
+ "target",
+ OtherTarget.class,
+ OtherTargetImpl.class,
+ scope);
+ AtomicComponent sourceComponent = contexts.get("source");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = source.getTarget();
+ assertTrue(Proxy.isProxyClass(target.getClass()));
+ assertNotNull(target);
+ scope.stop();
+ EasyMock.verify(scope);
+ }
+
+ public void testDifferentInterfaceMultiplicityInjection() throws Exception {
+ Map<String, Member> members = new HashMap<String, Member>();
+ Method m = SourceImpl.class.getMethod("setTargets", List.class);
+ members.put("target", m);
+ ScopeContainer scope = createMock();
+ scope.start();
+ Map<String, AtomicComponent> contexts =
+ MockFactory.createWiredMultiplicity("source", SourceImpl.class, Target.class, scope,
+ "target", OtherTarget.class, OtherTargetImpl.class, members, scope);
+ AtomicComponent sourceComponent = contexts.get("source");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ List<Target> targets = source.getTargets();
+ assertEquals(1, targets.size());
+ Target target = targets.get(0);
+ target.setString("foo");
+ assertEquals("foo", target.getString());
+ assertTrue(Proxy.isProxyClass(target.getClass()));
+ scope.stop();
+ EasyMock.verify(scope);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private ScopeContainer createMock() {
+ ScopeContainer scope = EasyMock.createMock(ScopeContainer.class);
+ scope.start();
+ scope.stop();
+ scope.register(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().atLeastOnce();
+ EasyMock.expect(scope.getScope()).andReturn(Scope.MODULE).atLeastOnce();
+ scope.getInstance(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+ private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+ public Object answer() throws Throwable {
+ AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
+ Object instance = cache.get(component);
+ if (instance == null) {
+ instance = component.createInstance();
+ cache.put(component, instance);
+ }
+ return instance;
+ }
+ }).anyTimes();
+ EasyMock.replay(scope);
+ return scope;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java
new file mode 100644
index 0000000000..4695866232
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class GetServiceByNameTestCase extends TestCase {
+
+ public void testServiceLocate() throws Exception {
+ ScopeContainer scope = createMock(ScopeContainer.class);
+ scope.register(EasyMock.isA(JavaAtomicComponent.class));
+ expect(scope.getScope()).andReturn(Scope.MODULE);
+ replay(scope);
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.setInstanceFactory(new PojoObjectFactory<TargetImpl>(TargetImpl.class.getConstructor()));
+ configuration.addServiceInterface(Target.class);
+ configuration.setWireService(new JDKWireService());
+ final JavaAtomicComponent component = new JavaAtomicComponent("target", configuration, null);
+
+ InboundWire wire = createMock(InboundWire.class);
+
+ JavaServiceContract contract = new JavaServiceContract(Target.class);
+ EasyMock.expect(wire.getServiceContract()).andReturn(contract).anyTimes();
+ expect(wire.getServiceName()).andReturn("Target");
+ Map<Operation<?>, InboundInvocationChain> chains = new HashMap<Operation<?>, InboundInvocationChain>();
+ expect(wire.getInvocationChains()).andReturn(chains);
+ expect(wire.getCallbackReferenceName()).andReturn(null);
+ replay(wire);
+ component.addInboundWire(wire);
+ component.prepare();
+ component.start();
+ assertTrue(component.getServiceInstance("Target") instanceof Target);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java
new file mode 100644
index 0000000000..a907e047b8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests SCA metadata such as <code>@ComponentName</code> and <code>@SCAObject</code> are handled properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaAtomicComponentMetadataInjectionTestCase extends TestCase {
+
+ public void testComponentNameSet() throws Exception {
+ }
+
+ public void testModuleContextSet() throws Exception {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java
new file mode 100644
index 0000000000..365de8e41f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Performs rudimentary negative testing by using malformed metadata on a POJO
+ *
+ * @version $Rev $Date
+ */
+public class JavaAtomicComponentNegativeMetadataTestCase extends TestCase {
+
+ /**
+ * Tests that a pojo with <code>@ComponentName</code> specified on a non-String type generates an error.
+ * <p/>
+ * <strong>NB:</strong> the test assumes an error with a message containing "@ComponentName" is generated
+ */
+ public void testBadNameType() throws Exception {
+// CompositeComponent mc = new CompositeComponentImpl();
+// mc.setName("mc");
+// try {
+// MockFactory.createPojoContext("BadNamePojo", BadNamePojo.class, Scope.MODULE, mc);
+// } catch (NoSuchMethodException e) {
+// if (e.getMessage().indexOf("@ComponentName") < 0) {
+// throw e;
+// }
+// }
+//
+ }
+
+ /**
+ * Tests that a pojo with <code>@Context</code> specified on a non-ModuleContext type generates an error.
+ * <p/>
+ * <strong>NB:</strong> the test assumes an error with a message containing "@Context" is generated
+ */
+ public void testContextType() throws Exception {
+// CompositeComponent mc = new CompositeComponentImpl();
+// mc.setName("mc");
+// try {
+// MockFactory.createPojoContext("BadContextPojo", BadContextPojo.class, Scope.MODULE, mc);
+// } catch (NoSuchMethodException e) {
+// if (e.getMessage().indexOf("@SCAObject") < 0) {
+// throw e;
+// }
+// }
+//
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java
new file mode 100644
index 0000000000..4877d06aba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class JavaComponentBuilderTestCase extends TestCase {
+ private DeploymentContext deploymentContext;
+
+ public void testBuild() throws Exception {
+ CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);
+
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> sourceType =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ sourceType.setImplementationScope(Scope.MODULE);
+ JavaMappedReference reference = new JavaMappedReference();
+ reference.setName("target");
+ reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
+ sourceType.add(reference);
+
+ ServiceContract<?> sourceContract = new JavaServiceContract(Source.class);
+ JavaMappedService sourceServiceDefinition = new JavaMappedService();
+ sourceServiceDefinition.setName("Source");
+ sourceServiceDefinition.setServiceContract(sourceContract);
+
+ sourceType.add(sourceServiceDefinition);
+ Constructor<SourceImpl> constructor = SourceImpl.class.getConstructor((Class[]) null);
+ sourceType.setConstructorDefinition(new ConstructorDefinition<SourceImpl>(constructor));
+ JavaImplementation sourceImpl = new JavaImplementation();
+ sourceImpl.setComponentType(sourceType);
+ sourceImpl.setImplementationClass(SourceImpl.class);
+ ComponentDefinition<JavaImplementation> sourceComponentDefinition =
+ new ComponentDefinition<JavaImplementation>(sourceImpl);
+
+ JavaComponentBuilder builder = new JavaComponentBuilder();
+ builder.setWireService(new JDKWireService());
+ JavaAtomicComponent component =
+ (JavaAtomicComponent) builder.build(parent, sourceComponentDefinition, deploymentContext);
+ deploymentContext.getModuleScope().start();
+ component.start();
+ Source source = (Source) component.getServiceInstance();
+ assertNotNull(source);
+ component.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ deploymentContext = new RootDeploymentContext(null, null, createMock(), null);
+ }
+
+ private ScopeContainer createMock() {
+ ScopeContainer scope = EasyMock.createMock(ScopeContainer.class);
+ scope.start();
+ scope.stop();
+ scope.register(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().atLeastOnce();
+ EasyMock.expect(scope.getScope()).andReturn(Scope.MODULE).atLeastOnce();
+ scope.getInstance(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+ private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+ public Object answer() throws Throwable {
+ AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
+ Object instance = cache.get(component);
+ if (instance == null) {
+ instance = component.createInstance();
+ cache.put(component, instance);
+ }
+ return instance;
+ }
+ }).anyTimes();
+ EasyMock.replay(scope);
+ return scope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
new file mode 100644
index 0000000000..5afc8b6511
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * Validates wiring from a Java atomic context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class JavaReferenceWireTestCase extends TestCase {
+
+ public void testReferenceSet() throws Exception {
+ ScopeContainer scope = createMock();
+ scope.start();
+ final Target target = new TargetImpl();
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.addReferenceSite("target", SourceImpl.class.getMethod("setTarget", Target.class));
+ configuration.addServiceInterface(Source.class);
+ Constructor<SourceImpl> ctr = SourceImpl.class.getConstructor();
+ configuration.setInstanceFactory(new PojoObjectFactory<SourceImpl>(ctr));
+ configuration.setScopeContainer(scope);
+ OutboundWire wire = EasyMock.createMock(OutboundWire.class);
+ wire.getInvocationChains();
+ EasyMock.expectLastCall().andReturn(new HashMap<Operation<?>, OutboundInvocationChain>());
+ EasyMock.expect(wire.getReferenceName()).andReturn("target").atLeastOnce();
+ EasyMock.replay(wire);
+ WireService service = EasyMock.createMock(WireService.class);
+ EasyMock.expect(service.createProxy(EasyMock.eq(wire))).andAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ OutboundWire wire = (OutboundWire) EasyMock.getCurrentArguments()[0];
+ wire.getInvocationChains();
+ return target;
+ }
+
+ }).atLeastOnce();
+ EasyMock.replay(service);
+ configuration.setWireService(service);
+ JavaAtomicComponent sourceContext = new JavaAtomicComponent("source", configuration, null);
+ sourceContext.addOutboundWire(wire);
+ sourceContext.start();
+ Source source = (Source) sourceContext.getServiceInstance();
+ assertSame(target, source.getTarget());
+ scope.stop();
+ EasyMock.verify(wire);
+ EasyMock.verify(scope);
+ EasyMock.verify(service);
+ }
+
+ private ScopeContainer createMock() {
+ ScopeContainer scope = EasyMock.createMock(ScopeContainer.class);
+ scope.start();
+ scope.stop();
+ scope.register(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().atLeastOnce();
+ EasyMock.expect(scope.getScope()).andReturn(Scope.MODULE).atLeastOnce();
+ scope.getInstance(EasyMock.isA(AtomicComponent.class));
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+ private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+ public Object answer() throws Throwable {
+ AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
+ Object instance = cache.get(component);
+ if (instance == null) {
+ instance = component.createInstance();
+ cache.put(component, instance);
+ }
+ return instance;
+ }
+ }).anyTimes();
+ EasyMock.replay(scope);
+ return scope;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java
new file mode 100644
index 0000000000..018273be28
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+
+public class JavaTargetInvokerTestCase extends TestCase {
+
+ private Method echoMethod;
+
+ public JavaTargetInvokerTestCase() {
+ super();
+ }
+
+ public JavaTargetInvokerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ echoMethod = Echo.class.getDeclaredMethod("echo", String.class);
+ Assert.assertNotNull(echoMethod);
+ }
+
+ public void testScopedInvoke() throws Exception {
+ ScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ JavaAtomicComponent component =
+ MockFactory.createJavaComponent("foo", scope, Echo.class);
+ scope.register(component);
+ JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component);
+ invoker.setCacheable(false);
+ assertEquals("foo", invoker.invokeTarget("foo"));
+ scope.stop();
+ }
+
+ public void testClone() throws Exception {
+ ScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ JavaAtomicComponent component =
+ MockFactory.createJavaComponent("foo", scope, Echo.class);
+ scope.register(component);
+ JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component);
+ invoker.setCacheable(false);
+ JavaTargetInvoker clone = invoker.clone();
+ assertEquals("foo", clone.invokeTarget("foo"));
+ scope.stop();
+ }
+
+ public static class Echo {
+ public String echo(String message) throws Exception {
+ return message;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java
new file mode 100644
index 0000000000..92c8c7acfa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests wires that are configured with a multiplicity
+ *
+ * @version $Rev$ $Date$
+ */
+public class MultiplicityTestCase extends TestCase {
+
+ public void testMultiplicity() throws Exception {
+// CompositeComponent context = createContext();
+// context.start();
+// context.registerModelObject(MockFactory.createModuleWithWiredComponents(Scope.MODULE, Scope.MODULE));
+// context.publish(new CompositeStart(this));
+// Source source = (Source) ((AtomicComponent) context.getContext("source")).getTargetInstance();
+// Assert.assertNotNull(source);
+// Target target = (Target) ((AtomicComponent)context.getContext("target")).getTargetInstance();
+// Assert.assertNotNull(target);
+// // test setter injection
+// List<Target> targets = source.getTargets();
+// Assert.assertEquals(1, targets.size());
+//
+// // test field injection
+// targets = source.getTargetsThroughField();
+// Assert.assertEquals(1, targets.size());
+ }
+
+// private CompositeComponent createContext() {
+// CompositeComponentImpl context = new CompositeComponentImpl();
+// context.setName("system.context");
+// List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
+// WireService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(),
+// new JDKWireFactoryService(), new DefaultPolicyBuilderRegistry());
+// builders.add(new JavaContextFactoryBuilder(wireService));
+// List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
+// wireBuilders.add(new JavaTargetWireBuilder());
+// context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
+// return context;
+// }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java
new file mode 100644
index 0000000000..e6309e0c97
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class ReferenceInjectionTestCase extends TestCase {
+
+ private Map<String, Member> members;
+
+ public void testProxiedReferenceInjection() throws Exception {
+ ScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ Map<String, AtomicComponent> contexts =
+ MockFactory.createWiredComponents("source", SourceImpl.class, scope,
+ members, "target", Target.class, TargetImpl.class, scope);
+ AtomicComponent sourceComponent = contexts.get("source");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = source.getTarget();
+ assertTrue(Proxy.isProxyClass(target.getClass()));
+
+ assertNotNull(target);
+ scope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ members = new HashMap<String, Member>();
+ Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+ members.put("target", m);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
new file mode 100644
index 0000000000..718fd50845
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.integration.component;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.osoa.sca.annotations.Callback;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
+import org.apache.tuscany.core.implementation.java.JavaImplementation;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import org.easymock.IAnswer;
+
+/**
+ * Verifies callback integration scenarios.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackInvocationTestCase extends TestCase {
+
+ private ScopeContainer container;
+ private DeploymentContext context;
+ private JavaComponentBuilder builder;
+ private WireService wireService;
+ private WorkScheduler scheduler;
+ private WorkContext workContext;
+ /**
+ * Verifies callback wires are built and callback invocations are handled properly
+ */
+ public void testComponentToComponentCallback() throws Exception {
+ ComponentDefinition<JavaImplementation> targetDefinition = createTarget();
+ JavaAtomicComponent fooComponent =
+ (JavaAtomicComponent) builder.build(null, targetDefinition, context);
+ wireService.createWires(fooComponent, targetDefinition);
+ container.register(fooComponent);
+
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ parent.getChild(isA(String.class));
+ expectLastCall().andReturn(fooComponent).anyTimes();
+ replay(parent);
+
+ ComponentDefinition<JavaImplementation> sourceDefinition = createSource("fooClient");
+ JavaAtomicComponent clientComponent =
+ (JavaAtomicComponent) builder.build(parent, sourceDefinition, context);
+ wireService.createWires(clientComponent, sourceDefinition);
+ container.register(clientComponent);
+
+ Connector connector = new ConnectorImpl(new JDKWireService(), null, scheduler , workContext);
+
+ connector.connect(clientComponent);
+ FooClient client = (FooClient) clientComponent.getServiceInstance();
+ client.invoke();
+ assertTrue(client.invoked);
+ }
+
+ /**
+ * Verifies a callback in response to an invocation from two different client components is routed back to the
+ * appropriate client.
+ */
+ public void testTwoSourceComponentToComponentCallback() throws Exception {
+ ComponentDefinition<JavaImplementation> targetDefinition = createTarget();
+ JavaAtomicComponent fooComponent =
+ (JavaAtomicComponent) builder.build(null, targetDefinition, context);
+ wireService.createWires(fooComponent, targetDefinition);
+ container.register(fooComponent);
+
+ CompositeComponent parent = createMock(CompositeComponent.class);
+ parent.getChild(isA(String.class));
+ expectLastCall().andReturn(fooComponent).anyTimes();
+ replay(parent);
+
+ ComponentDefinition<JavaImplementation> sourceDefinition1 = createSource("fooCleint1");
+ ComponentDefinition<JavaImplementation> sourceDefinition2 = createSource("fooCleint2");
+ JavaAtomicComponent clientComponent1 =
+ (JavaAtomicComponent) builder.build(parent, sourceDefinition1, context);
+ wireService.createWires(clientComponent1, sourceDefinition1);
+ container.register(clientComponent1);
+ JavaAtomicComponent clientComponent2 =
+ (JavaAtomicComponent) builder.build(parent, sourceDefinition2, context);
+ wireService.createWires(clientComponent2, sourceDefinition2);
+ container.register(clientComponent2);
+
+ Connector connector = new ConnectorImpl(new JDKWireService(), null, scheduler, workContext);
+ connector.connect(clientComponent1);
+ connector.connect(clientComponent2);
+ FooClient client1 = (FooClient) clientComponent1.getServiceInstance();
+ client1.invoke();
+ assertTrue(client1.invoked);
+ FooClient client2 = (FooClient) clientComponent2.getServiceInstance();
+ client2.invoke();
+ assertTrue(client2.invoked);
+ }
+
+
+ private ComponentDefinition<JavaImplementation> createTarget() throws NoSuchMethodException,
+ InvalidServiceContractException {
+ ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setConstructorDefinition(ctorDef);
+ type.setImplementationScope(Scope.MODULE);
+ Method method = FooImpl.class.getMethod("setCallback", FooCallback.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(Foo.class);
+ contract.setCallbackClass(FooCallback.class);
+ contract.setCallbackName("callback");
+ JavaMappedService mappedService = new JavaMappedService("Foo", contract, false, "callback", method);
+ type.getServices().put("Foo", mappedService);
+
+ JavaImplementation impl = new JavaImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooImpl.class);
+ return new ComponentDefinition<JavaImplementation>("foo", impl);
+ }
+
+ private ComponentDefinition<JavaImplementation> createSource(String name)
+ throws NoSuchMethodException, URISyntaxException, InvalidServiceContractException {
+ ConstructorDefinition<FooClient> ctorDef =
+ new ConstructorDefinition<FooClient>(FooClient.class.getConstructor());
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setConstructorDefinition(ctorDef);
+ type.setImplementationScope(Scope.MODULE);
+ Method method = FooClient.class.getMethod("setFoo", Foo.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(Foo.class);
+ contract.setCallbackClass(FooCallback.class);
+ contract.setCallbackName("callback");
+ JavaMappedReference mappedReference = new JavaMappedReference("foo", contract, method);
+ type.getReferences().put("foo", mappedReference);
+ ReferenceTarget refTarget = new ReferenceTarget();
+ refTarget.setReferenceName("foo");
+ refTarget.getTargets().add(new URI("foo"));
+ JavaImplementation impl = new JavaImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooClient.class);
+ ComponentDefinition<JavaImplementation> def = new ComponentDefinition<JavaImplementation>(name, impl);
+ def.getReferenceTargets().put("foo", refTarget);
+ return def;
+ }
+
+ @Callback(FooCallback.class)
+ public static interface Foo {
+ void call();
+ }
+
+ public static class FooImpl implements Foo {
+ private FooCallback callback;
+
+ public FooImpl() {
+ }
+
+ @Callback
+ public void setCallback(FooCallback callback) {
+ this.callback = callback;
+ }
+
+ public void call() {
+ callback.callback();
+ }
+ }
+
+ public static class FooClient implements FooCallback {
+
+ private Foo foo;
+ private boolean invoked;
+
+ public FooClient() {
+ }
+
+ public void setFoo(Foo foo) {
+ this.foo = foo;
+ }
+
+ public void callback() {
+ if (invoked) {
+ fail();
+ }
+ invoked = true;
+ }
+
+ public void invoke() {
+ foo.call();
+ }
+ }
+
+ public interface FooCallback {
+ void callback();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ wireService = new JDKWireService();
+ container = new ModuleScopeContainer();
+ container.start();
+ context = createMock(DeploymentContext.class);
+ context.getModuleScope();
+ expectLastCall().andReturn(container).anyTimes();
+ replay(context);
+
+ scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+
+ builder = new JavaComponentBuilder();
+ workContext = new WorkContextImpl();
+ builder.setWorkContext(workContext);
+ builder.setWireService(new JDKWireService(workContext, null));
+ builder.setWorkScheduler(scheduler);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java
new file mode 100644
index 0000000000..91d31d2db2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.integration.component;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.java.AsyncJavaTargetInvoker;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import static org.apache.tuscany.core.implementation.java.mock.MockFactory.createServiceWire;
+import org.apache.tuscany.core.implementation.java.mock.components.AsyncTarget;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+
+/**
+ * Verifies non-blocking invocations are properly made through a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class OneWayWireInvocationTestCase extends TestCase {
+
+ WireService wireService = new JDKWireService();
+
+ public void testNoInterceptors() throws Exception {
+ AsyncTarget target = createMock(AsyncTarget.class);
+ target.invoke();
+ expectLastCall().once();
+ replay(target);
+ JavaAtomicComponent component = MockFactory.createJavaComponent(target);
+ WorkScheduler scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+ WorkContext context = createMock(WorkContext.class);
+ Method method = AsyncTarget.class.getMethod("invoke");
+ method.setAccessible(true);
+ InboundWire inboundWire = createMock(InboundWire.class);
+ AsyncJavaTargetInvoker invoker =
+ new AsyncJavaTargetInvoker(method, inboundWire, component, null, context);
+ InboundWire wire = createServiceWire("foo", AsyncTarget.class, null);
+ Map<Operation<?>, InboundInvocationChain> chains = wire.getInvocationChains();
+ InboundInvocationChain chain = chains.get(wire.getServiceContract().getOperations().get("invoke"));
+ chain.setTargetInvoker(invoker);
+ chain.prepare();
+ MessageImpl msg = new MessageImpl();
+ msg.setTargetInvoker(invoker);
+ chain.getHeadInterceptor().invoke(msg);
+ verify(target);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
new file mode 100644
index 0000000000..9ea0cd99e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.integration.component;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.component.scope.HttpSessionScopeContainer;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.component.scope.RequestScopeContainer;
+import org.apache.tuscany.core.component.scope.StatelessScopeContainer;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.easymock.EasyMock;
+
+/**
+ * Validates wiring from a service context to Java atomic contexts by scope
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class OutboundWireToJavaTestCase extends TestCase {
+ private WorkContext workContext = new WorkContextImpl();
+ private WireService wireService = new JDKWireService(new WorkContextImpl(), null);
+
+ public void testToStatelessScope() throws Exception {
+ StatelessScopeContainer scope = new StatelessScopeContainer(workContext);
+ scope.start();
+ final OutboundWire wire = getWire(scope);
+ Target service = (Target) wireService.createProxy(wire);
+ assertNotNull(service);
+ service.setString("foo");
+ assertEquals(null, service.getString());
+ scope.stop();
+ }
+
+ public void testToRequestScope() throws Exception {
+ final RequestScopeContainer scope = new RequestScopeContainer(workContext);
+ scope.start();
+
+ scope.onEvent(new RequestStart(this));
+
+ final OutboundWire wire = getWire(scope);
+ Target service = (Target) wireService.createProxy(wire);
+ assertNotNull(service);
+ service.setString("foo");
+
+ // another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ scope.onEvent(new RequestStart(this));
+ Target service2 = (Target) wireService.createProxy(wire);
+ Target target2 = (Target) wireService.createProxy(wire);
+ assertEquals(null, service2.getString());
+ service2.setString("bar");
+ assertEquals("bar", service2.getString());
+ assertEquals("bar", target2.getString());
+ scope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+
+ assertEquals("foo", service.getString());
+ scope.onEvent(new RequestEnd(this));
+ scope.stop();
+ }
+
+ public void testToSessionScope() throws Exception {
+ HttpSessionScopeContainer scope = new HttpSessionScopeContainer(workContext);
+ scope.start();
+ Object session1 = new Object();
+ workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ scope.onEvent(new HttpSessionStart(this, session1));
+
+ final OutboundWire wire = getWire(scope);
+ Target service = (Target) wireService.createProxy(wire);
+ Target target = (Target) wireService.createProxy(wire);
+ assertNotNull(service);
+ service.setString("foo");
+ assertEquals("foo", service.getString());
+ assertEquals("foo", target.getString());
+
+ workContext.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+
+ //second session
+ Object session2 = new Object();
+ workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ scope.onEvent(new HttpSessionStart(this, session2));
+
+ Target service2 = (Target) wireService.createProxy(wire);
+ assertNotNull(service2);
+ assertNull(service2.getString());
+ Target target2 = (Target) wireService.createProxy(wire);
+ service2.setString("bar");
+ assertEquals("bar", service2.getString());
+ assertEquals("bar", target2.getString());
+
+ scope.onEvent(new HttpSessionEnd(this, session2));
+ workContext.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+
+ workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ assertEquals("foo", service.getString());
+
+ scope.onEvent(new HttpSessionEnd(this, session1));
+
+ scope.stop();
+ }
+
+ public void testToModuleScope() throws Exception {
+
+ ModuleScopeContainer scope = new ModuleScopeContainer(workContext);
+ scope.start();
+ scope.onEvent(new CompositeStart(this, null));
+ final OutboundWire wire = getWire(scope);
+ Target service = (Target) wireService.createProxy(wire);
+ Target target = (Target) wireService.createProxy(wire);
+ assertNotNull(service);
+ service.setString("foo");
+ assertEquals("foo", service.getString());
+ assertEquals("foo", target.getString());
+ scope.onEvent(new CompositeStop(this, null));
+ scope.stop();
+ }
+
+ private OutboundWire getWire(ScopeContainer scope) throws NoSuchMethodException,
+ InvalidServiceContractException {
+ ConnectorImpl connector = new ConnectorImpl();
+
+ CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
+
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.setInstanceFactory(new PojoObjectFactory<TargetImpl>(TargetImpl.class.getConstructor()));
+ configuration.addServiceInterface(Target.class);
+ configuration.setParent(parent);
+
+ JavaAtomicComponent source = new JavaAtomicComponent("source", configuration, null);
+ OutboundWire outboundWire = createOutboundWire(new QualifiedName("target/Target"), Target.class);
+ outboundWire.setContainer(source);
+ source.addOutboundWire(outboundWire);
+ JavaAtomicComponent target = new JavaAtomicComponent("target", configuration, null);
+ InboundWire targetWire = MockFactory.createTargetWire("Target", Target.class);
+ targetWire.setContainer(target);
+ target.addInboundWire(targetWire);
+ InboundWire inboundWire = target.getInboundWire("Target");
+ inboundWire.setContainer(target);
+
+ EasyMock.expect(parent.getChild("target")).andReturn(target);
+ EasyMock.replay(parent);
+
+ connector.connect(source);
+ target.start();
+ return outboundWire;
+ }
+
+ public static <T> OutboundWire createOutboundWire(QualifiedName targetName, Class<T> interfaze)
+ throws InvalidServiceContractException {
+ OutboundWire wire = new OutboundWireImpl();
+ JavaServiceContract contract = new JavaServiceContract(interfaze);
+ wire.setServiceContract(contract);
+ wire.setTargetName(targetName);
+ wire.addInvocationChains(createInvocationChains(interfaze));
+ return wire;
+ }
+
+ private static Map<Operation<?>, OutboundInvocationChain> createInvocationChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
+ Map<Operation<?>, OutboundInvocationChain> invocations = new HashMap<Operation<?>, OutboundInvocationChain>();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ for (Operation operation : contract.getOperations().values()) {
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ invocations.put(operation, chain);
+ }
+ return invocations;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/ScopeReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/ScopeReferenceTestCase.java
new file mode 100644
index 0000000000..87a8be3a01
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/ScopeReferenceTestCase.java
@@ -0,0 +1,746 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.integration.component;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.component.scope.HttpSessionScopeContainer;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.component.scope.RequestScopeContainer;
+import org.apache.tuscany.core.component.scope.StatelessScopeContainer;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+
+/**
+ * Tests scoping is properly handled for service references
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeReferenceTestCase extends TestCase {
+
+ private Map<String, Member> members;
+
+ /**
+ * Tests a module-to-module scoped wire
+ */
+ public void testModuleToModule() throws Exception {
+ ScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ scope, members, "target", Target.class, TargetImpl.class, scope);
+ scope.onEvent(new CompositeStart(this, null));
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+ scope.onEvent(new CompositeStop(this, null));
+ scope.stop();
+ }
+
+ /**
+ * Tests a module-to-session scoped wire is setup properly by the runtime
+ */
+ public void testModuleToSession() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
+ moduleScope.start();
+ ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ sessionScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ moduleScope, members, "target", Target.class, TargetImpl.class, sessionScope);
+ moduleScope.onEvent(new CompositeStart(this, null));
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+
+ //second session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ sessionScope.onEvent(new HttpSessionStart(this, session2));
+
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+
+ assertFalse("foo".equals(source.getTarget().getString()));
+ source.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source.getTarget().getString());
+ sessionScope.onEvent(new HttpSessionEnd(this, session2));
+
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ moduleScope.onEvent(new CompositeStop(this, null));
+ sessionScope.stop();
+ moduleScope.stop();
+ }
+
+ /**
+ * Tests a module-to-request scoped wire
+ */
+ public void testModuleToRequest() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
+ moduleScope.start();
+ final ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ requestScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ moduleScope, members, "target", Target.class, TargetImpl.class, requestScope);
+ moduleScope.onEvent(new CompositeStart(this, null));
+ requestScope.onEvent(new RequestStart(this));
+
+ AtomicComponent sourceComponent = contexts.get("source");
+ final AtomicComponent targetComponent = contexts.get("target");
+ final Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ // spin off another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ requestScope.onEvent(new RequestStart(this));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ assertFalse("foo".equals(source.getTarget().getString()));
+ source.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+ assertEquals("foo", source.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ moduleScope.onEvent(new CompositeStop(this, null));
+ requestScope.stop();
+ moduleScope.stop();
+ }
+
+ /**
+ * Tests a module-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testModuleToStateless() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
+ moduleScope.start();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ moduleScope, members, "target", Target.class, TargetImpl.class, statelessScope);
+ moduleScope.onEvent(new CompositeStart(this, null));
+
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertFalse("foo".equals(source.getTarget().getString()));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ source.getTarget().setString("bar");
+ assertFalse("bar".equals(source.getTarget().getString()));
+ moduleScope.onEvent(new CompositeStop(this, null));
+ moduleScope.stop();
+ statelessScope.stop();
+ }
+
+
+ /**
+ * Tests a session-to-session scoped wire
+ */
+ public void testSessionToSession() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ sessionScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ sessionScope, members, "target", Target.class, TargetImpl.class, sessionScope);
+
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ source.getTarget().setString("foo");
+ source.getTarget().setString("foo");
+ assertEquals("foo", target.getString());
+
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+
+ //second session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ sessionScope.onEvent(new HttpSessionStart(this, session2));
+
+ Source source2 = (Source) sourceComponent.getServiceInstance();
+ assertNotNull(source2);
+ Target target2 = (Target) targetComponent.getServiceInstance();
+
+ assertNotNull(target2);
+ assertNull(target2.getString());
+ assertEquals(null, source2.getTarget().getString());
+ source2.getTarget().setString("baz");
+ assertEquals("baz", source2.getTarget().getString());
+ assertEquals("baz", target2.getString());
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session2));
+ sessionScope.stop();
+ }
+
+
+ /**
+ * Tests a session-to-module scoped wire
+ */
+ public void testSessionToModule() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
+ moduleScope.start();
+ ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ sessionScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ sessionScope, members, "target", Target.class, TargetImpl.class, moduleScope);
+ moduleScope.onEvent(new CompositeStart(this, null));
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+
+ //second session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ sessionScope.onEvent(new HttpSessionStart(this, session2));
+
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ Source source2 = (Source) sourceComponent.getServiceInstance();
+ assertEquals("foo", target2.getString());
+ assertEquals("foo", source2.getTarget().getString());
+ source2.getTarget().setString("baz");
+ assertEquals("baz", source2.getTarget().getString());
+ assertEquals("baz", target2.getString());
+ assertEquals("baz", target.getString());
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session2));
+ moduleScope.stop();
+ sessionScope.stop();
+ }
+
+ /**
+ * Tests a session-to-request scoped wire is setup properly by the runtime
+ */
+ public void testSessionToRequest() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ final ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ requestScope.start();
+ ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ sessionScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ sessionScope, members, "target", Target.class, TargetImpl.class, requestScope);
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+ requestScope.onEvent(new RequestStart(this));
+ AtomicComponent sourceComponent = contexts.get("source");
+ final AtomicComponent targetComponent = contexts.get("target");
+ final Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ // spin off another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ requestScope.onEvent(new RequestStart(this));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ assertFalse("foo".equals(source.getTarget().getString()));
+ source.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+ assertEquals("foo", source.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+ requestScope.stop();
+ sessionScope.stop();
+ }
+
+
+ /**
+ * Tests a session-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testSessionToStateless() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ sessionScope.start();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ sessionScope, members, "target", Target.class, TargetImpl.class, statelessScope);
+
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertFalse("foo".equals(source.getTarget().getString()));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ source.getTarget().setString("bar");
+ assertFalse("bar".equals(source.getTarget().getString()));
+
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+ sessionScope.stop();
+ statelessScope.stop();
+ }
+
+ /**
+ * Tests a request-to-request scoped wire is setup properly by the runtime
+ */
+ public void testRequestToRequest() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ final ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ requestScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ requestScope, members, "target", Target.class, TargetImpl.class, requestScope);
+ requestScope.onEvent(new RequestStart(this));
+
+ final AtomicComponent sourceComponent = contexts.get("source");
+ final AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ // spin off another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ requestScope.onEvent(new RequestStart(this));
+ Source source2 = (Source) sourceComponent.getServiceInstance();
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ assertFalse("foo".equals(source2.getTarget().getString()));
+ source2.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source2.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+ requestScope.onEvent(new RequestEnd(this));
+ requestScope.stop();
+ }
+
+ /**
+ * Tests a request-to-module scoped wire
+ */
+ public void testRequestToModule() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ final ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ final ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
+ requestScope.start();
+ moduleScope.start();
+ moduleScope.onEvent(new CompositeStart(this, null));
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ requestScope, members, "target", Target.class, TargetImpl.class, moduleScope);
+ requestScope.onEvent(new RequestStart(this));
+
+ final AtomicComponent sourceComponent = contexts.get("source");
+ final AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ // spin off another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ requestScope.onEvent(new RequestStart(this));
+ Source source2 = (Source) sourceComponent.getServiceInstance();
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertEquals("foo", target2.getString());
+ assertEquals("foo", source2.getTarget().getString());
+ source2.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source2.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+ assertEquals("bar", target.getString());
+
+ requestScope.onEvent(new RequestEnd(this));
+ requestScope.stop();
+ moduleScope.onEvent(new CompositeStop(this, null));
+ moduleScope.stop();
+ }
+
+ /**
+ * Tests a request-to-session scoped wire is setup properly by the runtime
+ */
+ public void testRequestToSession() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ final ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ final ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ requestScope.start();
+ sessionScope.start();
+
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ requestScope, members, "target", Target.class, TargetImpl.class, sessionScope);
+
+ final AtomicComponent sourceComponent = contexts.get("source");
+ final AtomicComponent targetComponent = contexts.get("target");
+ requestScope.onEvent(new RequestStart(this));
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ // spin off another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ requestScope.onEvent(new RequestStart(this));
+ Source source2 = (Source) sourceComponent.getServiceInstance();
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertEquals("foo", target2.getString());
+ assertEquals("foo", source2.getTarget().getString());
+ source2.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source2.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+ assertEquals("bar", target.getString());
+
+ requestScope.onEvent(new RequestEnd(this));
+ requestScope.stop();
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+ sessionScope.stop();
+ }
+
+
+ /**
+ * Tests a request-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testRequestToStateless() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ requestScope.start();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ requestScope, members, "target", Target.class, TargetImpl.class, statelessScope);
+
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ requestScope.onEvent(new RequestStart(this));
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertFalse("foo".equals(source.getTarget().getString()));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ source.getTarget().setString("bar");
+ assertFalse("bar".equals(source.getTarget().getString()));
+ requestScope.onEvent(new RequestEnd(this));
+ requestScope.stop();
+ statelessScope.stop();
+ }
+
+
+ /**
+ * Tests a stateless-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToStateless() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ statelessScope, members, "target", Target.class, TargetImpl.class, statelessScope);
+
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertFalse("foo".equals(source.getTarget().getString()));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ source.getTarget().setString("bar");
+ assertFalse("bar".equals(source.getTarget().getString()));
+ statelessScope.stop();
+ }
+
+ /**
+ * Tests a stateless-to-request scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToRequest() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ final ScopeContainer requestScope = new RequestScopeContainer(ctx);
+ requestScope.start();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ statelessScope, members, "target", Target.class, TargetImpl.class, requestScope);
+ requestScope.onEvent(new RequestStart(this));
+ AtomicComponent sourceComponent = contexts.get("source");
+ final AtomicComponent targetComponent = contexts.get("target");
+ final Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ // spin off another request
+ Executor executor = Executors.newSingleThreadExecutor();
+ FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+ public void run() {
+ requestScope.onEvent(new RequestStart(this));
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+ assertFalse("foo".equals(source.getTarget().getString()));
+ source.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source.getTarget().getString());
+ requestScope.onEvent(new RequestEnd(this));
+ }
+ }, null);
+ executor.execute(future);
+ future.get();
+ requestScope.stop();
+ statelessScope.stop();
+ }
+
+ /**
+ * Tests a stateless-to-session scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToSession() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+ ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
+ sessionScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ statelessScope, members, "target", Target.class, TargetImpl.class, sessionScope);
+ Object session1 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+ sessionScope.onEvent(new HttpSessionStart(this, session1));
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.onEvent(new HttpSessionEnd(this, session1));
+
+ //second session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ sessionScope.onEvent(new HttpSessionStart(this, session2));
+
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertFalse("foo".equals(target2.getString()));
+
+ assertFalse("foo".equals(source.getTarget().getString()));
+ source.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source.getTarget().getString());
+ sessionScope.onEvent(new HttpSessionEnd(this, session2));
+
+ ctx.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+ sessionScope.stop();
+ statelessScope.stop();
+ }
+
+
+ /**
+ * Tests a stateless-to-module scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToModule() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
+ statelessScope.start();
+ ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
+ moduleScope.start();
+
+ Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
+ statelessScope, members, "target", Target.class, TargetImpl.class, moduleScope);
+ moduleScope.onEvent(new CompositeStart(this, null));
+ AtomicComponent sourceComponent = contexts.get("source");
+ AtomicComponent targetComponent = contexts.get("target");
+ Source source = (Source) sourceComponent.getServiceInstance();
+ Target target = (Target) targetComponent.getServiceInstance();
+ assertNull(source.getTarget().getString());
+ assertNull(target.getString());
+ target.setString("foo");
+ assertTrue(Proxy.isProxyClass(source.getTarget().getClass()));
+ assertEquals("foo", source.getTarget().getString());
+
+ //second session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+ moduleScope.onEvent(new HttpSessionStart(this, session2));
+
+ Target target2 = (Target) targetComponent.getServiceInstance();
+ assertEquals("foo", target2.getString());
+
+ assertEquals("foo", source.getTarget().getString());
+ source.getTarget().setString("bar");
+ assertEquals("bar", target2.getString());
+ assertEquals("bar", source.getTarget().getString());
+
+ moduleScope.onEvent(new CompositeStop(this, null));
+ moduleScope.stop();
+ statelessScope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ members = new HashMap<String, Member>();
+ Method[] methods = SourceImpl.class.getMethods();
+ for (Method method : methods) {
+ if (method.getName().startsWith("set")) {
+ members.put(JavaIntrospectionHelper.toPropertyName(method.getName()), method);
+ }
+ }
+ }
+
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java
new file mode 100644
index 0000000000..3c2093eee7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaIDLUtils;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.implementation.java.JavaTargetInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public final class MockFactory {
+
+ private static final WireService WIRE_SERVICE = new JDKWireService(new WorkContextImpl(), null);
+ private static final JavaInterfaceProcessorRegistry REGISTRY = new JavaInterfaceProcessorRegistryImpl();
+
+ private MockFactory() {
+ }
+
+ /**
+ * Creates a JavaAtomicComponent which returns the given instance
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> JavaAtomicComponent createJavaComponent(T instance) {
+ ScopeContainer scope = createMock(ScopeContainer.class);
+ scope.getScope();
+ expectLastCall().andReturn(Scope.MODULE);
+ scope.getInstance(isA(JavaAtomicComponent.class));
+ expectLastCall().andReturn(instance).anyTimes();
+ replay(scope);
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ try {
+ configuration.setInstanceFactory(new PojoObjectFactory(DummyImpl.class.getConstructor()));
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError(e);
+ }
+ configuration.addServiceInterface(DummyImpl.class);
+ configuration.setWireService(WIRE_SERVICE);
+ return new JavaAtomicComponent(instance.getClass().getName(), configuration, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> JavaAtomicComponent createJavaComponent(String name, ScopeContainer scope, Class<T> clazz)
+ throws NoSuchMethodException {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor()));
+ configuration.addServiceInterface(clazz);
+ configuration.setWireService(WIRE_SERVICE);
+ return new JavaAtomicComponent(name, configuration, null);
+
+ }
+
+ /**
+ * Wires two contexts together where the reference interface is the same as target service
+ *
+ * @param sourceName
+ * @param sourceClass
+ * @param sourceScope
+ * @param members
+ * @param targetName
+ * @param targetService
+ * @param targetClass
+ * @param targetScope
+ * @return
+ * @throws Exception
+ */
+ public static Map<String, AtomicComponent> createWiredComponents(String sourceName,
+ Class<?> sourceClass,
+ ScopeContainer sourceScope,
+ Map<String, Member> members,
+ String targetName,
+ Class<?> targetService,
+ Class<?> targetClass,
+ ScopeContainer targetScope) throws Exception {
+ return createWiredComponents(sourceName, sourceClass, targetService, sourceScope, members, targetName,
+ targetService, targetClass, targetScope);
+
+ }
+
+ /**
+ * Wires two contexts together where the reference interface may be different from the target service
+ */
+ public static Map<String, AtomicComponent> createWiredComponents(String sourceName, Class<?> sourceClass,
+ Class<?> sourceReferenceClass,
+ ScopeContainer sourceScope,
+ Map<String, Member> members,
+ String targetName,
+ Class<?> targetService,
+ Class<?> targetClass,
+ ScopeContainer targetScope) throws Exception {
+ return createWiredComponents(sourceName,
+ sourceClass,
+ sourceReferenceClass,
+ sourceScope,
+ null,
+ members,
+ targetName,
+ targetService,
+ targetClass,
+ targetScope,
+ null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, AtomicComponent> createWiredComponents(String sourceName, Class<?> sourceClass,
+ Class<?> sourceReferenceClass,
+ ScopeContainer sourceScope,
+ Interceptor sourceHeadInterceptor,
+ Map<String, Member> members,
+ String targetName, Class<?> targetService,
+ Class<?> targetClass,
+ ScopeContainer targetScope,
+ Interceptor targetHeadInterceptor)
+ throws Exception {
+
+ JavaAtomicComponent targetContext =
+ createJavaComponent(targetName, targetScope, targetClass);
+ String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1);
+ InboundWire inboundWire = createServiceWire(serviceName, targetService, targetHeadInterceptor);
+ targetContext.addInboundWire(inboundWire);
+
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(sourceScope);
+ configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+ configuration.addServiceInterface(sourceClass);
+ configuration.setWireService(WIRE_SERVICE);
+ for (Map.Entry<String, Member> entry : members.entrySet()) {
+ configuration.addReferenceSite(entry.getKey(), entry.getValue());
+ }
+ JavaAtomicComponent sourceContext = new JavaAtomicComponent(sourceName, configuration, null);
+ OutboundWire outboundWire = createReferenceWire(targetName, sourceReferenceClass, sourceHeadInterceptor);
+ sourceContext.addOutboundWire(outboundWire);
+ targetScope.register(targetContext);
+ sourceScope.register(sourceContext);
+ connect(outboundWire, inboundWire, targetContext, false);
+ Map<String, AtomicComponent> contexts = new HashMap<String, AtomicComponent>();
+ contexts.put(sourceName, sourceContext);
+ contexts.put(targetName, targetContext);
+ return contexts;
+ }
+
+
+ /**
+ * Wires two contexts using a multiplicity reference
+ *
+ * @param sourceName
+ * @param sourceClass
+ * @param sourceReferenceClass
+ * @param sourceScope
+ * @param targetName
+ * @param targetService
+ * @param targetClass
+ * @param members
+ * @param targetScope
+ * @return
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public static Map<String, AtomicComponent> createWiredMultiplicity(String sourceName, Class<?> sourceClass,
+ Class<?> sourceReferenceClass,
+ ScopeContainer sourceScope,
+ String targetName, Class<?> targetService,
+ Class<?> targetClass,
+ Map<String, Member> members,
+ ScopeContainer targetScope) throws Exception {
+ JavaAtomicComponent targetContext =
+ createJavaComponent(targetName, targetScope, targetClass);
+ String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1);
+ InboundWire inboundWire = createServiceWire(serviceName, targetService, null);
+ targetContext.addInboundWire(inboundWire);
+
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(sourceScope);
+ configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+ configuration.addServiceInterface(sourceClass);
+ configuration.setWireService(WIRE_SERVICE);
+ for (Map.Entry<String, Member> entry : members.entrySet()) {
+ configuration.addReferenceSite(entry.getKey(), entry.getValue());
+ }
+ JavaAtomicComponent sourceContext = new JavaAtomicComponent(sourceName, configuration, null);
+ OutboundWire outboundWire = createReferenceWire(targetName, sourceReferenceClass, null);
+ List<OutboundWire> factories = new ArrayList<OutboundWire>();
+ factories.add(outboundWire);
+ sourceContext.addOutboundWires(sourceReferenceClass, factories);
+ targetScope.register(targetContext);
+ sourceScope.register(sourceContext);
+ connect(outboundWire, inboundWire, targetContext, false);
+ Map<String, AtomicComponent> contexts = new HashMap<String, AtomicComponent>();
+ contexts.put(sourceName, sourceContext);
+ contexts.put(targetName, targetContext);
+ return contexts;
+ }
+
+ public static <T> InboundWire createTargetWire(String serviceName, Class<T> interfaze)
+ throws InvalidServiceContractException {
+ return createServiceWire(serviceName, interfaze, null);
+ }
+
+
+ public static <T> InboundWire createServiceWire(String serviceName, Class<T> interfaze, Interceptor interceptor)
+ throws InvalidServiceContractException {
+ InboundWire wire = new InboundWireImpl();
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ wire.setServiceContract(contract);
+ wire.setServiceName(serviceName);
+ wire.addInvocationChains(
+ createInboundChains(interfaze, interceptor));
+ return wire;
+ }
+
+ public static <T> OutboundWire createReferenceWire(String refName, Class<T> interfaze, Interceptor interceptor)
+ throws InvalidServiceContractException {
+
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setReferenceName(refName);
+ Map<Operation<?>, OutboundInvocationChain> outboundChains = createOutboundChains(interfaze, interceptor);
+ wire.addInvocationChains(outboundChains);
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ wire.setServiceContract(contract);
+ return wire;
+ }
+
+ public static <T> OutboundWire createReferenceWire(String refName, Class<T> interfaze)
+ throws InvalidServiceContractException {
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setReferenceName(refName);
+ wire.addInvocationChains(createOutboundChains(interfaze));
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ wire.setServiceContract(contract);
+ return wire;
+ }
+
+
+ /**
+ * @param outboundWire
+ * @param inboundWire
+ * @param targetContext
+ * @param cacheable
+ * @throws Exception
+ */
+ public static void connect(OutboundWire outboundWire,
+ InboundWire inboundWire,
+ JavaAtomicComponent targetContext,
+ boolean cacheable) throws Exception {
+ if (inboundWire != null) {
+ // if null, the target side has no interceptors or handlers
+ Map<Operation<?>, InboundInvocationChain> targetInvocationConfigs = inboundWire.getInvocationChains();
+ for (OutboundInvocationChain outboundInvocationConfig : outboundWire.getInvocationChains().values()) {
+ // match wire chains
+ InboundInvocationChain inboundInvocationConfig =
+ targetInvocationConfigs.get(outboundInvocationConfig.getOperation());
+ if (inboundInvocationConfig == null) {
+ BuilderConfigException e =
+ new BuilderConfigException("Incompatible source and target interface types for reference");
+ e.setIdentifier(outboundWire.getReferenceName());
+ throw e;
+ }
+ if (inboundInvocationConfig.getHeadInterceptor() == null) {
+ BuilderConfigException e =
+ new BuilderConfigException("No target handler or interceptor for operation");
+ e.setIdentifier(inboundInvocationConfig.getOperation().getName());
+ throw e;
+ }
+ if (!(outboundInvocationConfig.getTailInterceptor() instanceof InvokerInterceptor
+ && inboundInvocationConfig.getHeadInterceptor() instanceof InvokerInterceptor)) {
+ // check that we do not have the case where the only interceptors are invokers since we just
+ // need one
+ outboundInvocationConfig.setTargetInterceptor(inboundInvocationConfig.getHeadInterceptor());
+ }
+ }
+
+ for (OutboundInvocationChain chain : outboundWire.getInvocationChains().values()) {
+ //FIXME should use target method, not outboundInvocationConfig.getMethod()
+ Method[] methods = outboundWire.getServiceContract().getInterfaceClass().getMethods();
+ Method m = JavaIDLUtils.findMethod(chain.getOperation(), methods);
+ TargetInvoker invoker = new JavaTargetInvoker(m, targetContext);
+ invoker.setCacheable(cacheable);
+ chain.setTargetInvoker(invoker);
+ }
+ }
+ }
+
+ private static Map<Operation<?>, OutboundInvocationChain> createOutboundChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
+ return createOutboundChains(interfaze, null);
+ }
+
+ private static Map<Operation<?>, OutboundInvocationChain> createOutboundChains(Class<?> interfaze,
+ Interceptor interceptor)
+ throws InvalidServiceContractException {
+ Map<Operation<?>, OutboundInvocationChain> invocations = new HashMap<Operation<?>, OutboundInvocationChain>();
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ for (Operation<?> operation : contract.getOperations().values()) {
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ if (interceptor != null) {
+ chain.addInterceptor(interceptor);
+ }
+ invocations.put(operation, chain);
+ }
+ return invocations;
+ }
+
+ private static Map<Operation<?>, InboundInvocationChain> createInboundChains(Class<?> interfaze,
+ Interceptor interceptor)
+ throws InvalidServiceContractException {
+
+ Map<Operation<?>, InboundInvocationChain> invocations = new HashMap<Operation<?>, InboundInvocationChain>();
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ for (Operation<?> method : contract.getOperations().values()) {
+ InboundInvocationChain chain = new InboundInvocationChainImpl(method);
+ if (interceptor != null) {
+ chain.addInterceptor(interceptor);
+ }
+ // add tail interceptor
+ chain.addInterceptor(new InvokerInterceptor());
+ invocations.put(method, chain);
+ }
+ return invocations;
+ }
+
+ private static class DummyImpl {
+ public DummyImpl() {
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/AsyncTarget.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/AsyncTarget.java
new file mode 100644
index 0000000000..1abc9781e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/AsyncTarget.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+import org.osoa.sca.annotations.OneWay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface AsyncTarget {
+ @OneWay
+ void invoke();
+
+ int getCount();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTarget.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTarget.java
new file mode 100644
index 0000000000..87b1fd87fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTarget.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface OtherTarget {
+
+ String getString();
+
+ void setString(String val);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTargetImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTargetImpl.java
new file mode 100644
index 0000000000..b32fc7547e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/OtherTargetImpl.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+/**
+ * A target used for testing wires with a different source and target interface
+ *
+ * @version $Rev$ $Date$
+ */
+public class OtherTargetImpl implements OtherTarget {
+
+ private String theString;
+
+ public String getString() {
+ return theString;
+ }
+
+ public void setString(String val) {
+ theString = val;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Source.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Source.java
new file mode 100644
index 0000000000..bffacc3c20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Source.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+import java.util.List;
+
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Source {
+
+ Target getTarget();
+
+ List<Target> getTargets();
+
+ List<Target> getTargetsThroughField();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/SourceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/SourceImpl.java
new file mode 100644
index 0000000000..bf9e30b306
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/SourceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+import java.util.List;
+
+
+/**
+ * Mock system component implementation used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public class SourceImpl implements Source {
+
+ private Target target;
+ private List<Target> targets;
+ private Target[] targetsArray;
+ private List<Target> targetsThroughField;
+
+ public void setTarget(Target target) {
+ this.target = target;
+ }
+
+ public Target getTarget() {
+ return target;
+ }
+
+ public List<Target> getTargets() {
+ return targets;
+ }
+
+ public void setTargets(List<Target> targets) {
+ this.targets = targets;
+ }
+
+ public List<Target> getTargetsThroughField() {
+ return targetsThroughField;
+ }
+
+
+ public Target[] getArrayOfTargets() {
+ return targetsArray;
+ }
+
+ public void setArrayOfTargets(Target[] targets) {
+ targetsArray = targets;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Target.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Target.java
new file mode 100644
index 0000000000..cafebc0801
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/Target.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Target {
+
+ String getString();
+
+ void setString(String val);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/TargetImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/TargetImpl.java
new file mode 100644
index 0000000000..060ca292a9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/components/TargetImpl.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.java.mock.components;
+
+/**
+ * Mock system component implementation used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetImpl implements Target {
+
+ private String theString;
+
+ public String getString() {
+ return theString;
+ }
+
+ public void setString(String val) {
+ theString = val;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java
new file mode 100644
index 0000000000..c67d226b41
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorAutowireTestCase extends TestCase {
+
+ ConstructorProcessor processor =
+ new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ public void testAutowire() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Bar.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertNotNull(type.getReferences().get("myRef"));
+ }
+
+ public void testNamesOnConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Bar.class, Bar.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertEquals(2, type.getConstructorDefinition().getInjectionNames().size());
+ assertNotNull(type.getReferences().get("myRef1"));
+ assertNotNull(type.getReferences().get("myRef2"));
+ }
+
+ public void testNoName() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo2> ctor = Foo2.class.getConstructor(Bar.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertNotNull(type.getReferences().get(Bar.class.getName() + "0"));
+ }
+
+ public void testInvalidNumberOfNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Bar.class, Bar.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidAutowireException e) {
+ // expected
+ }
+ }
+
+ public void testNoMatchingNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ /**
+ * Verifies processing executes with additional extension annotations
+ */
+ public void testRandomAnnotation() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo3> ctor = Foo3.class.getConstructor(String.class, String.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertEquals(1, type.getProperties().size());
+ assertNotNull(type.getProperties().get("prop1"));
+ }
+
+ private static interface Bar {
+
+ }
+
+ private static class Foo {
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Autowire(name = "myRef") Bar ref) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor({"myRef1", "myRef2"})
+ public Foo(@Autowire Bar ref1, @Autowire Bar ref2) {
+
+ }
+
+ }
+
+ private static class Foo2 {
+ @org.osoa.sca.annotations.Constructor()
+ public Foo2(@Autowire Bar ref) {
+
+ }
+ }
+
+ private static class BadFoo {
+
+ @org.osoa.sca.annotations.Constructor({"ref1"})
+ public BadFoo(@Autowire Bar ref1, @Autowire Bar ref2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"})
+ public BadFoo(@Autowire List ref, @Autowire(name = "myOtherRef") List ref2) {
+
+ }
+
+ }
+
+ public static class Foo3 {
+
+ @org.osoa.sca.annotations.Constructor
+ public Foo3(@Property(name = "prop1") String prop, @Baz String baz) {
+ }
+ }
+
+ public @interface Baz {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java
new file mode 100644
index 0000000000..25a8ab9a1a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * Verifies the constructor processor works when parameters are marked with custom extension annotations
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstructorProcessorExtensibilityTestCase extends TestCase {
+ private ConstructorProcessor processor =
+ new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ public void testProcessFirst() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class, String.class);
+ processor.visitConstructor(null, ctor1, type, null);
+ assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+ }
+
+ /**
+ * Verifies the constructor processor can be called after another processor has evaluated the constructor and found
+ * an annotation
+ *
+ * @throws Exception
+ */
+ public void testProcessLast() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class, String.class);
+ ConstructorDefinition<Foo> definition = new ConstructorDefinition<Foo>(ctor1);
+ definition.getInjectionNames().add("");
+ definition.getInjectionNames().add("mybar");
+ type.setConstructorDefinition(definition);
+ processor.visitConstructor(null, ctor1, type, null);
+ assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+ }
+
+
+ private @interface Bar {
+
+ }
+
+ private static class Foo {
+ @org.osoa.sca.annotations.Constructor
+ public Foo(@Property(name = "foo") String foo, @Bar String bar) {
+
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java
new file mode 100644
index 0000000000..364bfcc274
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorProcessorTestCase extends TestCase {
+ private ConstructorProcessor processor =
+ new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ public void testDuplicateConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitClass(null, BadFoo.class, type, null);
+ fail();
+ } catch (DuplicateConstructorException e) {
+ // expected
+ }
+ }
+
+ public void testConstructorAnnotation() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class);
+ processor.visitConstructor(null, ctor1, type, null);
+ assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+ }
+
+ public void testNoAnnotation() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<NoAnnotation> ctor1 = NoAnnotation.class.getConstructor();
+ processor.visitConstructor(null, ctor1, type, null);
+ assertNull(type.getConstructorDefinition());
+ }
+
+ public void testBadAnnotation() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadAnnotation> ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class);
+ try {
+ processor.visitConstructor(null, ctor1, type, null);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ public void testMixedParameters() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Mixed> ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class);
+ processor.visitConstructor(null, ctor1, type, null);
+ assertEquals("java.lang.String0", type.getConstructorDefinition().getInjectionNames().get(0));
+ assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(1));
+ assertEquals("bar", type.getConstructorDefinition().getInjectionNames().get(2));
+ }
+
+ public void testAllAutowireWithNoNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<AllAutowireNoName> ctor1 =
+ AllAutowireNoName.class.getConstructor(String.class, String.class, String.class);
+ processor.visitConstructor(null, ctor1, type, null);
+ assertEquals("java.lang.String0", type.getConstructorDefinition().getInjectionNames().get(0));
+ assertEquals("java.lang.String1", type.getConstructorDefinition().getInjectionNames().get(1));
+ assertEquals("java.lang.String2", type.getConstructorDefinition().getInjectionNames().get(2));
+ }
+
+ private static class BadFoo {
+
+ @org.osoa.sca.annotations.Constructor("foo")
+ public BadFoo(String foo) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor({"foo", "bar"})
+ public BadFoo(String foo, String bar) {
+
+ }
+ }
+
+ private static class Foo {
+ @org.osoa.sca.annotations.Constructor("foo")
+ public Foo(String foo) {
+
+ }
+ }
+
+ private static class NoAnnotation {
+ public NoAnnotation() {
+ }
+ }
+
+ private static class BadAnnotation {
+ @org.osoa.sca.annotations.Constructor("foo")
+ public BadAnnotation(String foo, Foo ref) {
+ }
+ }
+
+
+ public static final class Mixed {
+ @org.osoa.sca.annotations.Constructor
+ public Mixed(@Autowire String param1,
+ @Property(name = "foo") String param2,
+ @Reference(name = "bar") String param3) {
+ }
+ }
+
+ public static final class AllAutowireNoName {
+ @org.osoa.sca.annotations.Constructor
+ public AllAutowireNoName(@Autowire String param1, @Autowire String param2, @Autowire String param3) {
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java
new file mode 100644
index 0000000000..ee461aead7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.OverrideOptions;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorPropertyTestCase extends TestCase {
+
+ ConstructorProcessor processor =
+ new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ public void testProperty() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ processor.visitConstructor(null, ctor, type, null);
+ JavaMappedProperty<?> property = type.getProperties().get("myProp");
+ //assertTrue(property.isRequired());
+ assertEquals(property.getOverride(), OverrideOptions.MAY);
+ assertEquals("myProp", property.getName());
+ }
+
+ public void testTwoPropertiesSameType() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertNotNull(type.getProperties().get("myProp1"));
+ assertNotNull(type.getProperties().get("myProp2"));
+ }
+
+ public void testDuplicateProperty() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ public void testNoName() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidPropertyException e) {
+ // expected
+ }
+ }
+
+ public void testNamesOnConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertNotNull(type.getProperties().get("myProp"));
+ }
+
+ public void testInvalidNumberOfNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidPropertyException e) {
+ // expected
+ }
+ }
+
+ public void testNoMatchingNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+// public void testMultiplicityRequired() throws Exception {
+ // TODO multiplicity
+// }
+
+ private static class Foo {
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Property(name = "myProp", override = "may") String prop) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor("myProp")
+ public Foo(@Property Integer prop) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Property(name = "myProp1") String prop1, @Property(name = "myProp2") String prop2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Property List prop) {
+
+ }
+ }
+
+ private static class BadFoo {
+
+ @org.osoa.sca.annotations.Constructor()
+ public BadFoo(@Property(name = "myProp") String prop1, @Property(name = "myProp") String prop2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor()
+ public BadFoo(@Property String prop) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor("myProp")
+ public BadFoo(@Property Integer prop, @Property Integer prop2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"})
+ public BadFoo(@Property List ref, @Property(name = "myOtherRef") List ref2) {
+
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java
new file mode 100644
index 0000000000..687c95e860
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorReferenceTestCase extends TestCase {
+
+ ConstructorProcessor processor;
+
+ public void testReference() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ processor.visitConstructor(null, ctor, type, null);
+ JavaMappedReference reference = type.getReferences().get("myRef");
+ assertTrue(reference.isRequired());
+ assertEquals("myRef", reference.getName());
+ }
+
+ public void testTwoReferencesSameType() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertNotNull(type.getReferences().get("myRef1"));
+ assertNotNull(type.getReferences().get("myRef2"));
+ }
+
+ public void testDuplicateProperty() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (DuplicateReferenceException e) {
+ // expected
+ }
+ }
+
+ public void testNoName() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidReferenceException e) {
+ // expected
+ }
+ }
+
+ public void testNamesOnConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+ processor.visitConstructor(null, ctor, type, null);
+ assertNotNull(type.getReferences().get("myRef"));
+ }
+
+ public void testInvalidNumberOfNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidReferenceException e) {
+ // expected
+ }
+ }
+
+ public void testNoMatchingNames() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+ try {
+ processor.visitConstructor(null, ctor, type, null);
+ fail();
+ } catch (InvalidConstructorException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ processor =
+ new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+ }
+
+// public void testMultiplicityRequired() throws Exception {
+ // TODO multiplicity
+// }
+
+ private static class Foo {
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Reference(name = "myRef", required = true) String prop) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Reference(name = "myRef1") String prop1, @Reference(name = "myRef2") String prop2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor("myRef")
+ public Foo(@Reference Integer prop) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor()
+ public Foo(@Reference List prop) {
+
+ }
+ }
+
+ private static class BadFoo {
+
+ @org.osoa.sca.annotations.Constructor
+ public BadFoo(@Reference(name = "myRef") String prop1, @Reference(name = "myRef") String prop2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor
+ public BadFoo(@Reference String prop) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor("myRef")
+ public BadFoo(@Reference Integer ref, @Reference Integer ref2) {
+
+ }
+
+ @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"})
+ public BadFoo(@Reference List ref, @Reference(name = "myOtherRef") List ref2) {
+
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java
new file mode 100644
index 0000000000..6929250298
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Method;
+
+import org.osoa.sca.annotations.Destroy;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DestroyProcessorTestCase extends TestCase {
+
+ public void testDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = Foo.class.getMethod("destroy");
+ processor.visitMethod(null, method, type, null);
+ assertNotNull(type.getDestroyMethod());
+ }
+
+ public void testBadDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = Bar.class.getMethod("badDestroy", String.class);
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalDestructorException e) {
+ // expected
+ }
+ }
+
+ public void testTwoDestroy() throws Exception {
+ DestroyProcessor processor = new DestroyProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = Bar.class.getMethod("destroy");
+ Method method2 = Bar.class.getMethod("destroy2");
+ processor.visitMethod(null, method, type, null);
+ try {
+ processor.visitMethod(null, method2, type, null);
+ fail();
+ } catch (DuplicateDestructorException e) {
+ // expected
+ }
+ }
+
+
+ private class Foo {
+
+ @Destroy
+ public void destroy() {
+ }
+ }
+
+
+ private class Bar {
+
+ @Destroy
+ public void destroy() {
+ }
+
+ @Destroy
+ public void destroy2() {
+ }
+
+ @Destroy
+ public void badDestroy(String foo) {
+ }
+
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java
new file mode 100644
index 0000000000..93de605e33
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeuristicAndPropertyTestCase extends TestCase {
+
+ private PropertyProcessor propertyProcessor;
+ private HeuristicPojoProcessor heuristicProcessor;
+
+ /**
+ * Verifies the property and heuristic processors don't collide
+ */
+ @SuppressWarnings("unchecked")
+ public void testPropertyProcessorWithHeuristicProcessor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor ctor = Foo.class.getConstructor(String.class);
+ type.setConstructorDefinition(new ConstructorDefinition(ctor));
+ propertyProcessor.visitConstructor(null, ctor, type, null);
+ heuristicProcessor.visitEnd(null, Foo.class, type, null);
+ assertEquals(1, type.getProperties().size());
+ assertNotNull(type.getProperties().get("foo"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ImplementationProcessorServiceImpl service =
+ new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl());
+ propertyProcessor = new PropertyProcessor(service);
+ heuristicProcessor = new HeuristicPojoProcessor(service);
+ }
+
+ public static class Foo {
+ public Foo(@Property(name = "foo") String prop) {
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java
new file mode 100644
index 0000000000..92f6d54366
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Remotable;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeuristicConstructorTestCase extends TestCase {
+
+ private HeuristicPojoProcessor processor =
+ new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ /**
+ * Verifies a single constructor is chosen with a parameter as the type
+ */
+ public void testSingleConstructorWithParam() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ JavaMappedProperty<String> prop = new JavaMappedProperty<String>();
+ prop.setName("foo");
+ prop.setJavaType(String.class);
+ type.getProperties().put("foo", prop);
+ processor.visitEnd(null, Foo1.class, type, null);
+ assertNotNull(type.getConstructorDefinition().getConstructor());
+ assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+ }
+
+ /**
+ * Verifies a single constructor is chosen with a reference as the type
+ */
+ public void testSingleConstructorWithRef() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ JavaMappedReference ref = new JavaMappedReference();
+ ref.setName("foo");
+ ServiceContract contract = new JavaServiceContract(String.class);
+ ref.setServiceContract(contract);
+ type.getReferences().put("foo", ref);
+ processor.visitEnd(null, Foo1.class, type, null);
+ assertNotNull(type.getConstructorDefinition().getConstructor());
+ assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+ }
+
+ /**
+ * Verifies a single constructor is chosen with a property and a reference as the type
+ */
+ public void testSingleConstructorWithPropRef() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+
+ JavaMappedProperty<String> prop = new JavaMappedProperty<String>();
+ prop.setName("foo");
+ prop.setJavaType(String.class);
+ type.getProperties().put("foo", prop);
+
+ JavaMappedReference ref = new JavaMappedReference();
+ ref.setName("ref");
+ ServiceContract contract = new JavaServiceContract(Foo1.class);
+ ref.setServiceContract(contract);
+ type.getReferences().put("ref", ref);
+ processor.visitEnd(null, Foo2.class, type, null);
+ assertNotNull(type.getConstructorDefinition().getConstructor());
+ assertEquals(2, type.getConstructorDefinition().getInjectionNames().size());
+ }
+
+
+ public void testSingleConstructorResolvableParam() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo5.class, type, null);
+ assertEquals(String.class, type.getProperties().get("string").getJavaType());
+ }
+
+ public void testSingleConstructorResolvableRef() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo6.class, type, null);
+ assertEquals(Ref.class,
+ type.getReferences().get("heuristicconstructortestcase$ref").getServiceContract().getInterfaceClass());
+ }
+
+ public void testSingleConstructorAmbiguousRef() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ JavaMappedReference ref = new JavaMappedReference();
+ ref.setName("ref");
+ ServiceContract contract = new JavaServiceContract(Foo1.class);
+ ref.setServiceContract(contract);
+ type.getReferences().put("ref", ref);
+ JavaMappedReference ref2 = new JavaMappedReference();
+ ref2.setName("ref2");
+ ref2.setServiceContract(contract);
+ type.getReferences().put("ref2", ref2);
+ try {
+ processor.visitEnd(null, Foo4.class, type, null);
+ fail();
+ } catch (AmbiguousConstructorException e) {
+ // expected
+ }
+ }
+
+ public void testConstructorPropertyAnnotatedParamsOnly() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo7.class, type, null);
+ assertNotNull(type.getProperties().get("myProp"));
+ }
+
+ public void testConstructorReferenceAnnotatedParamsOnly() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo8.class, type, null);
+ assertNotNull(type.getReferences().get("myRef"));
+ }
+
+ public void testConstructorAutowireAnnotatedParamsOnly() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo9.class, type, null);
+ assertNotNull(type.getReferences().get("myAutowire"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testDefaultConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo3.class, type, null);
+ assertNotNull(type.getConstructorDefinition().getConstructor());
+ }
+
+ public void testSameTypesButAnnotated() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo12.class, type, null);
+ assertEquals(2, type.getProperties().size());
+ assertNotNull(type.getProperties().get("prop1"));
+ assertNotNull(type.getProperties().get("prop2"));
+ }
+
+ /**
+ * Verifies processing executes with additional extension annotations
+ */
+ public void testRandomAnnotation() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo11.class, type, null);
+ assertEquals(1, type.getProperties().size());
+ assertNotNull(type.getProperties().get("prop1"));
+ }
+
+ public void testAutowire() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo13.class, type, null);
+ assertEquals(1, type.getReferences().size());
+ assertNotNull(type.getReferences().get(String.class.getName() + "0"));
+ }
+
+ public void testMultipleAutowire() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo15.class, type, null);
+ assertEquals(2, type.getReferences().size());
+ assertNotNull(type.getReferences().get(String.class.getName() + "0"));
+ assertNotNull(type.getReferences().get(String.class.getName() + "1"));
+ }
+
+ public void testNoAutowireNameInConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo16.class, type, null);
+ assertEquals(2, type.getReferences().size());
+ assertNotNull(type.getReferences().get(String.class.getName() + "0"));
+ assertNotNull(type.getReferences().get("bar"));
+ assertNotNull(type.getProperties().get("foo"));
+ }
+
+ public void testPrivateConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitEnd(null, Foo14.class, type, null);
+ fail();
+ } catch (NoConstructorException e) {
+ // expected
+ }
+ }
+
+
+ public void testMultipleConstructors() throws Exception {
+ // throw new UnsupportedOperationException("Finish heuristic multiple constructors - Foo10");
+ }
+
+
+ public static class Foo1 {
+ public Foo1(String val) {
+ }
+ }
+
+ public static class Foo2 {
+ public Foo2(String val, Foo1 ref) {
+ }
+ }
+
+ public static class Foo3 {
+ }
+
+ public static class Foo4 {
+ public Foo4(Foo1 ref) {
+ }
+ }
+
+ public static class Prop {
+
+ }
+
+ @Remotable
+ public static interface Ref {
+
+ }
+
+ public static class Foo5 {
+ public Foo5(String val) {
+ }
+ }
+
+ public static class Foo6 {
+ public Foo6(Ref ref) {
+ }
+ }
+
+ public static class Foo7 {
+ public Foo7(@Property(name = "myProp") String prop) {
+ }
+ }
+
+
+ public static class Foo8 {
+ public Foo8(@Reference(name = "myRef") String ref) {
+ }
+ }
+
+ public static class Foo9 {
+ public Foo9(@Autowire(name = "myAutowire") String autowire) {
+ }
+ }
+
+ public static class Foo10 {
+
+ public Foo10() {
+ }
+
+ public Foo10(String prop) {
+ }
+
+ public Foo10(@Property(name = "prop1") String prop1, @Property(name = "prop2") String prop2) {
+
+ }
+ }
+
+ public static class Foo11 {
+
+ public Foo11(@Property(name = "prop1") String prop, @Baz String baz) {
+ }
+ }
+
+ public static class Foo12 {
+
+ public Foo12(@Property(name = "prop1") String prop, @Property(name = "prop2") String baz) {
+ }
+ }
+
+ public @interface Baz {
+
+ }
+
+ public static class Foo13 {
+ public Foo13(@Autowire String foo) {
+ }
+ }
+
+ public static final class Foo14 {
+ private Foo14() {
+ }
+ }
+
+ public static final class Foo15 {
+ public Foo15(@Autowire String param1, @Autowire String param2) {
+ }
+ }
+
+ public static final class Foo16 {
+ public Foo16(@Autowire String param1,
+ @Property(name = "foo") String param2,
+ @Reference(name = "bar") String param3) {
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
new file mode 100644
index 0000000000..659cbbd115
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.List;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * Verfies component type information is properly introspected from an unadorned POJO according to the SCA Java Client
+ * and Implementation Model Specification
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeuristicPojoProcessorTestCase extends TestCase {
+
+ private HeuristicPojoProcessor processor =
+ new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ /**
+ * Verifies a single service interface is computed when only one interface is implemented
+ */
+ public void testSingleInterface() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<SingleInterfaceImpl>(ctor));
+ processor.visitEnd(null, SingleInterfaceImpl.class, type, null);
+ assertEquals(1, type.getServices().size());
+ assertEquals(PropertyInterface.class,
+ type.getServices().get("HeuristicPojoProcessorTestCase$PropertyInterface")
+ .getServiceContract().getInterfaceClass());
+ assertTrue(type.getProperties().isEmpty());
+ assertTrue(type.getReferences().isEmpty());
+ }
+
+ /**
+ * Verifies property and reference setters are computed
+ */
+ public void testPropertyReference() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<SingleInterfaceWithPropertyReferenceImpl> ctor =
+ SingleInterfaceWithPropertyReferenceImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<SingleInterfaceWithPropertyReferenceImpl>(ctor));
+ processor.visitEnd(null, SingleInterfaceWithPropertyReferenceImpl.class, type, null);
+ assertEquals(1, type.getServices().size());
+ assertEquals(Interface1.class,
+ type.getServices().get("HeuristicPojoProcessorTestCase$Interface1")
+ .getServiceContract().getInterfaceClass());
+ assertEquals(1, type.getProperties().size());
+ assertEquals(ComplexProperty.class, type.getProperties().get("property").getJavaType());
+ assertEquals(1, type.getReferences().size());
+ assertEquals(Ref.class, type.getReferences().get("reference").getServiceContract().getInterfaceClass());
+ }
+
+ /**
+ * Verifies that a property setter is not introspected if an analogous operation is in the service interface
+ */
+ public void testPropertySetterInInterface() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<SingleInterfaceImpl>(ctor));
+ processor.visitEnd(null, SingleInterfaceImpl.class, type, null);
+ assertEquals(0, type.getProperties().size());
+ }
+
+ /**
+ * Verifies that a reference setter is not introspected if an analogous operation is in the service interface
+ */
+ public void testReferenceSetterInInterface() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<RefInterfaceImpl> ctor = RefInterfaceImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<RefInterfaceImpl>(ctor));
+ processor.visitEnd(null, RefInterfaceImpl.class, type, null);
+ assertEquals(0, type.getReferences().size());
+ }
+
+ /**
+ * Verifies collection generic types or array types are introspected as references according to spec rules
+ */
+ public void testReferenceCollectionType() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<ReferenceCollectionImpl> ctor = ReferenceCollectionImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<ReferenceCollectionImpl>(ctor));
+ processor.visitEnd(null, ReferenceCollectionImpl.class, type, null);
+ assertEquals(0, type.getProperties().size());
+ assertEquals(4, type.getReferences().size());
+ }
+
+ /**
+ * Verifies collection generic types or array types are introspected as properties according to spec rules
+ */
+ public void testPropertyCollectionType() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<PropertyCollectionImpl> ctor = PropertyCollectionImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<PropertyCollectionImpl>(ctor));
+ processor.visitEnd(null, PropertyCollectionImpl.class, type, null);
+ assertEquals(0, type.getReferences().size());
+ assertEquals(4, type.getProperties().size());
+ }
+
+ /**
+ * Verifies references are calculated when the type marked with is @Remotable
+ */
+ public void testRemotableRef() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<RemotableRefImpl> ctor = RemotableRefImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<RemotableRefImpl>(ctor));
+ processor.visitEnd(null, RemotableRefImpl.class, type, null);
+ assertEquals(2, type.getReferences().size());
+ assertEquals(0, type.getProperties().size());
+ }
+
+ public void testParentInterface() throws ProcessingException, NoSuchMethodException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Child> ctor = Child.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<Child>(ctor));
+ processor.visitEnd(null, Child.class, type, null);
+ assertTrue(type.getServices().containsKey("HeuristicPojoProcessorTestCase$Interface1"));
+ }
+
+ /**
+ * Verifies a service inteface is calculated when only props and refs are given
+ */
+ public void testExcludedPropertyAndReference() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ JavaMappedReference ref = new JavaMappedReference();
+ ref.setName("reference");
+ type.add(ref);
+ JavaMappedReference ref2 = new JavaMappedReference();
+ ref2.setName("reference2");
+ type.add(ref2);
+ JavaMappedProperty<?> prop1 = new JavaMappedProperty();
+ prop1.setName("string1");
+ type.add(prop1);
+ JavaMappedProperty<?> prop2 = new JavaMappedProperty();
+ prop2.setName("string2");
+ type.add(prop2);
+ processor.visitEnd(null, ServiceImpl.class, type, null);
+ assertEquals(1, type.getServices().size());
+ }
+
+ public void testProtectedRemotableRefField() throws ProcessingException, NoSuchMethodException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<ProtectedRemotableRefFieldImpl> ctor = ProtectedRemotableRefFieldImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<ProtectedRemotableRefFieldImpl>(ctor));
+ processor.visitEnd(null, ProtectedRemotableRefFieldImpl.class, type, null);
+ assertNotNull(type.getReferences().get("otherRef"));
+ }
+
+ public void testProtectedRemotableRefMethod() throws ProcessingException, NoSuchMethodException {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<ProtectedRemotableRefMethodImpl> ctor = ProtectedRemotableRefMethodImpl.class.getConstructor();
+ type.setConstructorDefinition(new ConstructorDefinition<ProtectedRemotableRefMethodImpl>(ctor));
+ processor.visitEnd(null, ProtectedRemotableRefMethodImpl.class, type, null);
+ assertNotNull(type.getReferences().get("otherRef"));
+ }
+
+ private interface PropertyInterface {
+ void setString1(String val);
+ }
+
+ private interface Interface1 {
+ }
+
+ private static class Parent implements Interface1 {
+
+ }
+
+ private static class Child extends Parent {
+ public Child() {
+ }
+
+ }
+
+ private static class SingleInterfaceImpl implements PropertyInterface {
+ public SingleInterfaceImpl() {
+ }
+
+ public void setString1(String val) {
+ }
+
+ }
+
+ private interface HeuristicServiceInterface {
+ void fooOperation(String ref);
+ void setInvalid1(); // No parameter
+ void setInvalid2(String str, int i); // More than one parameter
+ String setInvalid3(String str); // return should be void
+ }
+
+ public static class ServiceImpl implements PropertyInterface, RefInterface, HeuristicServiceInterface {
+
+ @Property
+ public void setString1(String val) {
+ }
+
+ @Property
+ public void setString2(String val) {
+ }
+
+ @Reference
+ public void setReference(Ref ref) {
+ }
+
+ @Reference
+ public void setReference2(Ref ref) {
+ }
+
+ public void fooOperation(String ref) {
+
+ }
+ public void setInvalid1() {
+ }
+
+ public void setInvalid2(String str, int i) {
+ }
+
+ public String setInvalid3(String str) {
+ return null;
+ }
+
+ }
+
+ @Service
+ private interface Ref {
+ }
+
+ private class ComplexProperty {
+ }
+
+ private interface RefInterface {
+ void setReference(Ref ref);
+ }
+
+ private static class RefInterfaceImpl implements RefInterface {
+ public RefInterfaceImpl() {
+ }
+
+ public void setReference(Ref ref) {
+ }
+ }
+
+ private static class SingleInterfaceWithPropertyReferenceImpl implements Interface1 {
+ public SingleInterfaceWithPropertyReferenceImpl() {
+ }
+
+ public void setReference(Ref ref) {
+ }
+
+ public void setProperty(ComplexProperty prop) {
+ }
+ }
+
+ private static class ReferenceCollectionImpl implements Interface1 {
+ public ReferenceCollectionImpl() {
+ }
+
+ public void setCollectionReference(Collection<Ref> ref) {
+ }
+
+ public void setNonGenericCollectionReference(Collection ref) {
+ }
+
+ public void setListReference(List<Ref> ref) {
+ }
+
+ public void setArrayReference(Ref[] ref) {
+ }
+ }
+
+ private static class PropertyCollectionImpl implements Interface1 {
+ public PropertyCollectionImpl() {
+ }
+
+ public void setCollectionProperty(Collection<ComplexProperty> prop) {
+ }
+
+ public void setCollectionProperty2(Collection<String> prop) {
+ }
+
+ public void setArrayProperty(ComplexProperty[] prop) {
+ }
+
+ public void setArrayProperty2(String[] prop) {
+ }
+ }
+
+ @Remotable
+ private interface RemotableRef {
+ }
+
+ private static class RemotableRefImpl implements Interface1 {
+ protected RemotableRef otherRef;
+
+ public RemotableRefImpl() {
+ }
+
+ public void setRef(RemotableRef ref) {
+
+ }
+ }
+
+ private static class ProtectedRemotableRefFieldImpl implements Interface1 {
+ protected RemotableRef otherRef;
+
+ public ProtectedRemotableRefFieldImpl() {
+ }
+
+ public ProtectedRemotableRefFieldImpl(RemotableRef otherRef) {
+ this.otherRef = otherRef;
+ }
+
+ }
+
+ private static class ProtectedRemotableRefMethodImpl implements Interface1 {
+ public ProtectedRemotableRefMethodImpl() {
+ }
+
+ protected void setOtherRef(RemotableRef otherRef) {
+ }
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java
new file mode 100644
index 0000000000..4e6c1063d8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * Verifies constructors that have extensible annotation types, i.e. that have parameters marked by annotations which
+ * are themselves processed by some other implementation processor
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeutisticExtensibleConstructorTestCase extends TestCase {
+
+ private HeuristicPojoProcessor processor =
+ new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ /**
+ * Verifies heuristic processing can be called priot to an extension annotation processors being called.
+ */
+ public void testBarAnnotationProcessedFirst() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+ ConstructorDefinition<Foo> definition = new ConstructorDefinition<Foo>(ctor);
+ type.setConstructorDefinition(definition);
+ JavaMappedProperty property = new JavaMappedProperty();
+ property.setName("myBar");
+ definition.getInjectionNames().add("myBar");
+ type.getProperties().put("myBar", property);
+ processor.visitEnd(null, Foo.class, type, null);
+ assertEquals(2, type.getProperties().size());
+ }
+
+ /**
+ * Verifies heuristic processing can be called before an extension annotation processors is called.
+ * <p/>
+ * For example, given:
+ * <pre> Foo(@Bar String prop, @org.osoa.sca.annotations.Property(name = "foo") String prop2)</pre>
+ * <p/>
+ * Heuristic evaluation of @Property can occur prior to another implementation processor evaluating @Bar
+ *
+ * @throws Exception
+ */
+ public void testBarAnnotationProcessedLast() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitEnd(null, Foo.class, type, null);
+
+ // now simulate process the bar impl
+ ConstructorDefinition<?> definition = type.getConstructorDefinition();
+ List<String> injectionNames = definition.getInjectionNames();
+ injectionNames.remove(0);
+ injectionNames.add(0, "mybar");
+ type.getProperties().put("mybar", new JavaMappedProperty<String>());
+
+ assertEquals(2, type.getProperties().size());
+ assertEquals("foo", definition.getInjectionNames().get(1));
+ }
+
+ /**
+ * Verifies heuristic processing can be called before an extension annotation processors is called with the
+ * extension parameter in a middle position. Specifically, verifies that the heuristic processor updates injection
+ * names and preserves their ordering.
+ */
+ public void testBarAnnotationProcessedFirstInMiddle() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Foo2> ctor = Foo2.class.getConstructor(String.class, String.class, String.class);
+ ConstructorDefinition<Foo2> definition = new ConstructorDefinition<Foo2>(ctor);
+ type.setConstructorDefinition(definition);
+ // insert placeholder for first param, which would be done by a processor
+ definition.getInjectionNames().add("");
+ JavaMappedProperty property = new JavaMappedProperty();
+ property.setName("myBar");
+ definition.getInjectionNames().add("myBar");
+ type.getProperties().put("myBar", property);
+ processor.visitEnd(null, Foo2.class, type, null);
+ assertEquals("baz", definition.getInjectionNames().get(0));
+ assertEquals(2, type.getProperties().size());
+ assertEquals(1, type.getReferences().size());
+ }
+
+ public @interface Bar {
+
+ }
+
+ public static class Foo {
+ public Foo(@Bar String prop, @org.osoa.sca.annotations.Property(name = "foo") String prop2) {
+ }
+ }
+
+ public static class Foo2 {
+ public Foo2(@org.osoa.sca.annotations.Reference(name = "baz") String prop1,
+ @Bar String prop2,
+ @org.osoa.sca.annotations.Property(name = "foo") String prop3) {
+ }
+ }
+
+
+}
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java
new file mode 100644
index 0000000000..3fbe5a8350
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImplementationProcessorServiceTestCase extends TestCase {
+
+ private ImplementationProcessorService implService =
+ new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl());
+
+ public void testCreateConversationalService() throws Exception {
+ JavaMappedService service = implService.createService(Foo.class);
+ assertTrue(Foo.class.equals(service.getServiceContract().getInterfaceClass()));
+ assertTrue(service.isRemotable());
+ assertEquals(InteractionScope.CONVERSATIONAL, service.getServiceContract().getInteractionScope());
+ ServiceContract serviceContract = service.getServiceContract();
+ assertTrue(Bar.class.equals(serviceContract.getCallbackClass()));
+ assertTrue("ImplementationProcessorServiceTestCase$Bar".equals(serviceContract.getCallbackName()));
+ }
+
+ public void testCreateDefaultService() throws Exception {
+ JavaMappedService service = implService.createService(Baz.class);
+ assertTrue(Baz.class.equals(service.getServiceContract().getInterfaceClass()));
+ assertTrue(!service.isRemotable());
+ assertEquals(InteractionScope.NONCONVERSATIONAL, service.getServiceContract().getInteractionScope());
+ }
+
+
+ @Callback(Bar.class)
+ @Remotable
+ @Scope("CONVERSATIONAL")
+ public interface Foo {
+
+ }
+
+ public interface Bar {
+
+ }
+
+ public interface Baz {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java
new file mode 100644
index 0000000000..da45ed2d46
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImplementationProcessorServiceUniqueTestCase extends TestCase {
+
+ private ImplementationProcessorService service =
+ new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl());
+
+ public void testUniquess1() throws Exception {
+ Class[] classes = new Class[2];
+ classes[0] = String.class;
+ classes[1] = Integer.class;
+ assertTrue(service.areUnique(classes));
+ }
+
+ public void testUniquess2() throws Exception {
+ Class[] classes = new Class[2];
+ classes[0] = String.class;
+ classes[1] = String.class;
+ assertFalse(service.areUnique(classes));
+ }
+
+ public void testUniquess3() throws Exception {
+ Class[] classes = new Class[1];
+ classes[0] = String.class;
+ assertTrue(service.areUnique(classes));
+ }
+
+ public void testUniquess4() throws Exception {
+ Class[] classes = new Class[3];
+ classes[0] = String.class;
+ classes[1] = Integer.class;
+ classes[2] = String.class;
+ assertFalse(service.areUnique(classes));
+ }
+
+ public void testUniquess5() throws Exception {
+ Class[] classes = new Class[0];
+ assertTrue(service.areUnique(classes));
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java
new file mode 100644
index 0000000000..059094f922
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Method;
+
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InitProcessorTestCase extends TestCase {
+
+ public void testInit() throws Exception {
+ InitProcessor processor = new InitProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = InitProcessorTestCase.Foo.class.getMethod("init");
+ processor.visitMethod(null, method, type, null);
+ assertNotNull(type.getInitMethod());
+ assertEquals(50, type.getInitLevel());
+ }
+
+ public void testBadInit() throws Exception {
+ InitProcessor processor = new InitProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = InitProcessorTestCase.Bar.class.getMethod("badInit", String.class);
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalInitException e) {
+ // expected
+ }
+ }
+
+ public void testTwoInit() throws Exception {
+ InitProcessor processor = new InitProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = InitProcessorTestCase.Bar.class.getMethod("init");
+ Method method2 = InitProcessorTestCase.Bar.class.getMethod("init2");
+ processor.visitMethod(null, method, type, null);
+ try {
+ processor.visitMethod(null, method2, type, null);
+ fail();
+ } catch (DuplicateInitException e) {
+ // expected
+ }
+ }
+
+
+ private class Foo {
+ @Init(eager = true)
+ public void init() {
+ }
+ }
+
+
+ private class Bar {
+ @Init
+ public void init() {
+ }
+
+ @Init
+ public void init2() {
+ }
+
+ @Init
+ public void badInit(String foo) {
+ }
+
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java
new file mode 100644
index 0000000000..8982fa3991
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.IllegalPropertyException;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.api.annotation.Monitor;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.host.MonitorFactory;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MonitorProcessorTestCase extends TestCase {
+
+ private MonitorProcessor processor;
+ private MonitorFactory monitorFactory;
+
+ public void testSetter() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = Foo.class.getMethod("setMonitor", Foo.class);
+ EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(Foo.class))).andReturn(null);
+ EasyMock.replay(monitorFactory);
+ processor.visitMethod(null, method, type, null);
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ assertTrue(properties.get("monitor").getDefaultValueFactory() instanceof SingletonObjectFactory);
+ EasyMock.verify(monitorFactory);
+ }
+
+
+ public void testBadSetter() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Method method = BadMonitor.class.getMethod("setMonitor");
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalPropertyException e) {
+ // expected
+ }
+ }
+
+ public void testField() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Field field = Foo.class.getDeclaredField("bar");
+ EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(Foo.class))).andReturn(null);
+ EasyMock.replay(monitorFactory);
+ processor.visitField(null, field, type, null);
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ assertTrue(properties.get("bar").getDefaultValueFactory() instanceof SingletonObjectFactory);
+ EasyMock.verify(monitorFactory);
+ }
+
+ public void testConstructor() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Bar> ctor = Bar.class.getConstructor(BazMonitor.class);
+ EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(BazMonitor.class))).andReturn(null);
+ EasyMock.replay(monitorFactory);
+ processor.visitConstructor(null, ctor, type, null);
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ assertTrue(
+ properties.get(BazMonitor.class.getName()).getDefaultValueFactory() instanceof SingletonObjectFactory);
+ EasyMock.verify(monitorFactory);
+ }
+
+ /**
+ * Verifies calling the monitor processor to evaluate a constructor can be done after a property parameter is
+ * processed
+ */
+ public void testConstructorAfterProperty() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Bar> ctor = Bar.class.getConstructor(String.class, BazMonitor.class);
+ EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(BazMonitor.class))).andReturn(null);
+ EasyMock.replay(monitorFactory);
+ ConstructorDefinition<Bar> definition = new ConstructorDefinition<Bar>(ctor);
+ JavaMappedProperty prop = new JavaMappedProperty();
+ definition.getInjectionNames().add("prop");
+ type.setConstructorDefinition(definition);
+ type.getProperties().put("prop", prop);
+ processor.visitConstructor(null, ctor, type, null);
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ assertEquals(BazMonitor.class.getName(), definition.getInjectionNames().get(1));
+ assertEquals(2, type.getProperties().size());
+ String name = BazMonitor.class.getName();
+ assertTrue(properties.get(name).getDefaultValueFactory() instanceof SingletonObjectFactory);
+ EasyMock.verify(monitorFactory);
+ }
+
+ /**
+ * Verifies calling the monitor processor to evaluate a constructor can be done before a property parameter is
+ * processed
+ */
+ public void testConstructorBeforeProperty() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ Constructor<Bar> ctor = Bar.class.getConstructor(String.class, BazMonitor.class);
+ EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(BazMonitor.class))).andReturn(null);
+ EasyMock.replay(monitorFactory);
+ processor.visitConstructor(null, ctor, type, null);
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ ConstructorDefinition definition = type.getConstructorDefinition();
+ assertEquals(2, definition.getInjectionNames().size());
+ assertEquals(BazMonitor.class.getName(), definition.getInjectionNames().get(1));
+ String name = BazMonitor.class.getName();
+ assertTrue(properties.get(name).getDefaultValueFactory() instanceof SingletonObjectFactory);
+ EasyMock.verify(monitorFactory);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ monitorFactory = EasyMock.createMock(MonitorFactory.class);
+ JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl();
+ ImplementationProcessorServiceImpl processor = new ImplementationProcessorServiceImpl(registry);
+ this.processor = new MonitorProcessor(monitorFactory, processor);
+ }
+
+ private class Foo {
+
+ @Monitor
+ protected Foo bar;
+
+ @Monitor
+ public void setMonitor(Foo foo) {
+ }
+ }
+
+
+ private class BadMonitor {
+
+ @Monitor
+ public void setMonitor() {
+ }
+ }
+
+ private interface BazMonitor {
+
+ }
+
+ private static class Bar {
+
+ public Bar(@Monitor BazMonitor monitor) {
+ }
+
+ public Bar(String prop, @Monitor BazMonitor monitor) {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java
new file mode 100644
index 0000000000..412c9f9d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import static org.apache.tuscany.spi.model.OverrideOptions.MUST;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException;
+import org.apache.tuscany.spi.implementation.java.IllegalPropertyException;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.OverrideOptions;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PropertyProcessorTestCase extends TestCase {
+
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type;
+ PropertyProcessor processor;
+
+ public void testMethodAnnotation() throws Exception {
+ processor.visitMethod(null, Foo.class.getMethod("setFoo", String.class), type, null);
+ assertNotNull(type.getProperties().get("foo"));
+ }
+
+ public void testMethodRequired() throws Exception {
+ processor.visitMethod(null, Foo.class.getMethod("setFooRequired", String.class), type, null);
+ JavaMappedProperty prop = type.getProperties().get("fooRequired");
+ assertNotNull(prop);
+ assertEquals(prop.getOverride(), MUST);
+ }
+
+ public void testMethodName() throws Exception {
+ processor.visitMethod(null, Foo.class.getMethod("setBarMethod", String.class), type, null);
+ assertNotNull(type.getProperties().get("bar"));
+ }
+
+ public void testFieldAnnotation() throws Exception {
+ processor.visitField(null, Foo.class.getDeclaredField("baz"), type, null);
+ assertNotNull(type.getProperties().get("baz"));
+ }
+
+ public void testFieldRequired() throws Exception {
+ processor.visitField(null, Foo.class.getDeclaredField("bazRequired"), type, null);
+ JavaMappedProperty prop = type.getProperties().get("bazRequired");
+ assertNotNull(prop);
+ assertEquals(prop.getOverride(), OverrideOptions.MUST);
+ }
+
+ public void testFieldName() throws Exception {
+ processor.visitField(null, Foo.class.getDeclaredField("bazField"), type, null);
+ assertNotNull(type.getProperties().get("theBaz"));
+ }
+
+ public void testDuplicateFields() throws Exception {
+ processor.visitField(null, Bar.class.getDeclaredField("dup"), type, null);
+ try {
+ processor.visitField(null, Bar.class.getDeclaredField("baz"), type, null);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ public void testDuplicateMethods() throws Exception {
+ processor.visitMethod(null, Bar.class.getMethod("dupMethod", String.class), type, null);
+ try {
+ processor.visitMethod(null, Bar.class.getMethod("dupSomeMethod", String.class), type, null);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ // expected
+ }
+ }
+
+ public void testInvalidProperty() throws Exception {
+ try {
+ processor.visitMethod(null, Bar.class.getMethod("badMethod"), type, null);
+ fail();
+ } catch (IllegalPropertyException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl();
+ processor = new PropertyProcessor(new ImplementationProcessorServiceImpl(registry));
+ }
+
+ private class Foo {
+
+ @Property
+ protected String baz;
+ @Property(override = "must")
+ protected String bazRequired;
+ @Property(name = "theBaz")
+ protected String bazField;
+
+ @Property
+ public void setFoo(String string) {
+ }
+
+ @Property(override = "must")
+ public void setFooRequired(String string) {
+ }
+
+ @Property(name = "bar")
+ public void setBarMethod(String string) {
+ }
+
+ }
+
+ private class Bar {
+
+ @Property
+ protected String dup;
+
+ @Property(name = "dup")
+ protected String baz;
+
+ @Property
+ public void dupMethod(String s) {
+ }
+
+ @Property(name = "dupMethod")
+ public void dupSomeMethod(String s) {
+ }
+
+ @Property
+ public void badMethod() {
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java
new file mode 100644
index 0000000000..e60cf58fb5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceProcessorTestCase extends TestCase {
+
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ ReferenceProcessor processor =
+ new ReferenceProcessor(new JavaInterfaceProcessorRegistryImpl());
+
+ public void testMethodAnnotation() throws Exception {
+ processor.visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setFoo", Ref.class), type, null);
+ JavaMappedReference reference = type.getReferences().get("foo");
+ assertNotNull(reference);
+ ServiceContract contract = reference.getServiceContract();
+ assertEquals(Ref.class, contract.getInterfaceClass());
+ assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName());
+ }
+
+ public void testMethodRequired() throws Exception {
+ processor
+ .visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setFooRequired", Ref.class), type, null);
+ JavaMappedReference prop = type.getReferences().get("fooRequired");
+ assertNotNull(prop);
+ assertTrue(prop.isRequired());
+ }
+
+ public void testMethodName() throws Exception {
+ processor
+ .visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setBarMethod", Ref.class), type, null);
+ assertNotNull(type.getReferences().get("bar"));
+ }
+
+ public void testFieldAnnotation() throws Exception {
+ processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("baz"), type, null);
+ JavaMappedReference reference = type.getReferences().get("baz");
+ assertNotNull(reference);
+ ServiceContract contract = reference.getServiceContract();
+ assertEquals(Ref.class, contract.getInterfaceClass());
+ assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName());
+ }
+
+ public void testFieldRequired() throws Exception {
+ processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazRequired"), type, null);
+ JavaMappedReference prop = type.getReferences().get("bazRequired");
+ assertNotNull(prop);
+ assertTrue(prop.isRequired());
+ }
+
+ public void testFieldName() throws Exception {
+ processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazField"), type, null);
+ assertNotNull(type.getReferences().get("theBaz"));
+ }
+
+ public void testDuplicateFields() throws Exception {
+ processor.visitField(null, ReferenceProcessorTestCase.Bar.class.getDeclaredField("dup"), type, null);
+ try {
+ processor.visitField(null, ReferenceProcessorTestCase.Bar.class.getDeclaredField("baz"), type, null);
+ fail();
+ } catch (DuplicateReferenceException e) {
+ //expected
+ }
+ }
+
+ public void testDuplicateMethods() throws Exception {
+ processor.visitMethod(null, ReferenceProcessorTestCase.Bar.class.getMethod("dupMethod", Ref.class), type, null);
+ try {
+ processor
+ .visitMethod(null, ReferenceProcessorTestCase.Bar.class.getMethod("dupSomeMethod", Ref.class), type,
+ null);
+ fail();
+ } catch (DuplicateReferenceException e) {
+ //expected
+ }
+ }
+
+ public void testInvalidProperty() throws Exception {
+ try {
+ processor.visitMethod(null, ReferenceProcessorTestCase.Bar.class.getMethod("badMethod"), type, null);
+ fail();
+ } catch (IllegalReferenceException e) {
+ //expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor = new ReferenceProcessor(new JavaInterfaceProcessorRegistryImpl());
+ }
+
+ private interface Ref {
+ }
+
+ private class Foo {
+
+ @Reference
+ protected Ref baz;
+ @Reference(required = true)
+ protected Ref bazRequired;
+ @Reference(name = "theBaz")
+ protected Ref bazField;
+
+
+ @Reference
+ public void setFoo(Ref ref) {
+ }
+
+ @Reference(required = true)
+ public void setFooRequired(Ref ref) {
+ }
+
+ @Reference(name = "bar")
+ public void setBarMethod(Ref ref) {
+ }
+
+ }
+
+
+ private class Bar {
+
+ @Reference
+ protected Ref dup;
+
+ @Reference(name = "dup")
+ protected Ref baz;
+
+ @Reference
+ public void dupMethod(Ref s) {
+ }
+
+ @Reference(name = "dupMethod")
+ public void dupSomeMethod(Ref s) {
+ }
+
+ @Reference
+ public void badMethod() {
+ }
+
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java
new file mode 100644
index 0000000000..09152c9009
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeProcessorTestCase extends TestCase {
+
+ CompositeComponent parent;
+
+ public void testModuleScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+
+ processor.visitClass(parent, Module.class, type, null);
+ assertEquals(Scope.MODULE, type.getImplementationScope());
+ }
+
+ public void testSessionScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(parent, Session.class, type, null);
+ assertEquals(Scope.SESSION, type.getImplementationScope());
+ }
+
+ public void testRequestScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(parent, Request.class, type, null);
+ assertEquals(Scope.REQUEST, type.getImplementationScope());
+ }
+
+ public void testCompositeScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(parent, Composite.class, type, null);
+ assertEquals(Scope.COMPOSITE, type.getImplementationScope());
+ }
+
+ public void testStatelessScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(parent, Stateless.class, type, null);
+ assertEquals(Scope.STATELESS, type.getImplementationScope());
+ }
+
+ public void testNoScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(parent, None.class, type, null);
+ assertEquals(Scope.STATELESS, type.getImplementationScope());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ }
+
+ @org.osoa.sca.annotations.Scope("MODULE")
+ private class Module {
+ }
+
+ @org.osoa.sca.annotations.Scope("SESSION")
+ private class Session {
+ }
+
+ @org.osoa.sca.annotations.Scope("REQUEST")
+ private class Request {
+ }
+
+ @org.osoa.sca.annotations.Scope("COMPOSITE")
+ private class Composite {
+ }
+
+ @org.osoa.sca.annotations.Scope("STATELESS")
+ private class Stateless {
+ }
+
+ private class None {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java
new file mode 100644
index 0000000000..e5b5698e23
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Service;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.idl.java.IllegalCallbackException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceCallbackTestCase extends TestCase {
+
+ ServiceProcessor processor =
+ new ServiceProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+
+ public void testMethodCallbackInterface() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(null, FooImpl.class, type, null);
+ JavaMappedService service = type.getServices().get("ServiceCallbackTestCase$Foo");
+ assertNotNull(service);
+ Method method = FooImpl.class.getMethod("setCallback", FooCallback.class);
+ processor.visitMethod(null, method, type, null);
+ assertEquals(method, service.getCallbackMember());
+ }
+
+ public void testFieldCallbackInterface() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(null, FooImpl.class, type, null);
+ JavaMappedService service = type.getServices().get("ServiceCallbackTestCase$Foo");
+ assertNotNull(service);
+ Field field = FooImpl.class.getDeclaredField("callback");
+ processor.visitField(null, field, type, null);
+ assertEquals(field, service.getCallbackMember());
+ }
+
+ public void testMethodDoesNotMatchCallback() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(null, BadBarImpl.class, type, null);
+ Method method = BadBarImpl.class.getMethod("setWrongInterfaceCallback", String.class);
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalCallbackReferenceException e) {
+ // expected
+ }
+ }
+
+ public void testNoParamCallback() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(null, BadBarImpl.class, type, null);
+ Method method = BadBarImpl.class.getMethod("setNoParamCallback");
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalCallbackReferenceException e) {
+ // expected
+ }
+ }
+
+ public void testFieldDoesNotMatchCallback() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(null, BadBarImpl.class, type, null);
+ Field field = BadBarImpl.class.getDeclaredField("wrongInterfaceCallback");
+ try {
+ processor.visitField(null, field, type, null);
+ fail();
+ } catch (IllegalCallbackReferenceException e) {
+ // expected
+ }
+ }
+
+ public void testBadCallbackInterfaceAnnotation() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitClass(null, BadFooImpl.class, type, null);
+ fail();
+ } catch (ProcessingException e) {
+ // expected
+ assertTrue(e.getCause() instanceof IllegalCallbackException);
+ }
+ }
+
+ @Callback(FooCallback.class)
+ private interface Foo {
+
+ }
+
+ private interface FooCallback {
+
+ }
+
+ @Service(Foo.class)
+ private static class FooImpl implements Foo {
+
+ @Callback
+ protected FooCallback callback;
+
+ @Callback
+ public void setCallback(FooCallback cb) {
+
+ }
+ }
+
+ private static class BadBarImpl implements Foo {
+ @Callback
+ protected String wrongInterfaceCallback;
+
+ @Callback
+ public void setWrongInterfaceCallback(String cb) {
+
+ }
+
+ @Callback
+ public void setNoParamCallback() {
+
+ }
+
+ }
+
+ @Callback
+ private interface BadFoo {
+
+ }
+
+ @Service(BadFoo.class)
+ private static class BadFooImpl implements BadFoo {
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java
new file mode 100644
index 0000000000..f2a22fcb85
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceProcessorTestCase extends TestCase {
+
+ private ServiceProcessor processor;
+ private PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type;
+
+ public void testMultipleInterfaces() throws Exception {
+ processor.visitClass(null, FooMultiple.class, type, null);
+ assertEquals(2, type.getServices().size());
+ JavaMappedService service = type.getServices().get("ServiceProcessorTestCase$Baz");
+ ServiceContract contract = service.getServiceContract();
+ assertEquals(Baz.class, contract.getInterfaceClass());
+ assertEquals(Bar.class, contract.getCallbackClass());
+ assertEquals("ServiceProcessorTestCase$Bar", contract.getCallbackName());
+ assertNotNull(type.getServices().get("ServiceProcessorTestCase$Bar"));
+ }
+
+ public void testSingleInterfaces() throws Exception {
+ processor.visitClass(null, FooSingle.class, type, null);
+ assertEquals(1, type.getServices().size());
+ assertNotNull(type.getServices().get("ServiceProcessorTestCase$Baz"));
+ }
+
+ public void testMultipleNoService() throws Exception {
+ processor.visitClass(null, FooMultipleNoService.class, type, null);
+ assertEquals(0, type.getServices().size());
+ }
+
+ public void testRemotableNoService() throws Exception {
+ processor.visitClass(null, FooRemotableNoService.class, type, null);
+ assertEquals(1, type.getServices().size());
+ JavaMappedService service = type.getServices().get("ServiceProcessorTestCase$BazRemotable");
+ ServiceContract contract = service.getServiceContract();
+ assertEquals(BazRemotable.class, contract.getInterfaceClass());
+ }
+
+ public void testNonInterface() throws Exception {
+ try {
+ processor.visitClass(null, BadImpl.class, type, null);
+ fail();
+ } catch (InvalidServiceType e) {
+ //expected
+ }
+ }
+
+ public void testNoInterfaces() throws Exception {
+ try {
+ processor.visitClass(null, BadDefinition.class, type, null);
+ fail();
+ } catch (IllegalServiceDefinitionException e) {
+ //expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl();
+ processor = new ServiceProcessor(new ImplementationProcessorServiceImpl(registry));
+ type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ }
+
+ @Callback(Bar.class)
+ private interface Baz {
+ }
+
+ private interface Bar {
+ }
+
+ @Remotable
+ private interface BazRemotable {
+ }
+
+ @Service(interfaces = {Baz.class, Bar.class})
+ private class FooMultiple implements Baz, Bar {
+
+ }
+
+ @Service(Baz.class)
+ private class FooSingle implements Baz, Bar {
+
+ }
+
+ private class FooMultipleNoService implements Baz, Bar {
+
+ }
+
+ private class FooRemotableNoService implements BazRemotable, Bar {
+
+ }
+
+ @Service(FooSingle.class)
+ private class BadImpl extends FooSingle {
+
+ }
+
+
+ @Service()
+ private class BadDefinition extends FooSingle {
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderTestCase.java
new file mode 100644
index 0000000000..97d69f976e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderTestCase.java
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.builder;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWire;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentBuilderTestCase extends TestCase {
+
+ CompositeComponent parent;
+ DeploymentContext deploymentContext;
+ SystemComponentBuilder builder = new SystemComponentBuilder();
+ ModuleScopeContainer container;
+
+ /**
+ * Verifies lifecycle callbacks are made
+ */
+ public void testLifecycleBuild() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setEagerInit(true);
+ Method initMethod = FooImpl.class.getMethod("init");
+ initMethod.setAccessible(true);
+ type.setInitMethod(initMethod);
+ Method destroyMethod = FooImpl.class.getMethod("destroy");
+ destroyMethod.setAccessible(true);
+ type.setDestroyMethod(destroyMethod);
+ type.setImplementationScope(Scope.MODULE);
+ ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
+ type.setConstructorDefinition(ctorDef);
+ SystemImplementation impl = new SystemImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooImpl.class);
+ ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ component.start();
+ container.onEvent(new CompositeStart(this, null));
+ FooImpl foo = (FooImpl) component.getServiceInstance();
+ assertTrue(foo.initialized);
+ container.onEvent(new CompositeStop(this, null));
+ assertTrue(foo.destroyed);
+ }
+
+ /**
+ * Verifies properties are built properly
+ */
+ public void testPropertyBuild() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setEagerInit(true);
+ Method initMethod = FooImpl.class.getMethod("init");
+ initMethod.setAccessible(true);
+ type.setInitMethod(initMethod);
+ Method destroyMethod = FooImpl.class.getMethod("destroy");
+ destroyMethod.setAccessible(true);
+ type.setDestroyMethod(destroyMethod);
+ type.setImplementationScope(Scope.MODULE);
+ JavaMappedProperty mappedProp = new JavaMappedProperty();
+ mappedProp.setName("prop");
+ Method propMethod = FooImpl.class.getMethod("setProp", String.class);
+ propMethod.setAccessible(true);
+ mappedProp.setMember(propMethod);
+ type.add(mappedProp);
+ ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
+ type.setConstructorDefinition(ctorDef);
+ SystemImplementation impl = new SystemImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooImpl.class);
+ ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
+ PropertyValue<String> propVal = new PropertyValue<String>();
+ propVal.setName("prop");
+ propVal.setValueFactory(new SingletonObjectFactory<String>("value"));
+ definition.add(propVal);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ component.start();
+ FooImpl foo = (FooImpl) component.getServiceInstance();
+ assertEquals("value", foo.prop);
+ container.onEvent(new CompositeStop(this, null));
+ }
+
+ /**
+ * Verifies references are built properly
+ */
+ public void testRefBuild() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setImplementationScope(Scope.MODULE);
+ JavaMappedReference mappedReference = new JavaMappedReference();
+ mappedReference.setName("ref");
+ Method refMethod = FooImpl.class.getMethod("setRef", Foo.class);
+ refMethod.setAccessible(true);
+ mappedReference.setMember(refMethod);
+ ServiceContract contract = new JavaServiceContract(Foo.class);
+ mappedReference.setServiceContract(contract);
+ type.add(mappedReference);
+ ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
+ type.setConstructorDefinition(ctorDef);
+ SystemImplementation impl = new SystemImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooImpl.class);
+ ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
+ ReferenceTarget target = new ReferenceTarget();
+ target.setReferenceName("ref");
+ target.addTarget(new URI("foo"));
+ definition.add(target);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ OutboundWire wire = component.getOutboundWires().get("ref").get(0);
+ SystemInboundWire inbound = EasyMock.createMock(SystemInboundWire.class);
+ FooImpl targetFoo = new FooImpl();
+ EasyMock.expect(inbound.getTargetService()).andReturn(targetFoo);
+ EasyMock.replay(inbound);
+ wire.setTargetWire(inbound);
+ component.start();
+ FooImpl foo = (FooImpl) component.getServiceInstance();
+ assertNotNull(foo.ref);
+ container.onEvent(new CompositeStop(this, null));
+ EasyMock.verify(inbound);
+ }
+
+ /**
+ * Verifies autowires are built properly
+ */
+ public void testAutowireBuild() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setImplementationScope(Scope.MODULE);
+ JavaMappedReference mappedReference = new JavaMappedReference();
+ mappedReference.setName("ref");
+ mappedReference.setAutowire(true);
+ Method refMethod = FooImpl.class.getMethod("setRef", Foo.class);
+ refMethod.setAccessible(true);
+ mappedReference.setMember(refMethod);
+ ServiceContract contract = new JavaServiceContract(Foo.class);
+ mappedReference.setServiceContract(contract);
+ type.add(mappedReference);
+ ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
+ type.setConstructorDefinition(ctorDef);
+ SystemImplementation impl = new SystemImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooImpl.class);
+ ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
+ CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
+ FooImpl targetFoo = new FooImpl();
+ EasyMock.expect(parent.resolveSystemInstance(EasyMock.eq(Foo.class))).andReturn(targetFoo);
+ EasyMock.replay(parent);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ component.start();
+ FooImpl foo = (FooImpl) component.getServiceInstance();
+ assertNotNull(foo.ref);
+ container.onEvent(new CompositeStop(this, null));
+ EasyMock.verify(parent);
+ }
+
+ /**
+ * Verifies constructor-based autowiring
+ */
+ public void testAutowireConstructorBuild() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ type.setImplementationScope(Scope.MODULE);
+ ConstructorDefinition<FooImpl2> ctorDef =
+ new ConstructorDefinition<FooImpl2>(FooImpl2.class.getConstructor(Foo.class));
+ ctorDef.getInjectionNames().add("ref");
+ type.setConstructorDefinition(ctorDef);
+ SystemImplementation impl = new SystemImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(FooImpl2.class);
+ JavaMappedReference mappedReference = new JavaMappedReference();
+ mappedReference.setName("ref");
+ mappedReference.setAutowire(true);
+ ServiceContract contract = new JavaServiceContract(Foo.class);
+ mappedReference.setServiceContract(contract);
+ type.add(mappedReference);
+ ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
+ CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
+ FooImpl targetFoo = new FooImpl();
+ EasyMock.expect(parent.resolveSystemInstance(EasyMock.eq(Foo.class))).andReturn(targetFoo);
+ EasyMock.replay(parent);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ component.start();
+ container.onEvent(new CompositeStart(this, null));
+ FooImpl2 foo = (FooImpl2) component.getServiceInstance();
+ assertNotNull(foo.getRef());
+ container.onEvent(new CompositeStop(this, null));
+ EasyMock.verify(parent);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ container = new ModuleScopeContainer();
+ container.start();
+ deploymentContext = EasyMock.createMock(DeploymentContext.class);
+ EasyMock.expect(deploymentContext.getModuleScope()).andReturn(container).atLeastOnce();
+ EasyMock.replay(deploymentContext);
+ }
+
+ private static interface Foo {
+
+ }
+
+ private static class FooImpl implements Foo {
+ private boolean initialized;
+ private boolean destroyed;
+ private String prop;
+ private Foo ref;
+
+ public FooImpl() {
+ }
+
+ public void init() {
+ if (initialized) {
+ fail();
+ }
+ initialized = true;
+ }
+
+ public void destroy() {
+ if (destroyed) {
+ fail();
+ }
+ destroyed = true;
+ }
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ public String getProp() {
+ return prop;
+ }
+
+ public void setProp(String prop) {
+ this.prop = prop;
+ }
+
+ public Foo getRef() {
+ return ref;
+ }
+
+ public void setRef(Foo ref) {
+ this.ref = ref;
+ }
+ }
+
+ private static class FooImpl2 implements Foo {
+ private Foo ref;
+
+ public FooImpl2(@Autowire Foo ref) {
+ this.ref = ref;
+ }
+
+ public Foo getRef() {
+ return ref;
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java
new file mode 100644
index 0000000000..29c37ba47a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.component;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies a system atomic component can be started and initialized
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemAtomicComponentTestCase extends TestCase {
+
+ private EventInvoker<Object> initInvoker;
+
+ public void testDefaultCreationAndInit() throws Exception {
+ PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(Foo.class.getConstructor((Class[]) null));
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.addServiceInterface(Foo.class);
+ configuration.setInstanceFactory(factory);
+ configuration.setInitInvoker(initInvoker);
+ SystemAtomicComponentImpl component = new SystemAtomicComponentImpl("foo", configuration);
+ Foo foo = (Foo) component.createInstance();
+ component.init(foo);
+ assertTrue(foo.initialized);
+ }
+
+ public void testReferenceAndPropertyConstructor() throws Exception {
+ PojoObjectFactory<Bar> factory = new PojoObjectFactory<Bar>(Bar.class.getConstructor(String.class, Foo.class));
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.addServiceInterface(Foo.class);
+ configuration.setInstanceFactory(factory);
+ configuration.setInitInvoker(initInvoker);
+ configuration.addConstructorParamName("foo");
+ configuration.addConstructorParamName("ref");
+ SystemAtomicComponentImpl component = new SystemAtomicComponentImpl("foo", configuration);
+ component.addPropertyFactory("foo", new SingletonObjectFactory<String>("baz"));
+ Foo target = new Foo();
+ SystemOutboundWire wire = EasyMock.createMock(SystemOutboundWire.class);
+ EasyMock.expect(wire.getTargetService()).andReturn(target);
+ EasyMock.expect(wire.getReferenceName()).andReturn("ref").anyTimes();
+ EasyMock.replay(wire);
+ component.addOutboundWire(wire);
+ Bar bar = (Bar) component.createInstance();
+ assertEquals("baz", bar.foo);
+ assertEquals(target, bar.ref);
+ EasyMock.verify(wire);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ initInvoker = new MethodEventInvoker<Object>(Foo.class.getMethod("init"));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public static class Foo {
+
+ private boolean initialized;
+
+ public void init() {
+ initialized = true;
+ }
+ }
+
+ public static class Bar {
+
+ private String foo;
+ private Foo ref;
+
+ public Bar(String foo, Foo ref) {
+ this.foo = foo;
+ this.ref = ref;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java
new file mode 100644
index 0000000000..e4eec8cae2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.loader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl;
+import org.apache.tuscany.core.implementation.processor.ConstructorProcessor;
+import org.apache.tuscany.core.implementation.processor.DestroyProcessor;
+import org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl;
+import org.apache.tuscany.core.implementation.processor.InitProcessor;
+import org.apache.tuscany.core.implementation.processor.PropertyProcessor;
+import org.apache.tuscany.core.implementation.processor.ReferenceProcessor;
+import org.apache.tuscany.core.implementation.processor.ScopeProcessor;
+import org.apache.tuscany.core.implementation.processor.ServiceProcessor;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.mock.component.BasicInterface;
+import org.apache.tuscany.core.mock.component.BasicInterfaceImpl;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentTypeLoaderTestCase extends TestCase {
+ private SystemComponentTypeLoader loader;
+
+ public void testIntrospectUnannotatedClass() throws ProcessingException {
+ CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
+ SystemImplementation impl = new SystemImplementation(BasicInterfaceImpl.class);
+ PojoComponentType<?, ?, ?> componentType = loader.loadByIntrospection(parent, impl, null);
+ ServiceDefinition service = componentType.getServices().get("BasicInterface");
+ assertEquals(BasicInterface.class, service.getServiceContract().getInterfaceClass());
+ Property<?> property = componentType.getProperties().get("publicProperty");
+ assertEquals(String.class, property.getJavaType());
+ ReferenceDefinition referenceDefinition = componentType.getReferences().get("protectedReference");
+ assertEquals(BasicInterface.class, referenceDefinition.getServiceContract().getInterfaceClass());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistryImpl interfaceProcessorRegistry = new JavaInterfaceProcessorRegistryImpl();
+ ImplementationProcessorService service =
+ new ImplementationProcessorServiceImpl(interfaceProcessorRegistry);
+ IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl();
+ registry.setMonitor(new NullMonitorFactory().getMonitor(IntrospectionRegistryImpl.Monitor.class));
+ registry.registerProcessor(new ConstructorProcessor(service));
+ registry.registerProcessor(new DestroyProcessor());
+ registry.registerProcessor(new InitProcessor());
+ registry.registerProcessor(new ScopeProcessor());
+ registry.registerProcessor(new PropertyProcessor(service));
+ registry.registerProcessor(new ReferenceProcessor(interfaceProcessorRegistry));
+ registry.registerProcessor(new ServiceProcessor(service));
+ registry.registerProcessor(new HeuristicPojoProcessor(service));
+ loader = new SystemComponentTypeLoader(registry);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/AtomicComponentWireInvocationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/AtomicComponentWireInvocationTestCase.java
new file mode 100644
index 0000000000..017274e455
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/AtomicComponentWireInvocationTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.mock.component.Source;
+import org.apache.tuscany.core.mock.component.SourceImpl;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.core.mock.component.TargetImpl;
+import org.easymock.EasyMock;
+
+/**
+ * Tests wiring from an system atomic context
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class AtomicComponentWireInvocationTestCase extends TestCase {
+
+ public void testWireResolution() throws NoSuchMethodException {
+ ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ Target target = new TargetImpl();
+ SystemInboundWire inboundWire = EasyMock.createMock(SystemInboundWire.class);
+ EasyMock.expect(inboundWire.getTargetService()).andReturn(target);
+ EasyMock.replay(inboundWire);
+
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.addReferenceSite("setTarget", SourceImpl.class.getMethod("setTarget", Target.class));
+ configuration.addServiceInterface(Source.class);
+ configuration.setInstanceFactory(new PojoObjectFactory<SourceImpl>(SourceImpl.class.getConstructor()));
+ SystemAtomicComponent sourceContext = new SystemAtomicComponentImpl("source", configuration);
+ QualifiedName qName = new QualifiedName("service");
+ OutboundWire outboundWire = new SystemOutboundWireImpl("setTarget", qName, Target.class);
+ outboundWire.setTargetWire(inboundWire);
+ sourceContext.addOutboundWire(outboundWire);
+ sourceContext.start();
+ assertSame(((Source) sourceContext.getServiceInstance()).getTarget(), target);
+ // wires should pass back direct ref
+ EasyMock.verify(inboundWire);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundtoOutboundTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundtoOutboundTestCase.java
new file mode 100644
index 0000000000..ed89fb6aae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundtoOutboundTestCase.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.core.mock.component.TargetImpl;
+import org.easymock.EasyMock;
+
+/**
+ * Tests connecting an inbound system wire to an outbound system wire
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemInboundtoOutboundTestCase extends TestCase {
+
+ public void testWire() throws NoSuchMethodException {
+ Target target = new TargetImpl();
+ SystemOutboundWire outboundWire = EasyMock.createMock(SystemOutboundWire.class);
+ EasyMock.expect(outboundWire.getTargetService()).andReturn(target);
+ EasyMock.replay(outboundWire);
+ SystemInboundWire inboundWire = new SystemInboundWireImpl("service", Target.class);
+ inboundWire.setTargetWire(outboundWire);
+ assertSame(inboundWire.getTargetService(), target);
+ EasyMock.verify(outboundWire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java
new file mode 100644
index 0000000000..8c00af6e9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemOutboundAutowireTestCase extends TestCase {
+
+ public void testAutowire() {
+ CompositeComponent component = createMock(CompositeComponent.class);
+ expect(component.resolveSystemInstance(Object.class)).andReturn(new Object());
+ replay(component);
+ SystemOutboundAutowire wire = new SystemOutboundAutowire("foo", Object.class, component, false);
+ assertNotNull(wire.getTargetService());
+ verify(component);
+ }
+
+
+ public void testNonExistentAutowire() {
+ CompositeComponent component = createMock(CompositeComponent.class);
+ expect(component.resolveSystemInstance(Object.class)).andReturn(null);
+ replay(component);
+ SystemOutboundAutowire wire = new SystemOutboundAutowire("foo", Object.class, component, true);
+ try {
+ wire.getTargetService();
+ fail();
+ } catch (TargetNotFoundException e) {
+ // expected
+ }
+ verify(component);
+ }
+
+
+ public void testNonExistentAutowireNotRequired() {
+ CompositeComponent component = createMock(CompositeComponent.class);
+ expect(component.resolveSystemInstance(Object.class)).andReturn(null);
+ replay(component);
+ SystemOutboundAutowire wire = new SystemOutboundAutowire("foo", Object.class, component, false);
+ try {
+ assertNull(wire.getTargetService());
+ } catch (TargetNotFoundException e) {
+ fail();
+ }
+ verify(component);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundToInboundTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundToInboundTestCase.java
new file mode 100644
index 0000000000..8f41a33c12
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundToInboundTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import org.apache.tuscany.spi.QualifiedName;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.core.mock.component.TargetImpl;
+import org.easymock.EasyMock;
+
+/**
+ * Tests connecting an outbound system wire to an inbound system wire
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemOutboundToInboundTestCase extends TestCase {
+
+ public void testWire() throws NoSuchMethodException {
+ Target target = new TargetImpl();
+ SystemInboundWire inboundWire = EasyMock.createMock(SystemInboundWire.class);
+ EasyMock.expect(inboundWire.getTargetService()).andReturn(target);
+ EasyMock.replay(inboundWire);
+ QualifiedName qName = new QualifiedName("service");
+ SystemOutboundWire outboundWire = new SystemOutboundWireImpl("setTarget", qName, Target.class);
+ outboundWire.setTargetWire(inboundWire);
+ assertSame(outboundWire.getTargetService(), target);
+ EasyMock.verify(inboundWire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemServiceComponentWireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemServiceComponentWireTestCase.java
new file mode 100644
index 0000000000..222b02f6a1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemServiceComponentWireTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.system.wire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.system.component.SystemService;
+import org.apache.tuscany.core.implementation.system.component.SystemServiceImpl;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.core.mock.component.TargetImpl;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies that a system context interacts correctly with configured, connected inbound and outbound system wires
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemServiceComponentWireTestCase extends TestCase {
+
+ public void testServiceContext() throws NoSuchMethodException {
+ Target target = new TargetImpl();
+ SystemOutboundWire outboundWire = EasyMock.createMock(SystemOutboundWire.class);
+ EasyMock.expect(outboundWire.getTargetService()).andReturn(target);
+ EasyMock.replay(outboundWire);
+ SystemInboundWire wire = new SystemInboundWireImpl("Target", Target.class);
+ SystemService serviceContext = new SystemServiceImpl("service", null);
+ serviceContext.setInboundWire(wire);
+ serviceContext.setOutboundWire(outboundWire);
+ wire.setTargetWire(outboundWire);
+ assertSame(target, serviceContext.getServiceInstance());
+ EasyMock.verify(outboundWire);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java
new file mode 100644
index 0000000000..8c3aea9dd3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CallbackWireObjectFactoryTestCase extends TestCase {
+
+ public void testCreateInstance() throws Exception {
+ JavaServiceContract contract = new JavaServiceContract();
+ contract.setCallbackClass(Foo.class);
+ WireService service = createMock(WireService.class);
+ service.createCallbackProxy(contract, null);
+ expectLastCall().andReturn(null);
+ replay(service);
+ CallbackWireObjectFactory factory = new CallbackWireObjectFactory(contract, service, null);
+ factory.getInstance();
+ verify(service);
+ }
+
+ private interface Foo {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java
new file mode 100644
index 0000000000..d31347f7e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Field;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FieldInjectorTestCase extends TestCase {
+
+ protected Field protectedField;
+
+ public void testIllegalAccess() throws Exception {
+ FieldInjector<Foo> injector = new FieldInjector<Foo>(protectedField, new SingletonObjectFactory<String>("foo"));
+ Foo foo = new Foo();
+ injector.inject(foo);
+ assertEquals("foo", foo.hidden);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ protectedField = Foo.class.getDeclaredField("hidden");
+ }
+
+ private class Foo {
+ private String hidden;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java
new file mode 100644
index 0000000000..91214fd02d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JNDIObjectFactoryTestCase extends TestCase {
+
+ public void testGetInstance() throws Exception {
+ Context ctx = EasyMock.createMock(Context.class);
+ EasyMock.expect(ctx.lookup(EasyMock.eq("foo"))).andReturn(new Foo());
+ EasyMock.replay(ctx);
+ JNDIObjectFactory<Foo> factory = new JNDIObjectFactory<Foo>(ctx, "foo");
+ assertTrue(factory.getInstance() instanceof Foo); // must do an instanceof b/c of type erasure
+ EasyMock.verify(ctx);
+ }
+
+ public void testGetInstanceError() throws Exception {
+ Context ctx = EasyMock.createMock(Context.class);
+ EasyMock.expect(ctx.lookup(EasyMock.eq("foo"))).andThrow(new NamingException());
+ EasyMock.replay(ctx);
+ JNDIObjectFactory<Foo> factory = new JNDIObjectFactory<Foo>(ctx, "foo");
+ try {
+ factory.getInstance();
+ fail();
+ } catch (ObjectCreationException e) {
+ //expected
+ }
+ EasyMock.verify(ctx);
+ }
+
+
+ private class Foo {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java
new file mode 100644
index 0000000000..3bb882da2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MethodEventInvokerTestCase extends TestCase {
+ private Method privateMethod;
+ private Method exceptionMethod;
+
+ public void testIllegalAccess() throws Exception {
+ MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(privateMethod);
+ try {
+ injector.invokeEvent(new Foo());
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ }
+
+ public void testException() throws Exception {
+ MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(exceptionMethod);
+ try {
+ injector.invokeEvent(new Foo());
+ fail();
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ privateMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("hidden");
+ exceptionMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("exception");
+
+ }
+
+ private class Foo {
+
+ public void foo() {
+ }
+
+ private void hidden() {
+ }
+
+ public void exception() {
+ throw new RuntimeException();
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java
new file mode 100644
index 0000000000..b21ba4ccfa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MethodInjectorTestCase extends TestCase {
+ private Method fooMethod;
+ private Method privateMethod;
+ private Method exceptionMethod;
+
+ public void testIllegalArgument() throws Exception {
+ ObjectFactory<Object> factory = new SingletonObjectFactory<Object>(new Object());
+ MethodInjector<Foo> injector = new MethodInjector<Foo>(fooMethod, factory);
+ try {
+ injector.inject(new Foo());
+ fail();
+ } catch (ObjectCreationException e) {
+ // expected
+ }
+ }
+
+ public void testException() throws Exception {
+ ObjectFactory<Object> factory = new SingletonObjectFactory<Object>("foo");
+ MethodInjector<Foo> injector = new MethodInjector<Foo>(exceptionMethod, factory);
+ try {
+ injector.inject(new Foo());
+ fail();
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ fooMethod = Foo.class.getMethod("foo", String.class);
+ privateMethod = Foo.class.getDeclaredMethod("hidden", String.class);
+ exceptionMethod = Foo.class.getDeclaredMethod("exception", String.class);
+
+ }
+
+ private class Foo {
+
+ public void foo(String bar) {
+ }
+
+ private void hidden(String bar) {
+ }
+
+ public void exception(String bar) {
+ throw new RuntimeException();
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java
new file mode 100644
index 0000000000..7aba6dbab3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.tuscany.spi.ObjectFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PojoObjectFactoryTestCase extends TestCase {
+
+ private Constructor<Foo> ctor;
+
+ public void testConstructorInjection() throws Exception {
+ List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
+ initializers.add(new SingletonObjectFactory<String>("foo"));
+ PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor, initializers);
+ Foo foo = factory.getInstance();
+ assertEquals("foo", foo.foo);
+ }
+
+ public void testConstructorInitializerInjection() throws Exception {
+ PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor);
+ factory.setInitializerFactory(0, new SingletonObjectFactory<String>("foo"));
+ Foo foo = factory.getInstance();
+ assertEquals("foo", foo.foo);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ctor = Foo.class.getConstructor(String.class);
+ }
+
+ private static class Foo {
+
+ private String foo;
+
+ public Foo(String foo) {
+ this.foo = foo;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java
new file mode 100644
index 0000000000..876e68d5b3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactoryTestCase extends TestCase {
+
+ public void testSingleton() throws Exception {
+ Object o = new Object();
+ SingletonObjectFactory<Object> factory = new SingletonObjectFactory<Object>(o);
+ assertEquals(o, factory.getInstance());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/WireObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/WireObjectFactoryTestCase.java
new file mode 100644
index 0000000000..e6e531dba7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/injection/WireObjectFactoryTestCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireObjectFactoryTestCase extends TestCase {
+
+ public void testCreateInstance() throws Exception {
+ RuntimeWire wire = createMock(RuntimeWire.class);
+ WireService service = createMock(WireService.class);
+ service.createProxy(wire);
+ expectLastCall().andReturn(null);
+ replay(service);
+ WireObjectFactory factory = new WireObjectFactory(wire, service);
+ factory.getInstance();
+ verify(service);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java
new file mode 100644
index 0000000000..a9b1353cdd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.integration.implementation;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import static org.apache.tuscany.spi.model.Scope.MODULE;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl;
+import org.apache.tuscany.core.implementation.processor.DestroyProcessor;
+import org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl;
+import org.apache.tuscany.core.implementation.processor.InitProcessor;
+import org.apache.tuscany.core.implementation.processor.PropertyProcessor;
+import org.apache.tuscany.core.implementation.processor.ReferenceProcessor;
+import org.apache.tuscany.core.implementation.processor.ScopeProcessor;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+
+/**
+ * Sanity check of the <code>IntegrationRegistry</code> to verify operation with processors
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntrospectionRegistryIntegrationTestCase extends TestCase {
+
+ private IntrospectionRegistryImpl registry;
+
+ public void testSimpleComponentTypeParsing() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ registry.introspect(null, Foo.class, type, null);
+ assertEquals(Foo.class.getMethod("init"), type.getInitMethod());
+ assertEquals(Foo.class.getMethod("destroy"), type.getDestroyMethod());
+ assertEquals(MODULE, type.getImplementationScope());
+ assertEquals(Foo.class.getMethod("setBar", String.class), type.getProperties().get("bar").getMember());
+ assertEquals(Foo.class.getMethod("setTarget", Foo.class), type.getReferences().get("target").getMember());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new IntrospectionRegistryImpl();
+ registry.setMonitor(new NullMonitorFactory().getMonitor(IntrospectionRegistryImpl.Monitor.class));
+ registry.registerProcessor(new DestroyProcessor());
+ registry.registerProcessor(new InitProcessor());
+ registry.registerProcessor(new ScopeProcessor());
+ JavaInterfaceProcessorRegistryImpl interfaceProcessorRegistry = new JavaInterfaceProcessorRegistryImpl();
+ ImplementationProcessorService service = new ImplementationProcessorServiceImpl(interfaceProcessorRegistry);
+ registry.registerProcessor(new PropertyProcessor(service));
+ registry.registerProcessor(new ReferenceProcessor(interfaceProcessorRegistry));
+ }
+
+ @Scope("MODULE")
+ private static class Foo {
+ protected Foo target;
+ protected String bar;
+
+ private boolean initialized;
+ private boolean destroyed;
+
+
+ @Init
+ public void init() {
+ if (initialized) {
+ fail();
+ }
+ initialized = true;
+ }
+
+ @Destroy
+ public void destroy() {
+ if (destroyed) {
+ fail();
+ }
+ destroyed = true;
+ }
+
+ public Foo getTarget() {
+ return target;
+ }
+
+ @Reference
+ public void setTarget(Foo target) {
+ this.target = target;
+ }
+
+ public String getBar() {
+ return bar;
+ }
+
+ @Property
+ public void setBar(String bar) {
+ this.bar = bar;
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/java/builder/JavaBuilderPropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/java/builder/JavaBuilderPropertyTestCase.java
new file mode 100644
index 0000000000..a173dda98e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/java/builder/JavaBuilderPropertyTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.integration.implementation.java.builder;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.scope.ScopeRegistryImpl;
+import org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
+import org.apache.tuscany.core.implementation.java.JavaImplementation;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies that the system builder handles configured properties correctly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBuilderPropertyTestCase extends TestCase {
+
+ private DeploymentContext deploymentContext;
+ private CompositeComponent parent;
+ private ScopeRegistry registry;
+
+ public void testPropertyHandling() throws Exception {
+ JavaComponentBuilder builder = new JavaComponentBuilder();
+ builder.setScopeRegistry(registry);
+ PojoComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>> type =
+ new PojoComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>>();
+ JavaMappedProperty<String> property = new JavaMappedProperty<String>();
+ property.setName("test");
+ property.setDefaultValueFactory(new SingletonObjectFactory<String>("foo"));
+ property.setMember(JavaBuilderPropertyTestCase.Foo.class.getMethod("setTest", String.class));
+ type.add(property);
+ type.setConstructorDefinition(new ConstructorDefinition<Foo>(Foo.class.getConstructor((Class[]) null)));
+ type.setImplementationScope(Scope.STATELESS);
+ JavaImplementation impl = new JavaImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(Foo.class);
+ ComponentDefinition<JavaImplementation> definition = new ComponentDefinition<JavaImplementation>(impl);
+ PropertyValue propertyValue = new PropertyValue(property.getName(), property.getDefaultValueFactory());
+ definition.getPropertyValues().put(property.getName(), propertyValue);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ JavaBuilderPropertyTestCase.Foo foo = (JavaBuilderPropertyTestCase.Foo) component.createInstance();
+ assertEquals("foo", foo.getTest());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ deploymentContext = new RootDeploymentContext(null, null, null, null);
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ registry = new ScopeRegistryImpl(new WorkContextImpl());
+ new StatelessScopeObjectFactory(registry);
+ }
+
+ private static class Foo {
+ private String test;
+
+ public Foo() {
+ }
+
+ public String getTest() {
+ return test;
+ }
+
+ public void setTest(String test) {
+ this.test = test;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java
new file mode 100644
index 0000000000..a7d580bbcb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.integration.implementation.system.builder;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies that the system builder handles configured properties correctly
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemBuilderPropertyTestCase extends TestCase {
+
+ DeploymentContext deploymentContext;
+ CompositeComponent parent;
+
+ @SuppressWarnings("unchecked")
+ public void testPropertyHandling() throws Exception {
+ SystemComponentBuilder builder = new SystemComponentBuilder();
+ PojoComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>> type =
+ new PojoComponentType<ServiceDefinition, ReferenceDefinition, JavaMappedProperty<?>>();
+ type.setConstructorDefinition(new ConstructorDefinition<Foo>(Foo.class.getConstructor((Class[]) null)));
+ JavaMappedProperty<String> property = new JavaMappedProperty<String>();
+ property.setName("test");
+ property.setDefaultValueFactory(new SingletonObjectFactory<String>("foo"));
+ property.setMember(Foo.class.getMethod("setTest", String.class));
+ type.add(property);
+ SystemImplementation impl = new SystemImplementation();
+ impl.setComponentType(type);
+ impl.setImplementationClass(Foo.class);
+ ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
+ AtomicComponent component = builder.build(parent, definition, deploymentContext);
+ Foo foo = (Foo) component.createInstance();
+ assertEquals("foo", foo.getTest());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ deploymentContext = new RootDeploymentContext(null, null, null, null);
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ }
+
+ private static class Foo {
+ private String test;
+
+ public Foo() {
+ }
+
+ public String getTest() {
+ return test;
+ }
+
+ public void setTest(String test) {
+ this.test = test;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
new file mode 100644
index 0000000000..761d2bb650
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.integration.implementation.system.builder;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl;
+import org.apache.tuscany.core.implementation.system.builder.SystemBindingBuilder;
+import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder;
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.mock.component.Source;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.core.mock.factories.MockComponentFactory;
+
+/**
+ * Validates that system builders and the default connector create properly wired contexts
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SystemBuilderWireTestCase extends TestCase {
+ private DeploymentContext deploymentContext;
+
+ /**
+ * Validates building a wire from an atomic context to an atomic context
+ */
+ public void testAtomicWireBuild() throws Exception {
+ WorkContext work = new WorkContextImpl();
+ ScopeContainer scope = new ModuleScopeContainer(work);
+ scope.start();
+
+ Connector connector = new ConnectorImpl();
+ SystemComponentBuilder builder = new SystemComponentBuilder();
+
+ CompositeComponent parent = new CompositeComponentImpl(null, null, connector, null);
+
+ ComponentDefinition<SystemImplementation> targetComponentDefinition = MockComponentFactory.createTarget();
+ ComponentDefinition<SystemImplementation> sourceComponentDefinition =
+ MockComponentFactory.createSourceWithTargetReference();
+
+ AtomicComponent sourceComponent = builder.build(parent, sourceComponentDefinition, deploymentContext);
+ AtomicComponent targetComponent = builder.build(parent, targetComponentDefinition, deploymentContext);
+
+ parent.register(sourceComponent);
+ parent.register(targetComponent);
+ parent.prepare();
+ parent.start();
+ scope.onEvent(new CompositeStart(this, parent));
+ Source source = (Source) parent.getSystemChild("source").getServiceInstance();
+ assertNotNull(source);
+ Target target = (Target) parent.getSystemChild("target").getServiceInstance();
+ assertNotNull(target);
+ assertSame(target, source.getTarget());
+ scope.onEvent(new CompositeStop(this, parent));
+ parent.stop();
+ scope.stop();
+ }
+
+ /**
+ * Validates building a wire from an atomic context to a reference context
+ */
+ public void testAtomicToReferenceWireBuild() throws Exception {
+ WorkContext work = new WorkContextImpl();
+ ScopeContainer scope = new ModuleScopeContainer(work);
+ scope.start();
+
+ Connector connector = new ConnectorImpl();
+ SystemComponentBuilder builder = new SystemComponentBuilder();
+ SystemBindingBuilder bindingBuilder = new SystemBindingBuilder();
+
+ CompositeComponent grandParent = new CompositeComponentImpl("grandparent", null, null, null);
+ CompositeComponent parent = new CompositeComponentImpl("parent", grandParent, null, null);
+
+ // create a context in the grandparent that the reference will be autowired to
+ ComponentDefinition<SystemImplementation> targetComponentDefinition = MockComponentFactory.createTarget();
+ AtomicComponent targetComponentComponent = builder.build(parent, targetComponentDefinition, deploymentContext);
+ grandParent.register(targetComponentComponent);
+
+ BoundReferenceDefinition<SystemBinding> targetReferenceDefinition = MockComponentFactory.createBoundReference();
+ ComponentDefinition<SystemImplementation> sourceComponentDefinition =
+ MockComponentFactory.createSourceWithTargetReference();
+
+ AtomicComponent sourceComponent = builder.build(parent, sourceComponentDefinition, deploymentContext);
+ Reference reference = bindingBuilder.build(parent, targetReferenceDefinition, deploymentContext);
+
+ parent.register(sourceComponent);
+ parent.register(reference);
+ connector.connect(reference.getInboundWire(), reference.getOutboundWire(), true);
+ connector.connect(sourceComponent);
+ grandParent.register(parent);
+ grandParent.start();
+ scope.onEvent(new CompositeStart(this, parent));
+ Source source = (Source) parent.getSystemChild("source").getServiceInstance();
+ assertNotNull(source);
+ Target target = (Target) parent.getSystemChild("target").getServiceInstance();
+ assertNotNull(target);
+ assertSame(target, source.getTarget());
+ scope.onEvent(new CompositeStop(this, parent));
+ grandParent.stop();
+ scope.stop();
+ }
+
+
+ /**
+ * Validates building a wire from a service context to an atomic context
+ */
+ public void testServiceToAtomicWireBuild() throws Exception {
+ WorkContext work = new WorkContextImpl();
+ ScopeContainer scope = new ModuleScopeContainer(work);
+ scope.start();
+
+ ConnectorImpl connector = new ConnectorImpl();
+ SystemComponentBuilder builder = new SystemComponentBuilder();
+ SystemBindingBuilder bindingBuilder = new SystemBindingBuilder();
+
+ CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);
+
+ BoundServiceDefinition<SystemBinding> serviceDefinition = MockComponentFactory.createBoundService();
+ ComponentDefinition<SystemImplementation> componentDefinition = MockComponentFactory.createTarget();
+
+ AtomicComponent sourceComponent = builder.build(parent, componentDefinition, deploymentContext);
+ parent.register(sourceComponent);
+
+ Service service = bindingBuilder.build(parent, serviceDefinition, deploymentContext);
+ parent.register(service);
+
+ connector.connect(sourceComponent);
+ connector.connect(service);
+
+ parent.start();
+ scope.onEvent(new CompositeStart(this, parent));
+ Target target = (Target) parent.getSystemChild("serviceDefinition").getServiceInstance();
+ assertNotNull(target);
+ Target target2 = (Target) parent.getSystemChild("target").getServiceInstance();
+ assertNotNull(target);
+ assertSame(target, target2);
+ scope.onEvent(new CompositeStop(this, parent));
+ parent.stop();
+ scope.stop();
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ModuleScopeContainer moduleScope = new ModuleScopeContainer();
+ moduleScope.start();
+ deploymentContext = new RootDeploymentContext(null, null, moduleScope, null);
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java
new file mode 100644
index 0000000000..7fbda2baf9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.implementation.java.JavaImplementation;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ComponentLoaderTestCase extends TestCase {
+ private static final QName COMPONENT = new QName(XML_NAMESPACE_1_0, "component");
+ private static final String NAME = "testComponent";
+ private static final Implementation IMPL = new JavaImplementation();
+
+ private XMLStreamReader mockReader;
+ private LoaderRegistry mockRegistry;
+ private PropertyObjectFactory mockPropertyFactory;
+ private ComponentLoader loader;
+
+ public void testEmptyComponent() throws LoaderException, XMLStreamException {
+ EasyMock.expect(mockReader.getName()).andReturn(COMPONENT).atLeastOnce();
+ EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.isA(String.class)))
+ .andReturn(NAME);
+ EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("initLevel")))
+ .andReturn(null);
+ EasyMock.expect(mockReader.getAttributeValue(EasyMock.isA(String.class), EasyMock.isA(String.class)))
+ .andReturn(null);
+ EasyMock.expect(mockReader.nextTag()).andReturn(0);
+ EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ EasyMock.replay(mockReader);
+ mockRegistry.loadComponentType(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Implementation.class),
+ EasyMock.isA(DeploymentContext.class));
+
+ EasyMock.expect(mockRegistry.load(EasyMock.isA(CompositeComponent.class),
+ EasyMock.eq(mockReader),
+ EasyMock.isA(DeploymentContext.class))).andReturn(IMPL);
+ EasyMock.replay(mockRegistry);
+ ComponentDefinition component = loader.load(EasyMock.createNiceMock(CompositeComponent.class),
+ mockReader,
+ EasyMock.createNiceMock(DeploymentContext.class));
+ assertEquals(NAME, component.getName());
+ assertNull(component.getInitLevel());
+ }
+
+ public void testInitValue20() throws LoaderException, XMLStreamException {
+ EasyMock.expect(mockReader.getName()).andReturn(COMPONENT).atLeastOnce();
+ EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.isA(String.class)))
+ .andReturn(NAME);
+ EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("initLevel")))
+ .andReturn("20");
+ EasyMock.expect(mockReader.nextTag()).andReturn(0);
+ EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ EasyMock.replay(mockReader);
+
+ mockRegistry.loadComponentType(EasyMock.isA(CompositeComponent.class),
+ EasyMock.isA(Implementation.class),
+ EasyMock.isA(DeploymentContext.class));
+ EasyMock.expect(mockRegistry.load(EasyMock.isA(CompositeComponent.class),
+ EasyMock.eq(mockReader),
+ EasyMock.isA(DeploymentContext.class))).andReturn(IMPL);
+ EasyMock.replay(mockRegistry);
+ ComponentDefinition component = loader.load(EasyMock.createNiceMock(CompositeComponent.class),
+ mockReader,
+ EasyMock.createNiceMock(DeploymentContext.class));
+ assertEquals(NAME, component.getName());
+ assertEquals(Integer.valueOf(20), component.getInitLevel());
+ }
+
+ public void testLoadPropertyWithSource() throws LoaderException, XMLStreamException {
+ PojoComponentType<?, ?, Property<?>> type =
+ new PojoComponentType<ServiceDefinition, ReferenceDefinition, Property<?>>();
+ Property property = new Property();
+ property.setName("name");
+ type.add(property);
+ JavaImplementation impl = new JavaImplementation();
+ impl.setComponentType(type);
+ ComponentDefinition<?> defn = new ComponentDefinition<JavaImplementation>(impl);
+ XMLStreamReader reader = createMock(XMLStreamReader.class);
+ expect(reader.getAttributeValue(null, "name")).andReturn("name");
+ expect(reader.getAttributeValue(null, "source")).andReturn("$source");
+ expect(reader.getAttributeValue(null, "file")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ replay(reader);
+ loader.loadProperty(reader, null, defn);
+ assertEquals("$source", defn.getPropertyValues().get("name").getSource());
+ EasyMock.verify(reader);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mockReader = EasyMock.createMock(XMLStreamReader.class);
+ mockRegistry = EasyMock.createMock(LoaderRegistry.class);
+ mockPropertyFactory = EasyMock.createMock(PropertyObjectFactory.class);
+ loader = new ComponentLoader(mockRegistry, mockPropertyFactory);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java
new file mode 100644
index 0000000000..38f1122004
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.net.URL;
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.osoa.sca.Version;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingIncludeException;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Include;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IncludeLoaderTestCase extends TestCase {
+ private static final QName INCLUDE = new QName(Version.XML_NAMESPACE_1_0, "include");
+
+ private LoaderRegistry registry;
+ private IncludeLoader loader;
+ private XMLStreamReader reader;
+ private DeploymentContext context;
+ private URL base;
+ private URL includeURL;
+ private ClassLoader cl;
+
+ public void testNoLocation() throws LoaderException, XMLStreamException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(INCLUDE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null);
+ expect(reader.getAttributeValue(null, "scdlResource")).andReturn(null);
+ expect(reader.next()).andReturn(END_ELEMENT);
+
+ expect(context.getClassLoader()).andReturn(cl);
+ replay(registry, reader, context);
+
+ try {
+ loader.load(null, reader, context);
+ fail();
+ } catch (MissingIncludeException e) {
+ // OK expected
+ }
+ verify(registry, reader, context);
+ }
+
+ public void testWithAbsoluteScdlLocation() throws LoaderException, XMLStreamException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(INCLUDE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("http://example.com/include.scdl");
+ expect(reader.getAttributeValue(null, "scdlResource")).andReturn(null);
+ expect(reader.next()).andReturn(END_ELEMENT);
+
+ expect(context.getScdlLocation()).andReturn(base);
+ expect(context.getClassLoader()).andReturn(cl);
+
+ expect(registry.load((CompositeComponent) isNull(),
+ eq(includeURL),
+ eq(CompositeComponentType.class),
+ isA(DeploymentContext.class)))
+ .andReturn(null);
+ replay(registry, reader, context);
+
+ Include include = loader.load(null, reader, context);
+ assertEquals(name, include.getName());
+ assertEquals(includeURL, include.getScdlLocation());
+ verify(registry, reader, context);
+ }
+
+ public void testWithRelativeScdlLocation() throws LoaderException, XMLStreamException {
+ String name = "foo";
+ expect(reader.getName()).andReturn(INCLUDE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("include.scdl");
+ expect(reader.getAttributeValue(null, "scdlResource")).andReturn(null);
+ expect(reader.next()).andReturn(END_ELEMENT);
+
+ expect(context.getScdlLocation()).andReturn(base);
+ expect(context.getClassLoader()).andReturn(cl);
+
+ expect(registry.load((CompositeComponent) isNull(),
+ eq(includeURL),
+ eq(CompositeComponentType.class),
+ isA(DeploymentContext.class)))
+ .andReturn(null);
+ replay(registry, reader, context);
+
+ Include include = loader.load(null, reader, context);
+ assertEquals(name, include.getName());
+ assertEquals(includeURL, include.getScdlLocation());
+ verify(registry, reader, context);
+ }
+
+ public void testWithScdlResource() throws LoaderException, XMLStreamException {
+ String name = "foo";
+ String resource = "org/apache/tuscany/core/loader/test-include.scdl";
+ includeURL = cl.getResource(resource);
+ assertNotNull(includeURL);
+
+ expect(reader.getName()).andReturn(INCLUDE);
+ expect(reader.getAttributeValue(null, "name")).andReturn(name);
+ expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null);
+ expect(reader.getAttributeValue(null, "scdlResource")).andReturn(resource);
+ expect(reader.next()).andReturn(END_ELEMENT);
+
+ expect(context.getClassLoader()).andReturn(cl);
+
+ expect(registry.load((CompositeComponent) isNull(),
+ eq(includeURL),
+ eq(CompositeComponentType.class),
+ isA(DeploymentContext.class)))
+ .andReturn(null);
+ replay(registry, reader, context);
+
+ Include include = loader.load(null, reader, context);
+ assertEquals(name, include.getName());
+ assertEquals(includeURL, include.getScdlLocation());
+ verify(registry, reader, context);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ reader = createMock(XMLStreamReader.class);
+ context = createMock(DeploymentContext.class);
+ cl = getClass().getClassLoader();
+ base = new URL("http://example.com/test.scdl");
+ includeURL = new URL("http://example.com/include.scdl");
+ loader = new IncludeLoader(registry);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java
new file mode 100644
index 0000000000..fb5bfd32d3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.lang.reflect.Type;
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.tuscany.spi.model.PropertyValue;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.injection.JNDIObjectFactory;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JNDIPropertyFactoryTestCase extends TestCase {
+
+ public void testCreate() throws Exception {
+ String old = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+ try {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, MockInitialContextFactory.class.getName());
+ JNDIPropertyFactory factory = new JNDIPropertyFactory();
+ Element element = EasyMock.createMock(Element.class);
+ EasyMock.expect(element.getTextContent()).andReturn("foo");
+ EasyMock.replay(element);
+ Document doc = EasyMock.createMock(Document.class);
+ EasyMock.expect(doc.getDocumentElement()).andReturn(element);
+ EasyMock.replay(doc);
+ PropertyValue<?> value = new MockPropertyValue<Type>();
+ value.setValue(doc);
+ JNDIObjectFactory<?> jndiFactory = (JNDIObjectFactory<?>) factory.createObjectFactory(null, value);
+ assertEquals("bar", jndiFactory.getInstance());
+ } finally {
+ System.clearProperty(Context.INITIAL_CONTEXT_FACTORY);
+ if (old != null) {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old);
+ }
+ }
+
+ }
+
+ private class MockPropertyValue<T> extends PropertyValue<T> {
+
+ }
+
+ public static class MockInitialContextFactory implements InitialContextFactory {
+ public MockInitialContextFactory() {
+ }
+
+ public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
+ Context context = EasyMock.createMock(Context.class);
+ EasyMock.expect(context.lookup("foo")).andReturn("bar");
+ EasyMock.replay(context);
+ return context;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java
new file mode 100644
index 0000000000..080bc25039
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import java.io.StringReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import junit.framework.TestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PropertyParsingTestCase extends TestCase {
+ private XMLInputFactory xmlFactory;
+ private DocumentBuilder docBuilder;
+ private Element root;
+
+ public void testComplexProperty() throws XMLStreamException {
+ String xml = "<property xmlns:foo='http://foo.com'>"
+ + "<foo:a>aValue</foo:a>"
+ + "<foo:b>InterestingURI</foo:b>"
+ + "</property>";
+
+ XMLStreamReader reader = getReader(xml);
+ StAXUtil.loadPropertyValue(reader, root);
+ NodeList childNodes = root.getChildNodes();
+ assertEquals(2, childNodes.getLength());
+
+ Element e = (Element) childNodes.item(0);
+ assertEquals("http://foo.com", e.getNamespaceURI());
+ assertEquals("a", e.getLocalName());
+ assertEquals("aValue", e.getTextContent());
+ e = (Element) childNodes.item(1);
+ assertEquals("http://foo.com", e.getNamespaceURI());
+ assertEquals("b", e.getLocalName());
+ assertEquals("InterestingURI", e.getTextContent());
+ }
+
+ public XMLStreamReader getReader(String xml) throws XMLStreamException {
+ XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(xml));
+ reader.next();
+ return reader;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ xmlFactory = XMLInputFactory.newInstance();
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docBuilder = docFactory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+ root = doc.createElement("value");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
new file mode 100644
index 0000000000..bcf153290a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * Verifies loading of a service definition from an XML-based assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceLoaderTestCase extends TestCase {
+ private static final QName SERVICE = new QName(XML_NAMESPACE_1_0, "service");
+ private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference");
+ private static final QName INTERFACE_JAVA = new QName(XML_NAMESPACE_1_0, "interface.java");
+
+ private ServiceLoader loader;
+ private DeploymentContext deploymentContext;
+ private XMLStreamReader mockReader;
+ private LoaderRegistry mockRegistry;
+
+ public void testWithNoInterface() throws LoaderException, XMLStreamException {
+ String name = "serviceDefinition";
+// String target = "target";
+ expect(mockReader.getName()).andReturn(SERVICE).anyTimes();
+ expect(mockReader.getAttributeValue(null, "name")).andReturn(name);
+ expect(mockReader.next()).andReturn(END_ELEMENT);
+ expect(mockReader.getName()).andReturn(SERVICE).anyTimes();
+ replay(mockReader);
+ ServiceDefinition serviceDefinition = loader.load(null, mockReader, null);
+ assertNotNull(serviceDefinition);
+ assertEquals(name, serviceDefinition.getName());
+ }
+
+ public void testWithInterface() throws LoaderException, XMLStreamException {
+ String name = "serviceDefinition";
+ String target = "target";
+ ServiceContract sc = new ServiceContract() {
+ };
+ expect(mockReader.getName()).andReturn(SERVICE).anyTimes();
+ expect(mockReader.getAttributeValue(null, "name")).andReturn(name);
+ expect(mockReader.next()).andReturn(START_ELEMENT);
+ expect(mockReader.getName()).andReturn(INTERFACE_JAVA);
+ expect(mockRegistry.load(null, mockReader, deploymentContext)).andReturn(sc);
+ expect(mockReader.next()).andReturn(START_ELEMENT);
+ expect(mockReader.getName()).andReturn(REFERENCE);
+ expect(mockReader.getElementText()).andReturn(target);
+ expect(mockReader.next()).andReturn(END_ELEMENT);
+ expect(mockReader.getName()).andReturn(REFERENCE);
+ expect(mockReader.next()).andReturn(END_ELEMENT);
+ expect(mockReader.getName()).andReturn(SERVICE);
+
+ replay(mockReader);
+ replay(mockRegistry);
+
+ ServiceDefinition serviceDefinition = loader.load(null, mockReader, deploymentContext);
+ assertNotNull(serviceDefinition);
+ assertEquals(name, serviceDefinition.getName());
+ assertSame(sc, serviceDefinition.getServiceContract());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mockReader = EasyMock.createStrictMock(XMLStreamReader.class);
+ mockRegistry = EasyMock.createMock(LoaderRegistry.class);
+ loader = new ServiceLoader(mockRegistry);
+ deploymentContext = new RootDeploymentContext(null, null, null, null);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
new file mode 100644
index 0000000000..0d7c47774e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.StAXElementLoader;
+import org.apache.tuscany.spi.loader.UnrecognizedElementException;
+import org.apache.tuscany.spi.model.ModelObject;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * Verifies the default loader registry
+ *
+ * @version $Rev$ $Date$
+ */
+public class StAXLoaderRegistryImplTestCase extends TestCase {
+ private LoaderRegistryImpl registry;
+ private QName name;
+ private LoaderRegistryImpl.Monitor mockMonitor;
+ private StAXElementLoader<ModelObject> mockLoader;
+ private XMLStreamReader mockReader;
+ private DeploymentContext deploymentContext;
+ private ModelObject modelObject;
+
+ public void testLoaderRegistration() {
+ mockMonitor.registeringLoader(EasyMock.eq(name));
+ EasyMock.replay(mockMonitor);
+ registry.registerLoader(name, mockLoader);
+ EasyMock.verify(mockMonitor);
+ }
+
+ public void testLoaderUnregistration() {
+ mockMonitor.unregisteringLoader(EasyMock.eq(name));
+ EasyMock.replay(mockMonitor);
+ registry.unregisterLoader(name, (StAXElementLoader<ModelObject>) mockLoader);
+ EasyMock.verify(mockMonitor);
+ }
+
+ public void testSuccessfulDispatch() throws LoaderException, XMLStreamException {
+ EasyMock.expect(mockReader.getName()).andReturn(name);
+ EasyMock.replay(mockReader);
+ mockMonitor.registeringLoader(EasyMock.eq(name));
+ mockMonitor.elementLoad(EasyMock.eq(name));
+ EasyMock.replay(mockMonitor);
+ EasyMock.expect(mockLoader.load(EasyMock.isA(CompositeComponent.class),
+ EasyMock.eq(mockReader),
+ EasyMock.eq(deploymentContext))).andReturn(modelObject);
+ EasyMock.replay(mockLoader);
+ registry.registerLoader(name, (StAXElementLoader<ModelObject>) mockLoader);
+ CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
+ assertSame(modelObject, registry.load(parent, mockReader, deploymentContext));
+ EasyMock.verify(mockLoader);
+ EasyMock.verify(mockMonitor);
+ EasyMock.verify(mockReader);
+
+ }
+
+ public void testUnsuccessfulDispatch() throws LoaderException, XMLStreamException {
+ EasyMock.expect(mockReader.getName()).andReturn(name);
+ EasyMock.replay(mockReader);
+ mockMonitor.elementLoad(EasyMock.eq(name));
+ EasyMock.replay(mockMonitor);
+ try {
+ registry.load(null, mockReader, deploymentContext);
+ fail();
+ } catch (UnrecognizedElementException e) {
+ assertSame(name, e.getElement());
+ }
+ EasyMock.verify(mockReader);
+ EasyMock.verify(mockMonitor);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ name = new QName("http://mock", "test");
+ deploymentContext = new RootDeploymentContext(null, null, null, null);
+ registry = new LoaderRegistryImpl();
+ mockMonitor = EasyMock.createMock(LoaderRegistryImpl.Monitor.class);
+ registry.setMonitor(mockMonitor);
+
+ mockLoader = EasyMock.createMock(StAXElementLoader.class);
+ mockReader = EasyMock.createMock(XMLStreamReader.class);
+ modelObject = new ModelObject() {
+ };
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java
new file mode 100644
index 0000000000..4445dfad2c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.loader;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StringParserPropertyFactoryTestCase extends TestCase {
+
+ private <T> PropertyValue<T> mock(String value) {
+ Document document = EasyMock.createMock(Document.class);
+ Element element = EasyMock.createMock(Element.class);
+ EasyMock.expect(document.getDocumentElement()).andReturn(element);
+ EasyMock.expect(element.getTextContent()).andReturn(value);
+ EasyMock.replay(document, element);
+ return new PropertyValue<T>(null, document);
+ }
+
+ public void testInteger() throws Exception {
+
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<Integer> property = new Property<Integer>();
+ property.setJavaType(Integer.class);
+ PropertyValue<Integer> propertyValue = mock("1");
+ ObjectFactory<Integer> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals(1, oFactory.getInstance().intValue());
+ }
+
+ public void testPrimitiveInt() throws Exception {
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<Integer> property = new Property<Integer>();
+ property.setJavaType(Integer.TYPE);
+ PropertyValue<Integer> propertyValue = mock("1");
+ ObjectFactory<Integer> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals(1, oFactory.getInstance().intValue());
+ }
+
+ public void testString() throws Exception {
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<String> property = new Property<String>();
+ property.setJavaType(String.class);
+ PropertyValue<String> propertyValue = mock("1");
+ ObjectFactory<String> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals("1", oFactory.getInstance());
+ }
+
+ public void testByteArray() throws Exception {
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<byte[]> property = new Property<byte[]>();
+ property.setJavaType(byte[].class);
+ PropertyValue<byte[]> propertyValue = mock("1");
+ ObjectFactory<byte[]> oFactory = factory.createObjectFactory(property, propertyValue);
+ byte[] result = oFactory.getInstance();
+ byte[] expected = "1".getBytes();
+ for (int i = 0; i < result.length; i++) {
+ byte b = result[i];
+ if (b != expected[i]) {
+ fail();
+ }
+ }
+ }
+
+ public void testBoolean() throws Exception {
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<Boolean> property = new Property<Boolean>();
+ property.setJavaType(Boolean.class);
+ PropertyValue<Boolean> propertyValue = mock("true");
+ ObjectFactory<Boolean> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertTrue(oFactory.getInstance());
+ }
+
+ public void testPrimitiveBoolean() throws Exception {
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<Boolean> property = new Property<Boolean>();
+ property.setJavaType(Boolean.TYPE);
+ PropertyValue<Boolean> propertyValue = mock("true");
+ ObjectFactory<Boolean> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertTrue(oFactory.getInstance());
+ }
+
+ public void testStringConstructor() throws Exception {
+ StringParserPropertyFactory factory = new StringParserPropertyFactory();
+ Property<Foo> property = new Property<Foo>();
+ property.setJavaType(Foo.class);
+ PropertyValue<Foo> propertyValue = mock("test");
+ ObjectFactory<Foo> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals("test", oFactory.getInstance().getFoo());
+ }
+
+ private static class Foo {
+ private String foo;
+
+ public Foo(String foo) {
+ this.foo = foo;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java
new file mode 100644
index 0000000000..214378b2c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Context;
+
+public class BadContextPojo {
+
+ @Context
+ String moduleContext;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java
new file mode 100644
index 0000000000..77ec37f9e4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.ComponentName;
+
+public class BadNamePojo {
+ @ComponentName
+ private int name;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java
new file mode 100644
index 0000000000..b7921c248f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface BasicInterface {
+ String returnsProperty();
+
+ BasicInterface returnsReference();
+
+ int returnsInt();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java
new file mode 100644
index 0000000000..c2ca45ec17
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicInterfaceImpl implements BasicInterface {
+
+ @Property
+ public String publicProperty;
+ @Reference
+ public BasicInterface publicReference;
+ @Property
+ protected String protectedProperty;
+ @Reference
+ protected BasicInterface protectedReference;
+ private String privateProperty;
+ private BasicInterface privateReference;
+
+ @Property
+ public void setPrivateProperty(String privateProperty) {
+ this.privateProperty = privateProperty;
+ }
+
+ @Reference
+ public void setPrivateReference(BasicInterface privateReference) {
+ this.privateReference = privateReference;
+ }
+
+ public String returnsProperty() {
+ return privateProperty;
+ }
+
+ public BasicInterface returnsReference() {
+ return privateReference;
+ }
+
+ public int returnsInt() {
+ return 0;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponent.java
new file mode 100644
index 0000000000..5b63caf286
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponent.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public interface ModuleScopeComponent {
+
+ //public boolean isInit();
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponentImpl.java
new file mode 100644
index 0000000000..5febc32ce6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeComponentImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class ModuleScopeComponentImpl implements
+ ModuleScopeComponent {
+
+ private String foo;
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..886f3586f8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeDestroyOnlyComponent.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeDestroyOnlyComponent extends ModuleScopeComponentImpl {
+
+ boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitComponent.java
new file mode 100644
index 0000000000..a4cf75e8cb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitComponent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Init;
+
+public class ModuleScopeEagerInitComponent extends ModuleScopeComponentImpl {
+
+ boolean initialized;
+ // this value tests to ensure introspection can find the init() method even
+ // if a field is named the same. Ultimately, this should be in the
+ // introspection tests
+ private boolean init;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ initialized = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitDestroyComponent.java
new file mode 100644
index 0000000000..4cb219958d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeEagerInitDestroyComponent.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeEagerInitDestroyComponent extends ModuleScopeEagerInitComponent {
+
+ boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..323ebc636f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitDestroyComponent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeInitDestroyComponent extends ModuleScopeInitOnlyComponent {
+
+ boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ if (destroyed) {
+ throw new AssertionError("Destroy called more than once");
+ }
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..723ee18fac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeInitOnlyComponent.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Init;
+
+public class ModuleScopeInitOnlyComponent extends ModuleScopeComponentImpl {
+
+ private boolean initialized;
+ // this value tests to ensure introspection can find the init() method even
+ // if a field is named the same. Ultimately, this should be in the introspection tests
+ private boolean init;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ if (initialized) {
+ throw new AssertionError("Init called more than once");
+ }
+ initialized = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java
new file mode 100644
index 0000000000..af257c226d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+public class OrderException extends Exception {
+
+ public OrderException() {
+ super();
+ }
+
+ public OrderException(String message) {
+ super(message);
+ }
+
+ public OrderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OrderException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java
new file mode 100644
index 0000000000..2033f0eca5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OrderedDependentPojo extends OrderedInitPojo {
+
+ OrderedInitPojo getPojo();
+
+ void setPojo(OrderedInitPojo pojo);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java
new file mode 100644
index 0000000000..439c3d143c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class OrderedDependentPojoImpl extends OrderedInitPojoImpl implements OrderedDependentPojo {
+
+ private OrderedInitPojo pojo;
+
+ public OrderedInitPojo getPojo() {
+ return pojo;
+ }
+
+ public void setPojo(OrderedInitPojo pojo) {
+ this.pojo = pojo;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java
new file mode 100644
index 0000000000..815d9d6b12
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class OrderedEagerInitPojo {
+
+ private static final Object LOCK = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init(eager = true)
+ public void init() {
+ synchronized (LOCK) {
+ ++numberInstantied;
+ initOrder = numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (LOCK) {
+ if (initOrder != numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java
new file mode 100644
index 0000000000..0b891cfa42
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OrderedInitPojo {
+ int getNumberInstantiated();
+
+ int getInitOrder();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java
new file mode 100644
index 0000000000..53338f5613
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class OrderedInitPojoImpl implements OrderedInitPojo {
+
+ private static final Object LOCK = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init
+ public void init() {
+ synchronized (LOCK) {
+ ++numberInstantied;
+ initOrder = numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (LOCK) {
+ if (initOrder != numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java
new file mode 100644
index 0000000000..8c7dc107ee
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("REQUEST")
+public interface RequestScopeComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..5224ceda5f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("REQUEST")
+public class RequestScopeDestroyOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..38b188a4b5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("REQUEST")
+public class RequestScopeInitDestroyComponent extends SessionScopeInitOnlyComponent {
+
+ boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..707f8ab50f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("REQUEST")
+public class RequestScopeInitOnlyComponent extends SessionScopeComponentImpl {
+
+ private boolean initialized;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java
new file mode 100644
index 0000000000..827ba804f2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public interface SessionScopeComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java
new file mode 100644
index 0000000000..e547bf6113
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public class SessionScopeComponentImpl implements
+ SessionScopeComponent {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..c11bd1bd49
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class SessionScopeInitDestroyComponent extends SessionScopeInitOnlyComponent {
+
+ private boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..095cc916ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Init;
+
+public class SessionScopeInitOnlyComponent extends SessionScopeComponentImpl {
+
+ private boolean initialized;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java
new file mode 100644
index 0000000000..c78ba00a7a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+public interface SimpleTarget {
+
+ String hello(String message) throws Exception;
+
+ String goodbye(String message) throws Exception;
+
+ String echo(String message) throws Exception;
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java
new file mode 100644
index 0000000000..634a07a401
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+public class SimpleTargetImpl implements SimpleTarget {
+
+ public SimpleTargetImpl() {
+ super();
+ }
+
+ public String hello(String message) throws Exception {
+ return message;
+ }
+
+ public String goodbye(String message) throws Exception {
+ return message;
+ }
+
+ public String echo(String message) throws Exception {
+ return message;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java
new file mode 100644
index 0000000000..f7969f748b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import java.util.List;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Source {
+
+ Target getTarget();
+
+ List<Target> getTargets();
+
+ List<Target> getTargetsThroughField();
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java
new file mode 100644
index 0000000000..187e33b2bd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import java.util.List;
+
+/**
+ * Mock system component implementation used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public class SourceImpl implements Source {
+
+ private Target target;
+ private List<Target> targets;
+ private List<Target> targetsThroughField;
+ private Target[] targetsArray;
+
+ public void setTarget(Target target) {
+ this.target = target;
+ }
+
+ public Target getTarget() {
+ return target;
+ }
+
+ public List<Target> getTargets() {
+ return targets;
+ }
+
+ public void setTargets(List<Target> targets) {
+ this.targets = targets;
+ }
+
+ public List<Target> getTargetsThroughField() {
+ return targetsThroughField;
+ }
+
+ public Target[] getArrayOfTargets() {
+ return targetsArray;
+ }
+
+ public void setArrayOfTargets(Target[] targets) {
+ targetsArray = targets;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java
new file mode 100644
index 0000000000..c16ac942a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("STATELESS")
+public interface StatelessComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java
new file mode 100644
index 0000000000..64a23c12c8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessComponentImpl implements
+ StatelessComponent {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java
new file mode 100644
index 0000000000..778c14665d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Target {
+
+ String getString();
+
+ void setString(String val);
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java
new file mode 100644
index 0000000000..037dd3a37c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.component;
+
+/**
+ * Mock system component implementation used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetImpl implements Target {
+
+ private String theString;
+
+ public String getString() {
+ return theString;
+ }
+
+ public void setString(String val) {
+ theString = val;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockComponentFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockComponentFactory.java
new file mode 100644
index 0000000000..e6f1611d40
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockComponentFactory.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.factories;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.model.SystemImplementation;
+import org.apache.tuscany.core.mock.component.SourceImpl;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.core.mock.component.TargetImpl;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public final class MockComponentFactory {
+
+ private MockComponentFactory() {
+ }
+
+ /**
+ * Creates a component named "source" with a reference to target/Target
+ */
+ public static ComponentDefinition<SystemImplementation> createSourceWithTargetReference()
+ throws NoSuchMethodException {
+ SystemImplementation impl = new SystemImplementation();
+ PojoComponentType componentType = new PojoComponentType();
+ componentType.setImplementationScope(Scope.MODULE);
+ componentType
+ .setConstructorDefinition(
+ new ConstructorDefinition<SourceImpl>(SourceImpl.class.getConstructor((Class[]) null)));
+ JavaMappedReference reference;
+ try {
+ reference = new JavaMappedReference();
+ reference.setName("target");
+ reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
+ JavaServiceContract contract = new JavaServiceContract();
+ contract.setInterfaceClass(Target.class);
+ reference.setServiceContract(contract);
+ componentType.add(reference);
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError(e);
+ }
+ impl.setComponentType(componentType);
+ impl.setImplementationClass(SourceImpl.class);
+ ComponentDefinition<SystemImplementation> sourceComponentDefinition =
+ new ComponentDefinition<SystemImplementation>(impl);
+ sourceComponentDefinition.setName("source");
+
+ ReferenceTarget referenceTarget = new ReferenceTarget();
+ referenceTarget.setReferenceName("target");
+ try {
+ referenceTarget.addTarget(new URI("target/Target"));
+ } catch (URISyntaxException e) {
+ throw new AssertionError(e);
+ }
+ sourceComponentDefinition.add(referenceTarget);
+ return sourceComponentDefinition;
+ }
+
+ /**
+ * Creates a component named "source" with an autowire reference to {@link Target}
+ */
+ public static ComponentDefinition<SystemImplementation> createSourceWithTargetAutowire() {
+ SystemImplementation impl = new SystemImplementation();
+ PojoComponentType componentType = new PojoComponentType();
+ componentType.setImplementationScope(Scope.MODULE);
+ JavaMappedReference reference;
+ try {
+ reference = new JavaMappedReference();
+ reference.setName("target");
+ reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
+ reference.setAutowire(true);
+ ServiceContract<?> contract = new JavaServiceContract();
+ contract.setInterfaceClass(Target.class);
+ reference.setServiceContract(contract);
+ componentType.add(reference);
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError(e);
+ }
+ impl.setComponentType(componentType);
+ impl.setImplementationClass(SourceImpl.class);
+ ComponentDefinition<SystemImplementation> sourceComponentDefinition =
+ new ComponentDefinition<SystemImplementation>(impl);
+ sourceComponentDefinition.setName("source");
+
+ ReferenceTarget referenceTarget = new ReferenceTarget();
+ referenceTarget.setReferenceName("target");
+ sourceComponentDefinition.add(referenceTarget);
+ return sourceComponentDefinition;
+ }
+
+ /**
+ * Creates a component named "target" with a service named "Target"
+ */
+ public static ComponentDefinition<SystemImplementation> createTarget() throws NoSuchMethodException {
+ SystemImplementation impl = new SystemImplementation();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ componentType.setImplementationScope(Scope.MODULE);
+ componentType
+ .setConstructorDefinition(
+ new ConstructorDefinition<TargetImpl>(TargetImpl.class.getConstructor((Class[]) null)));
+ JavaMappedService targetServiceDefinition = new JavaMappedService();
+ targetServiceDefinition.setName("Target");
+ ServiceContract<?> contract = new JavaServiceContract();
+ contract.setInterfaceClass(Target.class);
+ targetServiceDefinition.setServiceContract(contract);
+ componentType.add(targetServiceDefinition);
+ impl.setComponentType(componentType);
+ impl.setImplementationClass(TargetImpl.class);
+ ComponentDefinition<SystemImplementation> targetComponentDefinition =
+ new ComponentDefinition<SystemImplementation>(impl);
+ targetComponentDefinition.setName("target");
+ return targetComponentDefinition;
+ }
+
+
+ public static BoundReferenceDefinition<SystemBinding> createBoundReference() {
+ SystemBinding binding = new SystemBinding();
+ BoundReferenceDefinition<SystemBinding> referenceDefinition = new BoundReferenceDefinition<SystemBinding>();
+ referenceDefinition.setBinding(binding);
+ referenceDefinition.setName("target");
+ ServiceContract<?> contract = new JavaServiceContract();
+ contract.setInterfaceClass(Target.class);
+ referenceDefinition.setServiceContract(contract);
+ return referenceDefinition;
+ }
+
+ /**
+ * Creates a bound service with the name "service" that is configured to be wired to a target named "target/Target"
+ */
+ public static BoundServiceDefinition<SystemBinding> createBoundService() {
+ SystemBinding binding = new SystemBinding();
+ BoundServiceDefinition<SystemBinding> serviceDefinition = new BoundServiceDefinition<SystemBinding>();
+ serviceDefinition.setBinding(binding);
+ serviceDefinition.setName("serviceDefinition");
+ ServiceContract<?> contract = new JavaServiceContract();
+ contract.setInterfaceClass(Target.class);
+ serviceDefinition.setServiceContract(contract);
+ try {
+ serviceDefinition.setTarget(new URI("target/Target"));
+ } catch (URISyntaxException e) {
+ throw new AssertionError(e);
+ }
+ return serviceDefinition;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockFactory.java
new file mode 100644
index 0000000000..c06633c4f7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/factories/MockFactory.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.factories;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.implementation.system.wire.SystemInboundWireImpl;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWire;
+import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWireImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public final class MockFactory {
+
+ private MockFactory() {
+ }
+
+ public static Map<String, AtomicComponent> createWiredComponents(String source,
+ Class<?> sourceClass,
+ ScopeContainer sourceScopeContainer,
+ String target,
+ Class<?> targetClass,
+ ScopeContainer targetScopeContainer)
+ throws NoSuchMethodException {
+ List<Class<?>> sourceClasses = new ArrayList<Class<?>>();
+ sourceClasses.add(sourceClass);
+ return createWiredComponents(source, sourceClasses, sourceClass, sourceScopeContainer, target, targetClass,
+ targetScopeContainer);
+ }
+
+ /**
+ * Creates source and target {@link AtomicComponent}s whose instances are wired together. The wiring algorithm
+ * searches for the first method on the source with a single parameter type matching an interface implemented by the
+ * target.
+ *
+ * @throws NoSuchMethodException
+ */
+ @SuppressWarnings("unchecked")
+ public static Map<String, AtomicComponent> createWiredComponents(String source,
+ List<Class<?>> sourceInterfaces,
+ Class<?> sourceClass,
+ ScopeContainer sourceScopeContainer,
+ String target,
+ Class<?> targetClass,
+ ScopeContainer targetScopeContainer)
+ throws NoSuchMethodException {
+
+ Map<String, AtomicComponent> contexts = new HashMap<String, AtomicComponent>();
+ SystemAtomicComponent targetComponent = createAtomicComponent(target, targetScopeContainer, targetClass);
+ PojoConfiguration sourceConfig = new PojoConfiguration();
+ sourceConfig.getServiceInterfaces().addAll(sourceInterfaces);
+ sourceConfig.setScopeContainer(sourceScopeContainer);
+ sourceConfig.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+
+ //create target wire
+ Method[] sourceMethods = sourceClass.getMethods();
+ Class[] interfaces = targetClass.getInterfaces();
+ Method setter = null;
+ for (Class interfaze : interfaces) {
+ for (Method method : sourceMethods) {
+ if (method.getParameterTypes().length == 1) {
+ if (interfaze.isAssignableFrom(method.getParameterTypes()[0])) {
+ setter = method;
+ }
+ }
+ Init init;
+ if ((init = method.getAnnotation(Init.class)) != null) {
+ sourceConfig.setInitLevel(init.eager() ? 50 : 0);
+ sourceConfig.setInitInvoker(new MethodEventInvoker<Object>(method));
+
+ } else if (method.getAnnotation(Destroy.class) != null) {
+ sourceConfig.setDestroyInvoker(new MethodEventInvoker<Object>(method));
+ }
+ }
+
+ }
+ if (setter == null) {
+ throw new IllegalArgumentException("No setter found on source for target");
+ }
+
+ sourceConfig.addReferenceSite(setter.getName(), setter);
+ SystemAtomicComponent sourceCtx = new SystemAtomicComponentImpl(source, sourceConfig);
+ QualifiedName targetName = new QualifiedName(target);
+ SystemOutboundWire wire = new SystemOutboundWireImpl(setter.getName(), targetName, targetClass);
+ InboundWire inboundWire = new SystemInboundWireImpl(targetName.getPortName(), targetClass, targetComponent);
+ wire.setTargetWire(inboundWire);
+
+ sourceCtx.addOutboundWire(wire);
+ contexts.put(source, sourceCtx);
+ contexts.put(target, targetComponent);
+ return contexts;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static SystemAtomicComponent createAtomicComponent(String name, ScopeContainer container, Class<?> clazz)
+ throws NoSuchMethodException {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(container);
+ configuration.addServiceInterface(clazz);
+ configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor()));
+ Method[] methods = clazz.getMethods();
+ for (Method method : methods) {
+ Init init;
+ if ((init = method.getAnnotation(Init.class)) != null) {
+ configuration.setInitLevel(init.eager() ? 50 : 0);
+ configuration.setInitInvoker(new MethodEventInvoker<Object>(method));
+
+ } else if (method.getAnnotation(Destroy.class) != null) {
+ configuration.setDestroyInvoker(new MethodEventInvoker<Object>(method));
+ }
+ }
+ return new SystemAtomicComponentImpl(name, configuration);
+ }
+
+ public static <T> InboundWire createTargetWireFactory(String serviceName, Class<T> interfaze)
+ throws InvalidServiceContractException {
+ InboundWire wire = new InboundWireImpl();
+ wire.setServiceName(serviceName);
+ JavaServiceContract contract = new JavaServiceContract(interfaze);
+ wire.setServiceContract(contract);
+ wire.addInvocationChains(createInboundChains(interfaze));
+ return wire;
+ }
+
+ public static Map<Operation<?>, InboundInvocationChain> createInboundChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ Map<Operation<?>, InboundInvocationChain> invocations = new HashMap<Operation<?>, InboundInvocationChain>();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+
+ for (Operation<?> operation : contract.getOperations().values()) {
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ // add tail interceptor
+ chain.addInterceptor(new InvokerInterceptor());
+ invocations.put(operation, chain);
+ }
+ return invocations;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java
new file mode 100644
index 0000000000..85afda9b08
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.wire;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Caches component instances that do not need to be resolved for every wire, e.g. an wire originating from a lesser
+ * scope intended for a target with a wider scope
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockStaticInvoker implements TargetInvoker {
+
+ private Object instance;
+ private Method operation;
+ private boolean cacheable;
+
+
+ public MockStaticInvoker(Method operation, Object instance) {
+ this.operation = operation;
+ this.instance = instance;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable();
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ if (payload != null && !payload.getClass().isArray()) {
+ return operation.invoke(instance, payload);
+ } else {
+ return operation.invoke(instance, (Object[]) payload);
+ }
+ } catch (IllegalAccessException e) {
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last interceptor in an interceptor chain");
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ MockStaticInvoker invoker = (MockStaticInvoker) super.clone();
+ invoker.instance = this.instance;
+ invoker.operation = this.operation;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java
new file mode 100644
index 0000000000..1fe2c027ab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.wire;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Interceptor next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next = next;
+ }
+
+ public Interceptor getNext() {
+ return next;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java
new file mode 100644
index 0000000000..ee452d34fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.monitor;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.api.annotation.LogLevel;
+import org.apache.tuscany.host.MonitorFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for the JavaLoggingMonitorFactory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaLoggingTestCase extends TestCase {
+ private static final Logger LOGGER = Logger.getLogger(Monitor.class.getName());
+ private static final MockHandler HANDLER = new MockHandler();
+
+ private MonitorFactory factory;
+
+ /**
+ * Smoke test to ensure the LOGGER is working.
+ */
+ public void testLogger() {
+ LOGGER.info("test");
+ assertEquals(1, HANDLER.logs.size());
+ }
+
+ /**
+ * Test that no record is logged.
+ */
+ public void testUnloggedEvent() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventNotToLog();
+ assertEquals(0, HANDLER.logs.size());
+ }
+
+ /**
+ * Test the correct record is written for an event with no arguments.
+ */
+ public void testEventWithNoArgs() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithNoArgs();
+ assertEquals(1, HANDLER.logs.size());
+ LogRecord record = HANDLER.logs.get(0);
+ assertEquals(Level.INFO, record.getLevel());
+ assertEquals(LOGGER.getName(), record.getLoggerName());
+ assertEquals(Monitor.class.getName() + "#eventWithNoArgs", record.getMessage());
+ }
+
+ /**
+ * Test the correct record is written for an event defined by annotation.
+ */
+ public void testEventWithAnnotation() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithAnnotation();
+ assertEquals(1, HANDLER.logs.size());
+ LogRecord record = HANDLER.logs.get(0);
+ assertEquals(Level.INFO, record.getLevel());
+ assertEquals(LOGGER.getName(), record.getLoggerName());
+ assertEquals(Monitor.class.getName() + "#eventWithAnnotation", record.getMessage());
+ }
+
+ /**
+ * Test a Throwable is logged when passed to an event.
+ */
+ public void testEventWithThrowable() {
+ Exception e = new Exception();
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithThrowable(e);
+ assertEquals(1, HANDLER.logs.size());
+ LogRecord record = HANDLER.logs.get(0);
+ assertEquals(Level.WARNING, record.getLevel());
+ assertEquals(LOGGER.getName(), record.getLoggerName());
+ assertEquals(Monitor.class.getName() + "#eventWithThrowable", record.getMessage());
+ assertSame(e, record.getThrown());
+ }
+
+ /**
+ * Test the argument is logged.
+ */
+ public void testEventWithOneArg() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithOneArg("ARG");
+ assertEquals(1, HANDLER.logs.size());
+ LogRecord record = HANDLER.logs.get(0);
+ assertEquals(Monitor.class.getName() + "#eventWithOneArg", record.getMessage());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ LOGGER.setUseParentHandlers(false);
+ LOGGER.addHandler(HANDLER);
+ HANDLER.flush();
+
+ String sourceClass = Monitor.class.getName();
+ Properties levels = new Properties();
+ levels.setProperty(sourceClass + "#eventWithNoArgs", "INFO");
+ levels.setProperty(sourceClass + "#eventWithOneArg", "INFO");
+ levels.setProperty(sourceClass + "#eventWithThrowable", "WARNING");
+ factory = new JavaLoggingMonitorFactory(levels, Level.FINE, "TestMessages");
+ }
+
+ protected void tearDown() throws Exception {
+ LOGGER.removeHandler(HANDLER);
+ HANDLER.flush();
+ super.tearDown();
+ }
+
+ /**
+ * Mock log HANDLER to capture records.
+ */
+ public static class MockHandler extends Handler {
+ List<LogRecord> logs = new ArrayList<LogRecord>();
+
+ public void publish(LogRecord record) {
+ logs.add(record);
+ }
+
+ public void flush() {
+ logs.clear();
+ }
+
+ public void close() throws SecurityException {
+ }
+ }
+
+ @SuppressWarnings({"JavaDoc"})
+ public static interface Monitor {
+ void eventNotToLog();
+
+ void eventWithNoArgs();
+
+ void eventWithOneArg(String msg);
+
+ void eventWithThrowable(Exception e);
+
+ @LogLevel("INFO")
+ void eventWithAnnotation();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java
new file mode 100644
index 0000000000..4f2e2fbf42
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.core.property;
+
+import java.net.URL;
+import javax.xml.namespace.NamespaceContext;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.databinding.xml.String2Node;
+import org.easymock.EasyMock;
+
+/**
+ *
+ */
+public class PropertyHelperTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testXPath() throws Exception {
+ String2Node t = new String2Node();
+ Node node = t.transform(IPO_XML, null);
+
+ Document doc = PropertyHelper.evaluate(null, node, "/ipo:purchaseOrder/billTo");
+ assertNotNull(doc);
+
+ NamespaceContext context = EasyMock.createMock(NamespaceContext.class);
+ EasyMock.expect(context.getNamespaceURI("ipo")).andReturn("http://www.example.com/IPO").anyTimes();
+ EasyMock.replay(context);
+ doc = PropertyHelper.evaluate(context, node, "/ipo:purchaseOrder/items");
+ assertNotNull(doc);
+ doc = PropertyHelper.evaluate(context, node, "/ipo:purchaseOrder/billTo");
+ assertNotNull(doc);
+ doc = PropertyHelper.evaluate(context, node, "/");
+ assertNotNull(doc);
+ doc = PropertyHelper.evaluate(context, node, "/ipo:purchaseOrder/billTo1");
+ assertNull(doc);
+ }
+
+ public void testFile() throws Exception {
+ URL url = getClass().getResource("ipo.xml");
+ Document doc = PropertyHelper.loadFromFile(url.toExternalForm(), null);
+ assertNotNull(doc);
+
+ DeploymentContext context = EasyMock.createMock(DeploymentContext.class);
+ EasyMock.expect(context.getClassLoader()).andReturn(getClass().getClassLoader());
+ EasyMock.replay(context);
+ doc = PropertyHelper.loadFromFile("org/apache/tuscany/core/property/ipo.xml", context);
+ assertNotNull(doc);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java
new file mode 100644
index 0000000000..9ef1faccfe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.property;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimplePropertyObjectFactoryTestCase extends TestCase {
+
+ private <T> PropertyValue<T> mock(String value) {
+ Document document = EasyMock.createMock(Document.class);
+ Element element = EasyMock.createMock(Element.class);
+ EasyMock.expect(document.getDocumentElement()).andReturn(element);
+ EasyMock.expect(element.getTextContent()).andReturn(value);
+ EasyMock.replay(document, element);
+ return new PropertyValue<T>(null, document);
+ }
+
+ public void testInteger() throws Exception {
+
+ PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl();
+ Property<Integer> property = new Property<Integer>();
+ property.setJavaType(Integer.class);
+ PropertyValue<Integer> propertyValue = mock("1");
+ ObjectFactory<Integer> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals(1, oFactory.getInstance().intValue());
+ }
+
+ public void testPrimitiveInt() throws Exception {
+ PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl();
+ Property<Integer> property = new Property<Integer>();
+ property.setJavaType(Integer.TYPE);
+ PropertyValue<Integer> propertyValue = mock("1");
+ ObjectFactory<Integer> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals(1, oFactory.getInstance().intValue());
+ }
+
+ public void testString() throws Exception {
+ PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl();
+ Property<String> property = new Property<String>();
+ property.setJavaType(String.class);
+ PropertyValue<String> propertyValue = mock("1");
+ ObjectFactory<String> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertEquals("1", oFactory.getInstance());
+ }
+
+ public void testByteArray() throws Exception {
+ PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl();
+ Property<byte[]> property = new Property<byte[]>();
+ property.setJavaType(byte[].class);
+ PropertyValue<byte[]> propertyValue = mock("TWFu"); // BASE64 for "Man"
+ ObjectFactory<byte[]> oFactory = factory.createObjectFactory(property, propertyValue);
+ byte[] result = oFactory.getInstance();
+ byte[] expected = "Man".getBytes();
+ for (int i = 0; i < result.length; i++) {
+ byte b = result[i];
+ if (b != expected[i]) {
+ fail();
+ }
+ }
+ }
+
+ public void testBoolean() throws Exception {
+ PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl();
+ Property<Boolean> property = new Property<Boolean>();
+ property.setJavaType(Boolean.class);
+ PropertyValue<Boolean> propertyValue = mock("true");
+ ObjectFactory<Boolean> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertTrue(oFactory.getInstance());
+ }
+
+ public void testPrimitiveBoolean() throws Exception {
+ PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl();
+ Property<Boolean> property = new Property<Boolean>();
+ property.setJavaType(Boolean.TYPE);
+ PropertyValue<Boolean> propertyValue = mock("true");
+ ObjectFactory<Boolean> oFactory = factory.createObjectFactory(property, propertyValue);
+ assertTrue(oFactory.getInstance());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java
new file mode 100644
index 0000000000..0efecb9302
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.artifact;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.services.artifact.Artifact;
+
+/**
+ * This testcase assumes that there is a maven repo in the default location.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LocalMavenRepositoryTestCase extends TestCase {
+ private static final String VERSION = "3.8.1";
+ private LocalMavenRepository repo;
+ private Artifact artifact;
+ private String path;
+
+ public void testPathWithNoClassifier() {
+ assertEquals(path, repo.getPath(artifact));
+ }
+
+ public void testPathWithClassifier() {
+ artifact.setClassifier("x86");
+ path = "junit/junit/" + VERSION + "/junit-" + VERSION + "-x86.jar";
+ assertEquals(path, repo.getPath(artifact));
+ }
+
+ public void testArtifactFoundInRepo() throws MalformedURLException, UnsupportedEncodingException {
+ String home = System.getProperty("user.home");
+ File file = new File(home + "/.m2/repository", path);
+ repo.resolve(artifact);
+ assertEquals(file.toURI().toURL(), artifact.getUrl());
+ }
+
+ public void testArtifactNotFoundInRepo() throws MalformedURLException {
+ artifact.setClassifier("x86");
+ repo.resolve(artifact);
+ assertNull(artifact.getUrl());
+ }
+
+ public void testNonNullURLIsUnmodified() throws MalformedURLException {
+ URL url = new URL("http://www.apache.org");
+ artifact.setUrl(url);
+ repo.resolve(artifact);
+ assertSame(url, artifact.getUrl());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ repo = new LocalMavenRepository(".m2/repository");
+
+ artifact = new Artifact();
+ artifact.setGroup("junit");
+ artifact.setName("junit");
+ artifact.setVersion(VERSION);
+ artifact.setType("jar");
+ path = "junit/junit/" + VERSION + "/junit-" + VERSION + ".jar";
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java
new file mode 100644
index 0000000000..1a5cb4ebe1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237;
+
+import org.apache.tuscany.spi.services.work.NotificationListener;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+
+import commonj.work.WorkManager;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager;
+
+public class Jsr237WorkSchedulerTest extends TestCase {
+
+ /*
+ * Test method for 'org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler.scheduleWork(T) <T>'
+ */
+ public void testScheduleWorkT() {
+
+
+ WorkManager workManager = new ThreadPoolWorkManager(1);
+ WorkScheduler workScheduler = new Jsr237WorkScheduler(workManager);
+
+ workScheduler.scheduleWork(new MyRunnable(), new MyNotificationListener());
+
+ }
+
+ /*
+ * Test method for 'org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler.scheduleWork(T,
+ * NotificationListener<T>) <T>'
+ */
+ public void testScheduleWorkTNotificationListenerOfT() {
+
+ }
+
+ private class MyRunnable implements Runnable {
+ public void run() {
+ System.err.println("Test executed");
+ }
+ }
+
+ private class MyNotificationListener implements NotificationListener<MyRunnable> {
+
+ public void workAccepted(MyRunnable work) {
+ System.err.println("Work accepted");
+ }
+
+ public void workCompleted(MyRunnable work) {
+ System.err.println("Work completed");
+ }
+
+ public void workStarted(MyRunnable work) {
+ System.err.println("Work started");
+ }
+
+ public void workRejected(MyRunnable work) {
+ System.err.println("Work rejected");
+ }
+
+ public void workFailed(MyRunnable work, Throwable error) {
+ System.err.println("Work failed");
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java
new file mode 100644
index 0000000000..3966f65683
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237;
+
+import org.apache.tuscany.spi.services.work.NotificationListener;
+import org.apache.tuscany.spi.services.work.WorkSchedulerException;
+
+import commonj.work.Work;
+import commonj.work.WorkItem;
+import commonj.work.WorkListener;
+import commonj.work.WorkManager;
+import commonj.work.WorkRejectedException;
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Jsr237WorkSchedulerTestCase extends TestCase {
+
+ public void testSchedule() throws Exception {
+ WorkItem item = createMock(WorkItem.class);
+ WorkManager mgr = createMock(WorkManager.class);
+ mgr.schedule(isA(Work.class));
+ expectLastCall().andReturn(item);
+ replay(mgr);
+ Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr);
+ Work work = createMock(Work.class);
+ scheduler.scheduleWork(work);
+ verify(mgr);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testListener() throws Exception {
+ WorkItem item = createMock(WorkItem.class);
+ WorkManager mgr = createMock(WorkManager.class);
+ mgr.schedule(isA(Work.class), isA(WorkListener.class));
+ expectLastCall().andReturn(item);
+ replay(mgr);
+ Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr);
+ Work work = createMock(Work.class);
+ NotificationListener<Runnable> listener = createMock(NotificationListener.class);
+ scheduler.scheduleWork(work, listener);
+ verify(mgr);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testWorkRejectedListener() throws Exception {
+ WorkManager mgr = createMock(WorkManager.class);
+ mgr.schedule(isA(Work.class), isA(WorkListener.class));
+ expectLastCall().andThrow(new WorkRejectedException());
+ replay(mgr);
+ Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr);
+ Work work = createMock(Work.class);
+ NotificationListener<Runnable> listener = createMock(NotificationListener.class);
+ listener.workRejected(isA(Runnable.class));
+ expectLastCall();
+ replay(listener);
+ scheduler.scheduleWork(work, listener);
+ verify(mgr);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testWorkRejectedNoListener() throws Exception {
+ WorkManager mgr = createMock(WorkManager.class);
+ mgr.schedule(isA(Work.class));
+ expectLastCall().andThrow(new WorkRejectedException());
+ replay(mgr);
+ Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr);
+ Work work = createMock(Work.class);
+ try {
+ scheduler.scheduleWork(work);
+ fail();
+ } catch (WorkSchedulerException e) {
+ // expected
+ }
+ verify(mgr);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java
new file mode 100644
index 0000000000..33ecd66fdc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.services.work.jsr237.workmanager;
+
+import java.util.concurrent.CountDownLatch;
+
+import commonj.work.Work;
+import commonj.work.WorkEvent;
+import commonj.work.WorkListener;
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ThreadPoolWorkManagerTestCase extends TestCase {
+
+ public void testSchedule() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ Work work = createMock(Work.class);
+ work.run();
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ latch.countDown();
+ return null;
+ }
+ });
+ replay(work);
+ ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1);
+ mgr.schedule(work);
+ latch.await();
+ verify(work);
+ }
+
+ public void testListener() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ WorkListener listener = createStrictMock(WorkListener.class);
+ listener.workAccepted(isA(WorkEvent.class));
+ listener.workStarted(isA(WorkEvent.class));
+ listener.workCompleted(isA(WorkEvent.class));
+ expectLastCall();
+ replay(listener);
+ Work work = createMock(Work.class);
+ work.run();
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ latch.countDown();
+ return null;
+ }
+ });
+ replay(work);
+ ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1);
+ mgr.schedule(work, listener);
+ latch.await();
+ verify(work);
+ }
+
+ public void testDelayListener() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ final CountDownLatch latch2 = new CountDownLatch(1);
+ WorkListener listener = createStrictMock(WorkListener.class);
+ listener.workAccepted(isA(WorkEvent.class));
+ listener.workStarted(isA(WorkEvent.class));
+ listener.workCompleted(isA(WorkEvent.class));
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ latch2.countDown();
+ return null;
+ }
+ });
+ replay(listener);
+ Work work = createMock(Work.class);
+ work.run();
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ latch.await();
+ return null;
+ }
+ });
+ replay(work);
+ ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1);
+ mgr.schedule(work, listener);
+ latch.countDown();
+ verify(work);
+ }
+
+ public void testErrorListener() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(1);
+ WorkListener listener = createStrictMock(WorkListener.class);
+ listener.workAccepted(isA(WorkEvent.class));
+ listener.workStarted(isA(WorkEvent.class));
+ listener.workCompleted(isA(WorkEvent.class));
+ replay(listener);
+ Work work = createMock(Work.class);
+ work.run();
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ latch.countDown();
+ throw new RuntimeException();
+ }
+ });
+ replay(work);
+ ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1);
+ mgr.schedule(work, listener);
+ latch.await();
+ verify(work);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java
new file mode 100644
index 0000000000..79fad549aa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.util;
+
+
+public class Bean1 extends SuperBean {
+
+ public static final int ALL_BEAN1_FIELDS = 6 + ALL_SUPER_FIELDS;
+ public static final int ALL_BEAN1_PUBLIC_PROTECTED_FIELDS = 5 + ALL_SUPER_PUBLIC_PROTECTED_FIELDS;
+ public static final int ALL_BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1;
+ public String field3;
+ protected String field2;
+ private String field1;
+
+ public void setMethod1(String param) {
+ }
+
+ public void setMethod1(int param) {
+ }
+
+ public void override(String param) throws Exception {
+ }
+
+
+ public void noOverride(String param) throws Exception {
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java
new file mode 100644
index 0000000000..7f7f03da9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.util;
+
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+public class Bean2 {
+
+ private List methodList;
+ private List fieldList;
+
+ public List getMethodList() {
+ return methodList;
+ }
+
+ public void setMethodList(List list) {
+ methodList = list;
+ }
+
+ public List getfieldList() {
+ return fieldList;
+ }
+
+ public void setfieldList(List list) {
+ throw new AssertionFailedError("setter inadvertantly called");
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java
new file mode 100644
index 0000000000..797b147b54
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.Target;
+
+public class JavaIntrospectionHelperTestCase extends TestCase {
+
+ private List testNoGenericsList;
+ private List<String> testList;
+ private Map<String, Bean1> testMap;
+ private Target[] testArray;
+ private String[] testStringArray;
+
+ public JavaIntrospectionHelperTestCase() {
+ super();
+ }
+
+ public JavaIntrospectionHelperTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void testBean1AllPublicProtectedFields() throws Exception {
+ Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class);
+ assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
+ }
+
+ public void testGetSuperAllMethods() throws Exception {
+ Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class);
+ assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
+ }
+
+ public void testGetBean1AllMethods() throws Exception {
+ Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+ assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size());
+ }
+
+ public void testOverrideMethod() throws Exception {
+ Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+ boolean invoked = false;
+ for (Method method : beanFields) {
+ if (method.getName().equals("override")) {
+ method.invoke(new Bean1(), "foo");
+ invoked = true;
+ }
+ }
+ if (!invoked) {
+ throw new Exception("Override never invoked");
+ }
+ }
+
+ public void testNoOverrideMethod() throws Exception {
+ Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+ boolean found = false;
+ for (Method method : beanFields) {
+ if (method.getName().equals("noOverride") && method.getParameterTypes().length == 0) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("No override not found");
+ }
+ }
+
+ public void testDefaultConstructor() throws Exception {
+ Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(Bean2.class);
+ assertEquals(ctr, Bean2.class.getConstructor());
+ assertTrue(Bean2.class == ctr.newInstance((Object[]) null).getClass());
+ }
+
+
+ public void testGetAllInterfaces() {
+ Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class);
+ assertEquals(2, interfaces.size());
+ assertTrue(interfaces.contains(W.class));
+ assertTrue(interfaces.contains(W2.class));
+ }
+
+
+ public void testGetAllInterfacesObject() {
+ Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class);
+ assertEquals(0, interfaces.size());
+ }
+
+ public void testGetAllInterfacesNoInterfaces() {
+ Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(NoInterface.class);
+ assertEquals(0, interfaces.size());
+ }
+
+ /**
+ * Tests generics introspection capabilities
+ */
+ public void testGenerics() throws Exception {
+
+ List classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testList").getGenericType());
+ assertEquals(1, classes.size());
+ assertEquals(String.class, classes.get(0));
+
+ classes =
+ JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testNoGenericsList").getGenericType());
+ assertEquals(0, classes.size());
+
+ classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testMap").getGenericType());
+ assertEquals(2, classes.size());
+ assertEquals(String.class, classes.get(0));
+ assertEquals(Bean1.class, classes.get(1));
+
+ classes = JavaIntrospectionHelper
+ .getGenerics(getClass().getDeclaredMethod("fooMethod", Map.class).getGenericParameterTypes()[0]);
+ assertEquals(2, classes.size());
+ assertEquals(String.class, classes.get(0));
+ assertEquals(Bean1.class, classes.get(1));
+
+ classes = JavaIntrospectionHelper
+ .getGenerics(getClass().getDeclaredMethod("fooMethod", List.class).getGenericParameterTypes()[0]);
+ assertEquals(1, classes.size());
+ assertEquals(String.class, classes.get(0));
+
+ }
+
+ private void fooMethod(List<String> foo) {
+
+ }
+
+ private void fooMethod(Map<String, Bean1> foo) {
+
+ }
+
+ public void setTestArray(Target[] array) {
+ }
+
+ private interface W {
+
+ }
+
+ private interface W2 {
+
+ }
+
+ private class X implements W {
+
+ }
+
+ private class Y extends X implements W, W2 {
+
+ }
+
+ private class Z extends Y {
+
+ }
+
+ private class NoInterface {
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java
new file mode 100644
index 0000000000..83aef7fb5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.util;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SuperBean {
+
+ public static final int ALL_SUPER_FIELDS = 6;
+ public static final int ALL_SUPER_PUBLIC_PROTECTED_FIELDS = 5;
+ public static final int ALL_SUPER_METHODS = 4;
+ public String superField2;
+
+ protected String superField3;
+
+ private String superField1;
+
+ public void setSuperMethod1(String param) {
+ }
+
+ public void setSuperMethod1(int param) {
+ }
+
+ public void override(String param) throws Exception {
+ throw new Exception("Override not handled");
+ }
+
+ public void noOverride() throws Exception {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..fe7469c998
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class BasicReferenceInvocationHandlerTestCase extends TestCase {
+
+ private Method echo;
+
+ public void testInterceptorInvoke() throws Throwable {
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(SimpleTarget.class);
+ Operation<?> operation = contract.getOperations().get("echo");
+ MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl());
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ chain.addInterceptor(interceptor);
+ chain.setTargetInterceptor(new InvokerInterceptor());
+ chain.setTargetInvoker(invoker);
+ chain.prepare();
+ //chains.put(echo, chain);
+ OutboundWire wire = new OutboundWireImpl();
+ wire.addInvocationChain(operation, chain);
+ wire.setServiceContract(contract);
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ assertEquals("foo", handler.invoke(null, echo, new String[]{"foo"}));
+ assertEquals(1, interceptor.getCount());
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ echo = SimpleTarget.class.getMethod("echo", String.class);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java
new file mode 100644
index 0000000000..79abec4904
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.jdk.JDKInboundInvocationHandler;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * Tests handling of exceptions thrown during an inbound wire invocation
+ *
+ * @version $Rev$ $Date$
+ */
+public class InboundInvocationErrorTestCase extends TestCase {
+
+ private Method checkedMethod;
+ private Method runtimeMethod;
+ private Operation checkedOperation;
+ private Operation runtimeOperation;
+
+ public InboundInvocationErrorTestCase() {
+ super();
+ }
+
+ public InboundInvocationErrorTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ checkedMethod =
+ TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+ runtimeMethod =
+ TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+ assertNotNull(checkedMethod);
+ assertNotNull(runtimeMethod);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(TestBean.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+
+ checkedOperation = contract.getOperations().get("checkedException");
+ runtimeOperation = contract.getOperations().get("runtimeException");
+ }
+
+ public void testCheckedException() throws Exception {
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ chains.put(checkedMethod, createChain(checkedMethod, checkedOperation));
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, workContext);
+ try {
+ InboundInvocationErrorTestCase.TestBean proxy = (InboundInvocationErrorTestCase.TestBean) Proxy
+ .newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[]{InboundInvocationErrorTestCase.TestBean.class}, handler);
+ proxy.checkedException();
+ } catch (InboundInvocationErrorTestCase.TestException e) {
+ return;
+ }
+ fail(InboundInvocationErrorTestCase.TestException.class.getName() + " should have been thrown");
+ }
+
+ public void testRuntimeException() throws Exception {
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ chains.put(runtimeMethod, createChain(runtimeMethod, runtimeOperation));
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, workContext);
+ try {
+ InboundInvocationErrorTestCase.TestBean proxy = (InboundInvocationErrorTestCase.TestBean) Proxy
+ .newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[]{InboundInvocationErrorTestCase.TestBean.class}, handler);
+ proxy.runtimeException();
+ } catch (InboundInvocationErrorTestCase.TestRuntimeException e) {
+ return;
+ }
+ fail(InboundInvocationErrorTestCase.TestException.class.getName() + " should have been thrown");
+ }
+
+ private InboundInvocationChain createChain(Method m, Operation operation) {
+ MockStaticInvoker invoker = new MockStaticInvoker(m, new InboundInvocationErrorTestCase.TestBeanImpl());
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ chain.addInterceptor(new MockSyncInterceptor());
+ chain.setTargetInvoker(invoker);
+ chain.addInterceptor(new InvokerInterceptor());
+ chain.prepare();
+ return chain;
+ }
+
+ public interface TestBean {
+
+ void checkedException() throws InboundInvocationErrorTestCase.TestException;
+
+ void runtimeException() throws InboundInvocationErrorTestCase.TestRuntimeException;
+
+ }
+
+ public class TestBeanImpl implements InboundInvocationErrorTestCase.TestBean {
+
+ public void checkedException() throws InboundInvocationErrorTestCase.TestException {
+ throw new InboundInvocationErrorTestCase.TestException();
+ }
+
+ public void runtimeException() throws InboundInvocationErrorTestCase.TestRuntimeException {
+ throw new InboundInvocationErrorTestCase.TestRuntimeException();
+ }
+ }
+
+ public class TestException extends Exception {
+ }
+
+ public class TestRuntimeException extends RuntimeException {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java
new file mode 100644
index 0000000000..294e98997f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvocationChainImplTestCase extends TestCase {
+
+ public void testInsertAtPos() throws Exception {
+ MockChain chain = new MockChain(new Operation<Type>("foo", null, null, null));
+ Interceptor inter3 = new MockInterceptor();
+ Interceptor inter2 = new MockInterceptor();
+ Interceptor inter1 = new MockInterceptor();
+ chain.addInterceptor(inter3);
+ chain.addInterceptor(0, inter1);
+ chain.addInterceptor(1, inter2);
+ Interceptor head = chain.getHeadInterceptor();
+ assertEquals(inter1, head);
+ assertEquals(inter2, head.getNext());
+ assertEquals(inter3, head.getNext().getNext());
+ }
+
+ public void testInsertAtEnd() throws Exception {
+ MockChain chain = new MockChain(new Operation<Type>("foo", null, null, null));
+ Interceptor inter2 = new MockInterceptor();
+ Interceptor inter1 = new MockInterceptor();
+ chain.addInterceptor(0, inter1);
+ chain.addInterceptor(1, inter2);
+ Interceptor head = chain.getHeadInterceptor();
+ assertEquals(inter1, head);
+ assertEquals(inter2, head.getNext());
+ assertEquals(inter2, chain.getTailInterceptor());
+
+ }
+
+ private class MockChain extends InvocationChainImpl {
+
+ public MockChain(Operation operation) {
+ super(operation);
+ }
+
+ public void prepare() {
+
+ }
+ }
+
+ private class MockInterceptor implements Interceptor {
+
+ private Interceptor next;
+
+ public Message invoke(Message msg) {
+ return null;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next = next;
+ }
+
+ public Interceptor getNext() {
+ return next;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java
new file mode 100644
index 0000000000..aca68a0f25
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+
+/**
+ * Tests error propagation through an innvocation
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationConfigurationErrorTestCase extends TestCase {
+
+ private ServiceContract<?> contract;
+ private Method hello;
+
+ public InvocationConfigurationErrorTestCase() {
+ super();
+ }
+
+ public InvocationConfigurationErrorTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ contract = registry.introspect(SimpleTarget.class);
+ hello = SimpleTarget.class.getMethod("hello", String.class);
+ }
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvokeWithInterceptors() throws Exception {
+ Operation operation = contract.getOperations().get("hello");
+ OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addInterceptor(sourceInterceptor);
+
+ InboundInvocationChain target = new InboundInvocationChainImpl(operation);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addInterceptor(targetInterceptor);
+ target.addInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetInterceptor(target.getHeadInterceptor());
+ source.prepare();
+ target.prepare();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(invoker);
+ Message response = source.getHeadInterceptor().invoke(msg);
+ assertTrue(response.isFault());
+ assertTrue(response.getBody() instanceof IllegalArgumentException);
+ assertEquals(1, sourceInterceptor.getCount());
+ assertEquals(1, targetInterceptor.getCount());
+
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java
new file mode 100644
index 0000000000..62df732a9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+
+public class InvocationConfigurationTestCase extends TestCase {
+
+ private Method hello;
+ private Operation operation;
+
+
+ public InvocationConfigurationTestCase() {
+ super();
+ }
+
+ public InvocationConfigurationTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+
+ operation = contract.getOperations().get("echo");
+ hello = SimpleTarget.class.getMethod("hello", String.class);
+ }
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvokeWithInterceptors() throws Exception {
+ OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addInterceptor(sourceInterceptor);
+
+ InboundInvocationChain target = new InboundInvocationChainImpl(operation);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addInterceptor(targetInterceptor);
+ target.addInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetInterceptor(target.getHeadInterceptor());
+ source.prepare();
+ target.prepare();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = new MessageImpl();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = source.getHeadInterceptor().invoke(msg);
+ assertEquals("foo", response.getBody());
+ assertEquals(1, sourceInterceptor.getCount());
+ assertEquals(1, targetInterceptor.getCount());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/MediationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/MediationTestCase.java
new file mode 100644
index 0000000000..a81e955a20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/MediationTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
+
+/**
+ * Tests invoking on a different interface from the one actually implemented by the target
+ *
+ * @version $Rev$ $Date$
+ */
+public class MediationTestCase extends TestCase {
+
+ private Method hello;
+
+ public void setUp() throws Exception {
+ hello = Hello.class.getMethod("hello", String.class);
+ }
+
+ public void testMediation() throws Exception {
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(hello, new SimpleTargetImpl());
+ Assert.assertEquals("foo", invoker.invokeTarget("foo"));
+ }
+
+ public interface Hello {
+
+ String hello(String message) throws Exception;
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java
new file mode 100644
index 0000000000..a8b1eaf36f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NonBlockingBridgingInterceptorTestCase extends TestCase {
+
+ public void testInvoke() throws Exception {
+ WorkScheduler scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+ WorkContext context = createMock(WorkContext.class);
+ Message msg = new MessageImpl();
+ Interceptor next = EasyMock.createMock(Interceptor.class);
+ EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg);
+ EasyMock.replay(next);
+ Interceptor interceptor = new NonBlockingBridgingInterceptor(scheduler, context, next);
+ interceptor.invoke(msg);
+ verify(next);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java
new file mode 100644
index 0000000000..6313f14220
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler;
+
+/**
+ * Tests handling of exceptions thrown during an outbound wire invocation
+ *
+ * @version $Rev$ $Date$
+ */
+public class OutboundInvocationErrorTestCase extends TestCase {
+
+ private Method checkedMethod;
+ private Method runtimeMethod;
+ private JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+
+ public OutboundInvocationErrorTestCase() {
+ super();
+ }
+
+ public OutboundInvocationErrorTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+ runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+ assertNotNull(checkedMethod);
+ assertNotNull(runtimeMethod);
+ }
+
+ public void testCheckedException() throws Exception {
+ OutboundWire wire = new OutboundWireImpl();
+ ServiceContract<?> contract = registry.introspect(TestBean.class);
+ wire.setServiceContract(contract);
+ Operation operation = contract.getOperations().get("checkedException");
+ wire.addInvocationChain(operation, createChain(checkedMethod, operation));
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ try {
+ TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[]{TestBean.class}, handler);
+ proxy.checkedException();
+ } catch (TestException e) {
+ return;
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ public void testRuntimeException() throws Exception {
+ OutboundWire wire = new OutboundWireImpl();
+ ServiceContract<?> contract = registry.introspect(TestBean.class);
+ wire.setServiceContract(contract);
+ Operation operation = contract.getOperations().get("runtimeException");
+ OutboundInvocationChain chain = createChain(runtimeMethod, operation);
+ wire.addInvocationChain(operation, chain);
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ try {
+ TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[]{TestBean.class}, handler);
+ proxy.runtimeException();
+ } catch (TestRuntimeException e) {
+ return;
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ private OutboundInvocationChain createChain(Method m, Operation operation) {
+ MockStaticInvoker invoker = new MockStaticInvoker(m, new TestBeanImpl());
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ chain.addInterceptor(new MockSyncInterceptor());
+ chain.setTargetInvoker(invoker);
+ chain.setTargetInterceptor(new InvokerInterceptor());
+ chain.prepare();
+ return chain;
+ }
+
+ public interface TestBean {
+
+ void checkedException() throws TestException;
+
+ void runtimeException() throws TestRuntimeException;
+
+ }
+
+ public class TestBeanImpl implements TestBean {
+
+ public void checkedException() throws TestException {
+ throw new TestException();
+ }
+
+ public void runtimeException() throws TestRuntimeException {
+ throw new TestRuntimeException();
+ }
+ }
+
+ public class TestException extends Exception {
+ }
+
+ public class TestRuntimeException extends RuntimeException {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..11e2a78d56
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.idl.java.JavaIDLUtils;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler;
+
+public class OutboundInvocationHandlerTestCase extends TestCase {
+
+ private Method hello;
+ private ServiceContract<?> contract;
+
+ public OutboundInvocationHandlerTestCase() {
+ super();
+ }
+
+ public OutboundInvocationHandlerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ contract = registry.introspect(SimpleTarget.class);
+ hello = SimpleTarget.class.getMethod("hello", String.class);
+ }
+
+ public void testBasicInvoke() throws Throwable {
+ OutboundWire wire = new OutboundWireImpl();
+ Operation operation = contract.getOperations().get("hello");
+ wire.addInvocationChain(operation, createChain(operation));
+ wire.setServiceContract(contract);
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
+ }
+
+ public void testErrorInvoke() throws Throwable {
+ OutboundWire wire = new OutboundWireImpl();
+ Operation operation = contract.getOperations().get("hello");
+ wire.addInvocationChain(operation, createChain(operation));
+ wire.setServiceContract(contract);
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ try {
+ handler.invoke(hello, new Object[]{});
+ fail("Expected " + IllegalArgumentException.class.getName());
+ } catch (IllegalArgumentException e) {
+ // should throw
+ }
+ }
+
+ public void testDirectErrorInvoke() throws Throwable {
+ Operation operation = contract.getOperations().get("hello");
+ OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setServiceContract(contract);
+ wire.addInvocationChain(operation, source);
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ try {
+ assertEquals("foo", handler.invoke(hello, new Object[]{}));
+ fail("Expected " + IllegalArgumentException.class.getName());
+ } catch (IllegalArgumentException e) {
+ // should throw
+ }
+ }
+
+ public void testDirectInvoke() throws Throwable {
+ Operation operation = contract.getOperations().get("hello");
+ OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setServiceContract(contract);
+ wire.addInvocationChain(operation, source);
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
+ }
+
+ private OutboundInvocationChain createChain(Operation operation) {
+ OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addInterceptor(sourceInterceptor);
+
+ InboundInvocationChain target = new InboundInvocationChainImpl(operation);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addInterceptor(targetInterceptor);
+ target.addInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetInterceptor(targetInterceptor);
+ source.prepare();
+ target.prepare();
+ Method method = JavaIDLUtils.findMethod(operation, SimpleTarget.class.getMethods());
+ MockStaticInvoker invoker = new MockStaticInvoker(method, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+ return source;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/StaticPojoInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/StaticPojoInvokerTestCase.java
new file mode 100644
index 0000000000..e9e07dfa0a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/StaticPojoInvokerTestCase.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import static java.lang.Integer.TYPE;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class StaticPojoInvokerTestCase extends TestCase {
+
+ private Method echoMethod;
+ private Method arrayMethod;
+ private Method nullParamMethod;
+ private Method primitiveMethod;
+ private Method checkedMethod;
+ private Method runtimeMethod;
+
+ public StaticPojoInvokerTestCase() {
+
+ }
+
+ public StaticPojoInvokerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ echoMethod = TestBean.class.getDeclaredMethod("echo", String.class);
+ arrayMethod = TestBean.class.getDeclaredMethod("arrayEcho", String[].class);
+ nullParamMethod = TestBean.class.getDeclaredMethod("nullParam", (Class[]) null);
+ primitiveMethod = TestBean.class.getDeclaredMethod("primitiveEcho", TYPE);
+ checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+ runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+ Assert.assertNotNull(echoMethod);
+ Assert.assertNotNull(checkedMethod);
+ Assert.assertNotNull(runtimeMethod);
+ }
+
+ public void testObjectInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(echoMethod, bean);
+ Object ret = invoker.invokeTarget("foo");
+ Assert.assertEquals("foo", ret);
+ }
+
+ public void testArrayInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(arrayMethod, bean);
+ String[] args = new String[]{"foo", "bar"};
+ Object ret = invoker.invokeTarget(new Object[]{args});
+ String[] retA = (String[]) ret;
+ Assert.assertNotNull(retA);
+ Assert.assertEquals(2, retA.length);
+ Assert.assertEquals("foo", retA[0]);
+ Assert.assertEquals("bar", retA[1]);
+ }
+
+ public void testNullInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(nullParamMethod, bean);
+ Object ret = invoker.invokeTarget(null);
+ String retS = (String) ret;
+ Assert.assertEquals("foo", retS);
+ }
+
+ public void testPrimitiveInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(primitiveMethod, bean);
+ Object ret = invoker.invokeTarget(new Integer[]{1});
+ Integer retI = (Integer) ret;
+ Assert.assertEquals(1, retI.intValue());
+ }
+
+ public void testInvokeCheckedException() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(checkedMethod, bean);
+ try {
+ invoker.invokeTarget(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && TestException.class.equals(e.getCause().getClass())) {
+ return;
+ }
+ } catch (Throwable e) {
+ //ok
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ public void testInvokeRuntimeException() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticPojoTargetInvoker invoker = new StaticPojoTargetInvoker(runtimeMethod, bean);
+ try {
+ invoker.invokeTarget(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && e.getCause() instanceof TestRuntimeException) {
+ return;
+ }
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ private class TestBean {
+
+ public String echo(String msg) throws Exception {
+ Assert.assertEquals("foo", msg);
+ return msg;
+ }
+
+ public String[] arrayEcho(String[] msg) throws Exception {
+ Assert.assertNotNull(msg);
+ Assert.assertEquals(2, msg.length);
+ Assert.assertEquals("foo", msg[0]);
+ Assert.assertEquals("bar", msg[1]);
+ return msg;
+ }
+
+ public String nullParam() throws Exception {
+ return "foo";
+ }
+
+ public int primitiveEcho(int i) throws Exception {
+ return i;
+ }
+
+ public void checkedException() throws TestException {
+ throw new TestException();
+ }
+
+ public void runtimeException() throws TestRuntimeException {
+ throw new TestRuntimeException();
+ }
+ }
+
+ public class TestException extends Exception {
+ }
+
+ public class TestRuntimeException extends RuntimeException {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java
new file mode 100644
index 0000000000..f1631fc555
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.verify;
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SynchronousBridgingInterceptorTestCase extends TestCase {
+
+ public void testInvoke() throws Exception {
+ Message msg = new MessageImpl();
+ Interceptor next = EasyMock.createMock(Interceptor.class);
+ EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg);
+ EasyMock.replay(next);
+ Interceptor interceptor = new SynchronousBridgingInterceptor(next);
+ interceptor.invoke(msg);
+ verify(next);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java
new file mode 100644
index 0000000000..97e27d947e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+
+/**
+ * Verifies wire optimization analysis
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class WireOptimizationTestCase extends TestCase {
+
+ private Operation operation;
+ private Method m;
+
+ public void foo() {
+ }
+
+ public void testSourceWireInterceptorOptimization() throws Exception {
+ OutboundWire wire = new OutboundWireImpl();
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ chain.addInterceptor(new OptimizableInterceptor());
+ wire.addInvocationChain(operation, chain);
+ assertTrue(wire.isOptimizable());
+ }
+
+ public void testSourceWireNonInterceptorOptimization() throws Exception {
+ OutboundWire wire = new OutboundWireImpl();
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ chain.addInterceptor(new NonOptimizableInterceptor());
+ wire.addInvocationChain(operation, chain);
+ assertFalse(wire.isOptimizable());
+ }
+
+ public void testTargetWireInterceptorOptimization() throws Exception {
+ InboundWire wire = new InboundWireImpl();
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ chain.addInterceptor(new OptimizableInterceptor());
+ wire.addInvocationChain(operation, chain);
+ assertTrue(wire.isOptimizable());
+ }
+
+ public void testTargetWireNonInterceptorOptimization() throws Exception {
+ InboundWire wire = new InboundWireImpl();
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ chain.addInterceptor(new NonOptimizableInterceptor());
+ wire.addInvocationChain(operation, chain);
+ assertFalse(wire.isOptimizable());
+ }
+
+ public void testTargetWireNonTargetInvokerOptimization() throws Exception {
+ InboundWire wire = new InboundWireImpl();
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ TargetInvoker invoker = new StaticPojoTargetInvoker(m, new Object());
+ invoker.setCacheable(false);
+ chain.setTargetInvoker(invoker);
+ wire.addInvocationChain(operation, chain);
+ assertFalse(wire.isOptimizable());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ m = getClass().getMethod("foo", (Class[]) null);
+ operation = new Operation<Type>("foo", null, null, null, false, null);
+
+ }
+
+ private class OptimizableInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ return null;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+ }
+
+ private class NonOptimizableInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ return null;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..d34ecd61f0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.mock.component.SimpleTarget;
+import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
+import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
+import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * Verifies invocations on inbound wires
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class JDKInboundInvocationHandlerTestCase extends TestCase {
+
+ private Method echo;
+ private Operation operation;
+
+ public void testInterceptorInvoke() throws Throwable {
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl());
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ chain.addInterceptor(interceptor);
+ chain.addInterceptor(new InvokerInterceptor());
+ chain.setTargetInvoker(invoker);
+ chain.prepare();
+ chains.put(echo, chain);
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, workContext);
+ assertEquals("foo", handler.invoke(echo, new String[]{"foo"}));
+ assertEquals(1, interceptor.getCount());
+ }
+
+
+ public void testDirectErrorInvoke() throws Throwable {
+ InboundInvocationChain source = new InboundInvocationChainImpl(operation);
+ MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ chains.put(echo, source);
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, workContext);
+ try {
+ assertEquals("foo", handler.invoke(echo, new Object[]{}));
+ fail("Expected " + IllegalArgumentException.class.getName());
+ } catch (IllegalArgumentException e) {
+ // should throw
+ }
+ }
+
+ public void testDirectInvoke() throws Throwable {
+ InboundInvocationChain source = new InboundInvocationChainImpl(operation);
+ MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ chains.put(echo, source);
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, workContext);
+ assertEquals("foo", handler.invoke(echo, new Object[]{"foo"}));
+ }
+
+ public void testToString() {
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler =
+ new JDKInboundInvocationHandler(new HashMap<Method, InboundInvocationChain>(), workContext);
+ Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
+ assertNotNull(foo.toString());
+ }
+
+ public void testHashCode() {
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ JDKInboundInvocationHandler handler =
+ new JDKInboundInvocationHandler(new HashMap<Method, InboundInvocationChain>(), workContext);
+ Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
+ assertNotNull(foo.hashCode());
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+ operation = contract.getOperations().get("echo");
+ echo = SimpleTarget.class.getMethod("echo", String.class);
+ }
+
+ private interface Foo {
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..74338c4d38
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.wire.jdk;
+
+import java.lang.reflect.Proxy;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKOutboundInvocationHandlerTestCase extends TestCase {
+
+ public void testToString() {
+ OutboundWireImpl wire = new OutboundWireImpl();
+ wire.setServiceContract(new JavaServiceContract(Foo.class));
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
+ assertNotNull(foo.toString());
+ }
+
+ public void testHashCode() {
+ OutboundWireImpl wire = new OutboundWireImpl();
+ wire.setServiceContract(new JavaServiceContract(Foo.class));
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+ Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
+ assertNotNull(foo.hashCode());
+ }
+
+ private interface Foo {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd
new file mode 100644
index 0000000000..92a576fb98
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl
new file mode 100644
index 0000000000..100890e10b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/order.wsdl" xmlns:tns="http://example.com/order.wsdl"
+ xmlns:xsd1="http://example.com/order.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/order.xsd" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd"/>
+ <element name="checkOrderStatus">
+ <complexType>
+ <sequence>
+ <element name="customerId" type="string" />
+ <element name="order" type="ipo:PurchaseOrderType" />
+ <element name="flag" type="int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="checkOrderStatusResponse">
+ <complexType>
+ <sequence>
+ <element name="status" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="note" type="string" />
+ </schema>
+ </types>
+
+ <message name="CheckOrderStatusInput1">
+ <part name="body" element="xsd1:checkOrderStatus" />
+ </message>
+
+ <message name="CheckOrderStatusOutput1">
+ <part name="body" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <message name="CheckOrderStatusInput2">
+ <part name="p1" element="xsd1:checkOrderStatus" />
+ <part name="p2" element="xsd1:note" />
+ </message>
+
+ <message name="CheckOrderStatusOutput2">
+ <part name="p1" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <portType name="OrderPortType">
+ <operation name="checkOrderStatus">
+ <input message="tns:CheckOrderStatusInput1" />
+ <output message="tns:CheckOrderStatusOutput1" />
+ </operation>
+ <operation name="checkOrderStatus2">
+ <input message="tns:CheckOrderStatusInput2" />
+ <output message="tns:CheckOrderStatusOutput2" />
+ </operation>
+ </portType>
+
+</definitions> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml
new file mode 100644
index 0000000000..0ba8ade1e0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<f:foo xmlns:f="http://foo" name="foo">
+ <b:bar xmlns:b="http://bar">bar</b:bar>
+</f:foo> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl
new file mode 100644
index 0000000000..c8b825ed5a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="boot1-include">
+
+ <component name="component2">
+ <system:implementation.system class="org.apache.tuscany.core.mock.component.BasicInterfaceImpl"/>
+ </component>
+
+ <service name="service2" >
+ <interface.java interface="org.apache.tuscany.core.mock.component.BasicInterface"/>
+ <system:binding.system/>
+ <reference>component2</reference>
+ </service>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl
new file mode 100644
index 0000000000..f9397bcac0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="boot1">
+ <service name="service" >
+ <interface.java interface="org.apache.tuscany.core.mock.component.BasicInterface"/>
+ <system:binding.system/>
+ <reference>component</reference>
+ </service>
+
+ <component name="component">
+ <system:implementation.system class="org.apache.tuscany.core.mock.component.BasicInterfaceImpl"/>
+ <property name="publicProperty">propval</property>
+ <reference name="publicReference">component2</reference>
+ </component>
+
+ <include name="boot1-include" scdlLocation="boot1-include.scdl"/>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl
new file mode 100644
index 0000000000..bdf8061778
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ A more complex example closer to a typical bootstrap configuration
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="boot2">
+
+ <!-- expose Deployer API as a service -->
+ <service name="deployer" >
+ <interface.java interface="org.apache.tuscany.spi.deployer.Deployer"/>
+ <system:binding.system/>
+ <reference>deployerImpl</reference>
+ </service>
+
+ <!-- Component that provides the Deployer service -->
+ <component name="deployerImpl">
+ <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+ </component>
+
+ <!-- Work management -->
+ <component name="workContext">
+ <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+ </component>
+
+ <!-- Scope infrastructure -->
+ <component name="scopeRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+ </component>
+
+ <!-- Builder and BuilderRegistry -->
+ <component name="builder">
+ <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+ </component>
+
+ <!-- Loader and LoaderRegistry -->
+ <component name="loader">
+ <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+ </component>
+
+ <!-- Introspector and IntrospectionRegistry -->
+ <component name="interfaceProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+ </component>
+
+ <!-- Connector infrastructure -->
+ <component name="connector">
+ <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+ </component>
+
+ <!-- Foundcation element loader implementations -->
+ <component name="elementLoader.component">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ComponentLoader"/>
+ </component>
+ <component name="elementLoader.componentType">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ComponentTypeElementLoader"/>
+ </component>
+ <component name="elementLoader.interface.java">
+ <system:implementation.system class="org.apache.tuscany.core.idl.java.InterfaceJavaLoader"/>
+ </component>
+ <component name="elementLoader.property">
+ <system:implementation.system class="org.apache.tuscany.core.loader.PropertyLoader"/>
+ </component>
+ <component name="elementLoader.reference">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ReferenceLoader"/>
+ </component>
+ <component name="elementLoader.service">
+ <system:implementation.system class="org.apache.tuscany.core.loader.ServiceLoader"/>
+ </component>
+
+ <component name="wireService">
+ <system:implementation.system class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+ </component>
+
+ <!-- Composite implementation type -->
+ <component name="composite.loader">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeLoader"/>
+ </component>
+
+ <component name="interfaceJava.interfaceProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl"/>
+ </component>
+
+ <component name="artifactRepository">
+ <system:implementation.system class="org.apache.tuscany.core.services.artifact.LocalMavenRepository"/>
+ <property name="repository">.m2/repository</property>
+ </component>
+
+ <!-- DataBinding registry -->
+ <component name="databinding.registry">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.DataBindingRegistryImpl" />
+ </component>
+
+ <!-- DataBinding registry -->
+ <component name="databinding.mediator">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.MediatorImpl" />
+ </component>
+
+ <!-- Transformer registry -->
+ <component name="databinding.transformerRegistry" initLevel="90">
+ <system:implementation.system class="org.apache.tuscany.core.databinding.impl.TransformerRegistryImpl" />
+ </component>
+
+ <component name="propertyFactory">
+ <system:implementation.system class="org.apache.tuscany.core.property.PropertyObjectFactoryImpl"/>
+ </component>
+
+ <component name="policyBuilderRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+ </component>
+
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl
new file mode 100644
index 0000000000..584846504b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite>
+ This file just needs to exist
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml
new file mode 100644
index 0000000000..df901d183d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ipo:purchaseOrder
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ipo="http://www.example.com/IPO"
+ xsi:schemaLocation="http://www.example.com/IPO ipo.xsd"
+ orderDate="1999-12-01">
+
+ <shipTo exportCode="1" xsi:type="ipo:UKAddress">
+ <name>Helen Zoe</name>
+ <street>47 Eden Street</street>
+ <city>Cambridge</city>
+ <postcode>CB1 1JR</postcode>
+ </shipTo>
+
+ <billTo xsi:type="ipo:USAddress">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+
+ <items>
+ <item partNum="833-AA">
+ <productName>Lapis necklace</productName>
+ <quantity>1</quantity>
+ <USPrice>99.95</USPrice>
+ <ipo:comment>Want this for the holidays</ipo:comment>
+ <shipDate>1999-12-05</shipDate>
+ </item>
+ </items>
+</ipo:purchaseOrder>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.checkstyle b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.checkstyle
new file mode 100644
index 0000000000..3e57539570
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.checkstyle
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.pmd b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.pmd
new file mode 100644
index 0000000000..ffc4fe2bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/pom.xml
new file mode 100644
index 0000000000..da401b448a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-host-api</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Host API</name>
+ <description>Tuscany Host Programming Interfaces.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java
new file mode 100644
index 0000000000..64f2e8b9a0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host;
+
+import java.net.URL;
+
+import org.osoa.sca.CompositeContext;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Interface that allows a host to launch a runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Launcher {
+ /**
+ * Boot the Tuscany runtime.
+ *
+ * @param systemScdl the SCDL defining the runtime's system configuration
+ * @param systemClassLoader the root classloader to use to deploy the system SCDL
+ * @param monitorFactory the monitor factory initialize the runtime with
+ * @throws TuscanyException if there was a problem booting the runtimr
+ */
+ void bootRuntime(URL systemScdl, ClassLoader systemClassLoader, MonitorFactory monitorFactory)
+ throws TuscanyException;
+
+ /**
+ * Shutdown the Tuscany runtime.
+ */
+ void shutdownRuntime();
+
+ /**
+ * Boot a default application into the runtime.
+ *
+ * @param applicationScdl the application's SCDL
+ * @param applicationClassLoader the classloader to use to deploy the application
+ * @return the CompositeContext for the application
+ */
+ CompositeContext bootApplication(URL applicationScdl, ClassLoader applicationClassLoader);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java
new file mode 100644
index 0000000000..d338681641
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host;
+
+import java.util.Map;
+
+/**
+ * A MonitorFactory creates implementations of components' monitor interfaces that interface with a its monitoring
+ * scheme. For example, a implementation may create versions that emit appropriate logging events or which send
+ * notifications to a management API.
+ *
+ * MonitorFactory implementations must provide a no-arg constructor and implement the {@link #initialize} method
+ * to perform configuration of instances created using that constructor. Additional constructors may be defined;
+ * typically their implementations delegate to {@link #initialize}.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MonitorFactory {
+ /**
+ * Initializes MonitorFactory instances with implementation-specific configuration properties.
+ *
+ * @param configProperties a map of named configuration properties. May be null.
+ * @throws IllegalArgumentException if the instance can't be configured using the supplied properties
+ */
+ void initialize(Map<String, Object> configProperties);
+ /**
+ * Return a monitor for a component's monitor interface.
+ *
+ * @param monitorInterface the component's monitoring interface
+ * @return an implementation of the monitoring interface; will not be null
+ */
+ <T> T getMonitor(Class<T> monitorInterface);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java
new file mode 100644
index 0000000000..b22235f4c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * Interface that provides information on the runtime environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeInfo {
+ /**
+ * The default name that the runtime should assign to the component providing this service.
+ */
+ String COMPONENT_NAME = "RuntimeInfo";
+
+ /**
+ * Return the directory where the running runtime was installed.
+ *
+ * @return the directory where the runtime was installed
+ */
+ File getInstallDirectory();
+
+ /**
+ * Return the root directory used to resolve application file paths.
+ *
+ * @return the directory used to resolve application file paths.
+ */
+ File getApplicationRootDirectory();
+
+ /**
+ * Gets the base URL for the runtime.
+ *
+ * @return The base URL for the runtime.
+ */
+ URL getBaseURL();
+
+ /**
+ * Returns whether the runtime considers itself "online" or connected to the internet.
+ * This can be used by services to enable access to remote resources.
+ *
+ * @return true if the runtime is online.
+ */
+ boolean isOnline();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java
new file mode 100644
index 0000000000..203179de92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.rmi;
+
+import java.rmi.Remote;
+
+/* RMI Service hosting interface to be implemented by host environments that allows SCA Components
+ * to register RMI Services to handle inbound service requests over RMI to SCA Components
+ */
+
+public interface RMIHost {
+ int RMI_DEFAULT_PORT = 1099;
+
+ // registers an RMI service with the given name and port
+ void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ // registers an RMI service with the given name and default port (1099)
+ void registerService(String serviceName, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ // unregister a service registered under the given service name and port number
+ void unregisterService(String serviceName, int port) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ // unregister a service registered under the given service name and defalut port number (1099)
+ void unregisterService(String serviceName) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ //find a remote service hosted on the given host, port and service name
+ Remote findService(String host, String port, String svcName) throws RMIHostException,
+ RMIHostRuntimeException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java
new file mode 100644
index 0000000000..dedfff1cdd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.rmi;
+
+import java.rmi.registry.Registry;
+import java.util.List;
+
+/* RMI Service hosting Admin Interface to be implemented by host environments that allows SCA Components
+ * to register RMI Services to handle inbound service requests over RMI to SCA Components. This interface
+ * can be used by admin functions to obtain information on RMI registries started and running in the host
+ * environment
+ */
+
+public interface RMIHostAdmin {
+ //gets all RMI registries running on the host. Each element of the list is an object of type
+ //java.rmi.registry
+ List getAllRegistries() throws RMIHostRuntimeException;
+
+ //gets a registry that is running at a particular port
+ Registry getRegistry(int port) throws RMIHostRuntimeException;
+
+ //more methods to be added
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java
new file mode 100644
index 0000000000..3a5d27dcc7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.rmi;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * This exception will relate to situations where the end applicaition's
+ * input is the cause of the exception
+ *
+ */
+public class RMIHostException extends TuscanyException {
+
+ private static final long serialVersionUID = -1L;
+
+ public RMIHostException() {
+ }
+
+ public RMIHostException(String message) {
+ super(message);
+ }
+
+ public RMIHostException(Throwable e) {
+ super(e);
+ }
+
+ public RMIHostException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java
new file mode 100644
index 0000000000..35b207b5d2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.rmi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * This exception relates to cases where there is a problem with the
+ * Host runtime
+ *
+ */
+public class RMIHostRuntimeException extends TuscanyRuntimeException {
+ private static final long serialVersionUID = -1L;
+
+ public RMIHostRuntimeException() {
+ }
+
+ public RMIHostRuntimeException(String message) {
+ super(message);
+ }
+
+ public RMIHostRuntimeException(Throwable e) {
+ super(e);
+ }
+
+ public RMIHostRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
new file mode 100644
index 0000000000..72bdc38774
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.runtime;
+
+import java.net.URL;
+
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TuscanyRuntime {
+ /**
+ * Returns the location of the SCDL used to boot this runtime.
+ *
+ * @return the location of the SCDL used to boot this runtime
+ */
+ URL getSystemScdl();
+
+ /**
+ * Sets the location of the SCDL used to boot this runtime.
+ *
+ * @param systemScdl the location of the SCDL used to boot this runtime
+ */
+ void setSystemScdl(URL systemScdl);
+
+ /**
+ * Returns the name of the component associated with the application SCDL.
+ * @return the name of the component associated with the application SCDL
+ */
+ String getApplicationName();
+
+ /**
+ * Sets the name of the component associated with the application SCDL.
+ * @param applicationName the name of the component associated with the application SCDL
+ */
+ void setApplicationName(String applicationName);
+
+ /**
+ * Returns the location of the default application's SCDL.
+ *
+ * @return the location of the default application's SCDL
+ */
+ URL getApplicationScdl();
+
+ /**
+ * Sets the location of the default application's SCDL
+ *
+ * @param applicationScdl the location of the default application's SCDL
+ */
+ void setApplicationScdl(URL applicationScdl);
+
+ /**
+ * Returns the host ClassLoader that is parent to all Tuscany classloaders.
+ *
+ * @return the host's ClassLoader
+ */
+ ClassLoader getHostClassLoader();
+
+ /**
+ * Sets the host ClassLoader; this will be a parent for all Tuscany classloaders.
+ *
+ * @param classLoader the host's ClassLoader
+ */
+ void setHostClassLoader(ClassLoader classLoader);
+
+ /**
+ * Returns the info this runtime will make available to service components.
+ *
+ * @return the info this runtime will make available to service components
+ */
+ RuntimeInfo getRuntimeInfo();
+
+ /**
+ * Sets the info this runtime should make available to service components.
+ * The instance supplied here should be registered in the system composite with the name
+ * {@link RuntimeInfo#COMPONENT_NAME "RuntimeInfo"}.
+ *
+ * @param runtimeInfo the information this runtime should make available to service components
+ */
+ void setRuntimeInfo(RuntimeInfo runtimeInfo);
+
+ /** Returns the MonitorFactory that this runtime is using.
+ *
+ * @return the MonitorFactory that this runtime is using
+ */
+ MonitorFactory getMonitorFactory();
+
+ /**
+ * Sets the MonitorFactory that this runtime should use.
+ * @param monitorFactory the MonitorFactory that this runtime should use
+ */
+ void setMonitorFactory(MonitorFactory monitorFactory);
+
+ /**
+ * Create the default MonitorFactory for this runtime.
+ *
+ * @return the default MonitorFactory for this runtime
+ */
+ MonitorFactory createDefaultMonitorFactory();
+
+ /**
+ * Initialize a runtime.
+ *
+ */
+ void initialize();
+
+ /**
+ * Destroy the runtime. Any further invocations should result in an error.
+ */
+ void destroy();
+
+ /**
+ * Returns the current SCA context
+ */
+ SCA getContext();
+
+ /**
+ * Get the application classloader
+ */
+ ClassLoader getApplicationClassLoader();
+
+ /**
+ * Set the application classloader
+ */
+ void setApplicationClassLoader(ClassLoader applicationClassLoader);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java
new file mode 100644
index 0000000000..e4b11aee90
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.servlet;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * Interface to a system component that dispatches servlet requests to the Tuscany runtime
+ */
+public interface ServletRequestInjector {
+
+ /**
+ * Dispatch servlet requests to the Tuscany runtime
+ *
+ * @param req the ServletRequest object that contains the request the client made of the servlet
+ * @param res the ServletResponse object that contains the response the servlet returns to the client
+ * @throws ServletException if the request cannot be handled
+ * @throws IOException if an input or output error occurs while handling the request
+ */
+ void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
new file mode 100644
index 0000000000..c0f9003b89
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class LaunchHelper {
+
+ ///CLOVER:OFF
+ private LaunchHelper() {
+ }
+
+ /**
+ * Scan a directory for jar files to be added to the classpath.
+ *
+ * @param lib the directory to scan
+ * @return the URLs or jar files in that directory
+ */
+ public static URL[] scanDirectoryForJars(File lib) {
+ File[] jars = lib.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ });
+
+ URL[] urls = new URL[jars.length];
+ for (int i = 0; i < jars.length; i++) {
+ try {
+ urls[i] = jars[i].toURI().toURL();
+ } catch (MalformedURLException e) {
+ // toURI should have escaped the URL
+ throw new AssertionError();
+ }
+ }
+ return urls;
+ }
+
+ /**
+ * Set a JavaBean property on an object.
+ *
+ * @param instance the object whose property should be set
+ * @param name the name of the property
+ * @param value the value to set it to
+ */
+ public static void setProperty(Object instance, String name, Object value) {
+ Class<?> beanType = instance.getClass();
+ name = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ Class<?> propertyType = value.getClass();
+ try {
+ Method setter = beanType.getMethod(name, propertyType);
+ setter.invoke(instance, value);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException(e);
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException(e);
+ } catch (InvocationTargetException e) {
+ throw new IllegalStateException(e.getCause());
+ }
+ }
+
+ /**
+ * Invoke a method on an object.
+ *
+ * @param instance the object to invoke
+ * @param name the name of the method to invoke
+ * @param args arguments to call the method with
+ * @return the value returned by the method
+ * @throws InvocationTargetException if the method throw an Exception
+ */
+ public static Object invoke(Object instance, String name, Class<?>[] paramTypes, Object... args)
+ throws InvocationTargetException {
+ try {
+ Method method = instance.getClass().getMethod(name, paramTypes);
+ return method.invoke(instance, (Object[]) args);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException(e);
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java
new file mode 100644
index 0000000000..8c07fe743c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.rmi;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RMIHostExceptionTestCase extends TestCase {
+ private static final Throwable CAUSE = new Throwable("Cause");
+ private static final String MESSAGE = "Message";
+
+ public void testNoArgConstructor() {
+ Exception ex = new RMIHostException();
+ assertNull(ex.getMessage());
+ assertNull(ex.getCause());
+ }
+
+ public void testMessageConstructor() {
+ Exception ex = new RMIHostException(MESSAGE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertNull(ex.getCause());
+ }
+
+ public void testThrowableConstructor() {
+ Exception ex = new RMIHostException(CAUSE);
+ assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ }
+
+ public void testMessageThrowableConstructor() {
+ Exception ex = new RMIHostException(MESSAGE, CAUSE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java
new file mode 100644
index 0000000000..5071a68132
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.rmi;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RMIHostRuntimeExceptionTestCase extends TestCase {
+ private static final Throwable CAUSE = new Throwable("Cause");
+ private static final String MESSAGE = "Message";
+
+ public void testNoArgConstructor() {
+ Exception ex = new RMIHostRuntimeException();
+ assertNull(ex.getMessage());
+ assertNull(ex.getCause());
+ }
+
+ public void testMessageConstructor() {
+ Exception ex = new RMIHostRuntimeException(MESSAGE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertNull(ex.getCause());
+ }
+
+ public void testThrowableConstructor() {
+ Exception ex = new RMIHostRuntimeException(CAUSE);
+ assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ }
+
+ public void testMessageThrowableConstructor() {
+ Exception ex = new RMIHostRuntimeException(MESSAGE, CAUSE);
+ assertSame(MESSAGE, ex.getMessage());
+ assertSame(CAUSE, ex.getCause());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/util/LaunchHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/util/LaunchHelperTestCase.java
new file mode 100644
index 0000000000..bf846cf0a8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/host-api/src/test/java/org/apache/tuscany/host/util/LaunchHelperTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.host.util;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LaunchHelperTestCase extends TestCase {
+ private TestBean instance;
+
+ public void testSetPrimitive() {
+ // fixme this does not work yet
+// LaunchHelper.setProperty(instance, "int", 12);
+// assertEquals(12, instance.anInt);
+ }
+
+ public void testSetObject() {
+ LaunchHelper.setProperty(instance, "string", "Hello");
+ Assert.assertEquals("Hello", instance.aString);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ instance = new TestBean();
+ }
+
+ private static class TestBean {
+ private int anInt;
+ private String aString;
+
+ public void setInt(int anInt) {
+ this.anInt = anInt;
+ }
+
+ public void setString(String aString) {
+ this.aString = aString;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/pom.xml
new file mode 100644
index 0000000000..98fc9d52a0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Kernel Sub-Project</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>api</module>
+ <module>host-api</module>
+ <module>spi</module>
+ <module>core</module>
+ </modules>
+ </profile>
+
+ <profile>
+ <id>javadoc</id>
+ <modules>
+ <module>api</module>
+ <module>host-api</module>
+ <module>spi</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.checkstyle b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.checkstyle
new file mode 100644
index 0000000000..3e57539570
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.checkstyle
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.pmd b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.pmd
new file mode 100644
index 0000000000..ffc4fe2bbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/pom.xml
new file mode 100644
index 0000000000..6bc0672e3a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-spi</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany SCA SPI</name>
+ <description>Tuscany Service Provider Interfaces.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-host-api</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/doc/Context Model.emx b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/doc/Context Model.emx
new file mode 100644
index 0000000000..0445ea5a6b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/doc/Context Model.emx
@@ -0,0 +1,673 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--xtools2_universal_type_manager-->
+<uml:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.ibm.com/xtools/1.5.0/Notation" xmlns:uml="http://www.eclipse.org/uml2/1.0.0/UML" xmlns:umlnotation="http://www.ibm.com/xtools/1.5.0/Umlnotation" xmi:id="_al1S8NovEdqRBPR5WyT36A" name="Context Model" appliedProfile="_al1S9NovEdqRBPR5WyT36A _al1S99ovEdqRBPR5WyT36A _al1S-tovEdqRBPR5WyT36A _al1S_dovEdqRBPR5WyT36A _al1TANovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S8dovEdqRBPR5WyT36A" source="uml2.diagrams" references="_al1S8tovEdqRBPR5WyT36A">
+ <contents xmi:type="notation:Diagram" xmi:id="_al1S8tovEdqRBPR5WyT36A" type="Class" name="Main">
+ <children xmi:id="_ePDcYdovEdqRBPR5WyT36A" sourceEdges="_Fd3lQdowEdqRBPR5WyT36A _R5Rjwdo1EdqRBPR5WyT36A _pdfmkNo2EdqRBPR5WyT36A" targetEdges="_hmIF4dovEdqRBPR5WyT36A _mu9A4dovEdqRBPR5WyT36A _pe3jwNovEdqRBPR5WyT36A" element="_ePDcYNovEdqRBPR5WyT36A">
+ <children xmi:id="_ePJjANovEdqRBPR5WyT36A" type="ImageCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_ePJjAdovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_ePJjAtovEdqRBPR5WyT36A" type="Stereotype" element="_ePDcYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ePJjA9ovEdqRBPR5WyT36A" type="Kind" element="_ePDcYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ePJjBNovEdqRBPR5WyT36A" type="Name" element="_ePDcYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ePJjBdovEdqRBPR5WyT36A" type="AttributeCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ePJjBtovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ePJjB9ovEdqRBPR5WyT36A" type="OperationCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ePJjCNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ePJjCdovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_ePDcYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ePJjCtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_ePDcYtovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_ePDcY9ovEdqRBPR5WyT36A" x="6693" y="3545"/>
+ </children>
+ <children xmi:id="_fs1pANovEdqRBPR5WyT36A" sourceEdges="_hmIF4dovEdqRBPR5WyT36A _pe3jwNovEdqRBPR5WyT36A" targetEdges="_xInjYdovEdqRBPR5WyT36A" element="_fsviYNovEdqRBPR5WyT36A">
+ <children xmi:id="_fs1pA9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_fs1pBNovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_fs1pBdovEdqRBPR5WyT36A" type="Stereotype" element="_fsviYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_fs1pBtovEdqRBPR5WyT36A" type="Kind" element="_fsviYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_fs1pB9ovEdqRBPR5WyT36A" type="Name" element="_fsviYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_fs1pCNovEdqRBPR5WyT36A" type="AttributeCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_fs1pCdovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_fs1pCtovEdqRBPR5WyT36A" type="OperationCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_fs1pC9ovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_fs1pDNovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_fsviYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_fs1pDdovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_fs1pAdovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_fs1pAtovEdqRBPR5WyT36A" x="2226" y="8268"/>
+ </children>
+ <children xmi:id="_ikr_4NovEdqRBPR5WyT36A" sourceEdges="_mu9A4dovEdqRBPR5WyT36A" element="_ikl5QNovEdqRBPR5WyT36A">
+ <children xmi:id="_ikr_49ovEdqRBPR5WyT36A" type="ImageCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_ikr_5NovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_ikr_5dovEdqRBPR5WyT36A" type="Stereotype" element="_ikl5QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ikr_5tovEdqRBPR5WyT36A" type="Kind" element="_ikl5QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ikr_59ovEdqRBPR5WyT36A" type="Name" element="_ikl5QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_ikr_6NovEdqRBPR5WyT36A" type="AttributeCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ikr_6dovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ikr_6tovEdqRBPR5WyT36A" type="OperationCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ikr_69ovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_ikr_7NovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_ikl5QNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_ikr_7dovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_ikr_4dovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_ikr_4tovEdqRBPR5WyT36A" x="9222" y="8268"/>
+ </children>
+ <children xmi:id="_tZF9odovEdqRBPR5WyT36A" sourceEdges="_xInjYdovEdqRBPR5WyT36A _BkUg0dowEdqRBPR5WyT36A" element="_tZF9oNovEdqRBPR5WyT36A">
+ <children xmi:id="_tZF9pNovEdqRBPR5WyT36A" type="ImageCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_tZF9pdovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_tZF9ptovEdqRBPR5WyT36A" type="Stereotype" element="_tZF9oNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_tZF9p9ovEdqRBPR5WyT36A" type="Kind" element="_tZF9oNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_tZF9qNovEdqRBPR5WyT36A" type="Name" element="_tZF9oNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_tZF9qdovEdqRBPR5WyT36A" type="AttributeCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_tZF9qtovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_tZF9q9ovEdqRBPR5WyT36A" type="OperationCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_tZF9rNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_tZF9rdovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_tZF9oNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_tZF9rtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_tZF9otovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_tZF9o9ovEdqRBPR5WyT36A" x="2226" y="12084"/>
+ </children>
+ <children xmi:id="_z_m-oNovEdqRBPR5WyT36A" sourceEdges="_cN4xsdo2EdqRBPR5WyT36A" targetEdges="_3Ic-4NovEdqRBPR5WyT36A _9XeF4tovEdqRBPR5WyT36A _Fd3lQdowEdqRBPR5WyT36A" element="_z_g4ANovEdqRBPR5WyT36A">
+ <children xmi:id="_z_m-o9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_z_m-pNovEdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_z_m-pdovEdqRBPR5WyT36A" type="Stereotype" element="_z_g4ANovEdqRBPR5WyT36A"/>
+ <children xmi:id="_z_m-ptovEdqRBPR5WyT36A" type="Kind" element="_z_g4ANovEdqRBPR5WyT36A"/>
+ <children xmi:id="_z_m-p9ovEdqRBPR5WyT36A" type="Name" element="_z_g4ANovEdqRBPR5WyT36A"/>
+ <children xmi:id="_z_m-qNovEdqRBPR5WyT36A" type="AttributeCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_z_m-qdovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_z_m-qtovEdqRBPR5WyT36A" type="OperationCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_z_m-q9ovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_z_m-rNovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_z_g4ANovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_z_m-rdovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_z_m-odovEdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_z_m-otovEdqRBPR5WyT36A" x="17172" y="6996"/>
+ </children>
+ <children xmi:id="_1y-ZsNovEdqRBPR5WyT36A" sourceEdges="_3Ic-4NovEdqRBPR5WyT36A _9-BEUNo2EdqRBPR5WyT36A" targetEdges="_BkUg0dowEdqRBPR5WyT36A" element="_1yyMcNovEdqRBPR5WyT36A">
+ <children xmi:id="_1y-Zs9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_1y-ZtNovEdqRBPR5WyT36A" width="1320" height="1320"/>
+ </children>
+ <children xmi:id="_1y-ZtdovEdqRBPR5WyT36A" type="Stereotype" element="_1yyMcNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_1y-ZttovEdqRBPR5WyT36A" type="Name" element="_1yyMcNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_1y-Zt9ovEdqRBPR5WyT36A" type="AttributeCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_1y-ZuNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_1y-ZudovEdqRBPR5WyT36A" type="OperationCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_1y-ZutovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_1y-Zu9ovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_1y-ZvNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_1y-ZvdovEdqRBPR5WyT36A" visible="false" type="StructureCompartment" element="_1yyMcNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLShapeCompartmentStyle" xmi:id="_1y-ZvtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLShapeStyle" xmi:id="_1y-ZsdovEdqRBPR5WyT36A" showStereotype="Label"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_1y-ZstovEdqRBPR5WyT36A" x="13992" y="12084"/>
+ </children>
+ <children xmi:id="_4WSrANovEdqRBPR5WyT36A" sourceEdges="_9XeF4tovEdqRBPR5WyT36A _9PaR4No2EdqRBPR5WyT36A" element="_4WMkYNovEdqRBPR5WyT36A">
+ <children xmi:id="_4WSrA9ovEdqRBPR5WyT36A" type="ImageCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_4WSrBNovEdqRBPR5WyT36A" width="1320" height="1320"/>
+ </children>
+ <children xmi:id="_4WSrBdovEdqRBPR5WyT36A" type="Stereotype" element="_4WMkYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_4WSrBtovEdqRBPR5WyT36A" type="Name" element="_4WMkYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_4WSrB9ovEdqRBPR5WyT36A" type="AttributeCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_4WSrCNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_4WSrCdovEdqRBPR5WyT36A" type="OperationCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_4WSrCtovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_4WSrC9ovEdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_4WSrDNovEdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_4WSrDdovEdqRBPR5WyT36A" visible="false" type="StructureCompartment" element="_4WMkYNovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLShapeCompartmentStyle" xmi:id="_4WSrDtovEdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLShapeStyle" xmi:id="_4WSrAdovEdqRBPR5WyT36A" showStereotype="Label"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_4WSrAtovEdqRBPR5WyT36A" x="19716" y="12084"/>
+ </children>
+ <children xmi:id="_o2m3oNo0EdqRBPR5WyT36A" targetEdges="_9PaR4No2EdqRBPR5WyT36A _9-BEUNo2EdqRBPR5WyT36A" element="_o2gxANo0EdqRBPR5WyT36A">
+ <children xmi:id="_o2m3o9o0EdqRBPR5WyT36A" type="ImageCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_o2m3pNo0EdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_o2m3pdo0EdqRBPR5WyT36A" type="Stereotype" element="_o2gxANo0EdqRBPR5WyT36A"/>
+ <children xmi:id="_o2m3pto0EdqRBPR5WyT36A" type="Kind" element="_o2gxANo0EdqRBPR5WyT36A"/>
+ <children xmi:id="_o2m3p9o0EdqRBPR5WyT36A" type="Name" element="_o2gxANo0EdqRBPR5WyT36A"/>
+ <children xmi:id="_o2m3qNo0EdqRBPR5WyT36A" type="AttributeCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_o2m3qdo0EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_o2m3qto0EdqRBPR5WyT36A" type="OperationCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_o2m3q9o0EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_o2m3rNo0EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_o2gxANo0EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_o2m3rdo0EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_o2m3odo0EdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_o2m3oto0EdqRBPR5WyT36A" x="23532" y="6996"/>
+ </children>
+ <children xmi:id="_M0FLkNo1EdqRBPR5WyT36A" targetEdges="_R5Rjwdo1EdqRBPR5WyT36A _V7zlEdo1EdqRBPR5WyT36A" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <children xmi:id="_M0FLk9o1EdqRBPR5WyT36A" type="ImageCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_M0FLlNo1EdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_M0FLldo1EdqRBPR5WyT36A" type="Stereotype" element="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <children xmi:id="_M0FLlto1EdqRBPR5WyT36A" type="Kind" element="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <children xmi:id="_M0FLl9o1EdqRBPR5WyT36A" type="Name" element="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <children xmi:id="_M0FLmNo1EdqRBPR5WyT36A" type="AttributeCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_M0FLmdo1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_M0FLmto1EdqRBPR5WyT36A" type="OperationCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_M0FLm9o1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_M0FLnNo1EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_Mz_E8No1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_M0FLndo1EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_M0FLkdo1EdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_M0FLkto1EdqRBPR5WyT36A" x="6678" y="318"/>
+ </children>
+ <children xmi:id="_TJHbANo1EdqRBPR5WyT36A" sourceEdges="_V7zlEdo1EdqRBPR5WyT36A" targetEdges="_cN4xsdo2EdqRBPR5WyT36A" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <children xmi:id="_TJHbA9o1EdqRBPR5WyT36A" type="ImageCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_TJHbBNo1EdqRBPR5WyT36A" width="530" height="530"/>
+ </children>
+ <children xmi:id="_TJHbBdo1EdqRBPR5WyT36A" type="Stereotype" element="_TI7NwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_TJHbBto1EdqRBPR5WyT36A" type="Kind" element="_TI7NwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_TJHbB9o1EdqRBPR5WyT36A" type="Name" element="_TI7NwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_TJHbCNo1EdqRBPR5WyT36A" type="AttributeCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_TJHbCdo1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_TJHbCto1EdqRBPR5WyT36A" type="OperationCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_TJHbC9o1EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_TJHbDNo1EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_TI7NwNo1EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_TJHbDdo1EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLClassifierStyle" xmi:id="_TJHbAdo1EdqRBPR5WyT36A" showStereotype="Label" useClassifierShape="true"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_TJHbAto1EdqRBPR5WyT36A" x="16854" y="318"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLDiagramStyle" xmi:id="_al1S89ovEdqRBPR5WyT36A"/>
+ <edges xmi:id="_hmIF4dovEdqRBPR5WyT36A" element="_hmIF4NovEdqRBPR5WyT36A" source="_fs1pANovEdqRBPR5WyT36A" target="_ePDcYdovEdqRBPR5WyT36A">
+ <children xmi:id="_hmIF5NovEdqRBPR5WyT36A" type="NameLabel" element="_hmIF4NovEdqRBPR5WyT36A">
+ <children xmi:id="_hmIF5tovEdqRBPR5WyT36A" type="Stereotype" element="_hmIF4NovEdqRBPR5WyT36A"/>
+ <children xmi:id="_hmIF59ovEdqRBPR5WyT36A" type="Name" element="_hmIF4NovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_hmIF5dovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_hmIF4tovEdqRBPR5WyT36A" routing="Tree" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_hmIF49ovEdqRBPR5WyT36A" points="[26, -31, -110, 148]$[140, -148, 4, 31]"/>
+ </edges>
+ <edges xmi:id="_mu9A4dovEdqRBPR5WyT36A" element="_mu9A4NovEdqRBPR5WyT36A" source="_ikr_4NovEdqRBPR5WyT36A" target="_ePDcYdovEdqRBPR5WyT36A">
+ <children xmi:id="_mu9A5NovEdqRBPR5WyT36A" type="NameLabel" element="_mu9A4NovEdqRBPR5WyT36A">
+ <children xmi:id="_mu9A5tovEdqRBPR5WyT36A" type="Stereotype" element="_mu9A4NovEdqRBPR5WyT36A"/>
+ <children xmi:id="_mu9A59ovEdqRBPR5WyT36A" type="Name" element="_mu9A4NovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_mu9A5dovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_mu9A4tovEdqRBPR5WyT36A" routing="Tree" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_mu9A49ovEdqRBPR5WyT36A" points="[-185, -820, 2937, 3916]$[-185, -3042, 2937, 1694]$[-3255, -3042, -133, 1694]$[-3255, -3916, -133, 820]"/>
+ </edges>
+ <edges xmi:id="_pe3jwNovEdqRBPR5WyT36A" element="_peM1YNovEdqRBPR5WyT36A" source="_fs1pANovEdqRBPR5WyT36A" target="_ePDcYdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jw9ovEdqRBPR5WyT36A" type="NameLabel" element="_peM1YNovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jxdovEdqRBPR5WyT36A" type="Stereotype" element="_peM1YNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_pe3jxtovEdqRBPR5WyT36A" type="Name" element="_peM1YNovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jxNovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pe3jx9ovEdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_peM1YtovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jydovEdqRBPR5WyT36A" type="ToMultiplicity" element="_peM1YtovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jyNovEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pe3jytovEdqRBPR5WyT36A" type="ToRoleLabel" element="_peM1YtovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jzNovEdqRBPR5WyT36A" type="ToRole" element="_peM1YtovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jy9ovEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pe3jzdovEdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_peM1YdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3jz9ovEdqRBPR5WyT36A" type="FromMultiplicity" element="_peM1YdovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3jztovEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pe3j0NovEdqRBPR5WyT36A" type="FromRoleLabel" element="_peM1YdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3j0tovEdqRBPR5WyT36A" type="FromRole" element="_peM1YdovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3j0dovEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pe3j09ovEdqRBPR5WyT36A" type="ToQualifierLabel" element="_peM1YtovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3j1dovEdqRBPR5WyT36A" type="QualifierCompartment" element="_peM1YtovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pe3j1tovEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3j1NovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pe3j19ovEdqRBPR5WyT36A" type="FromQualifierLabel" element="_peM1YdovEdqRBPR5WyT36A">
+ <children xmi:id="_pe3j2dovEdqRBPR5WyT36A" type="QualifierCompartment" element="_peM1YdovEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pe3j2tovEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pe3j2NovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_pe3jwdovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_pe3jwtovEdqRBPR5WyT36A" points="[-317, -820, -3916, 3916]$[-1931, -4762, -5530, -26]$[2382, -4762, -1217, -26]"/>
+ </edges>
+ <edges xmi:id="_xInjYdovEdqRBPR5WyT36A" element="_xInjYNovEdqRBPR5WyT36A" source="_tZF9odovEdqRBPR5WyT36A" target="_fs1pANovEdqRBPR5WyT36A">
+ <children xmi:id="_xInjZNovEdqRBPR5WyT36A" type="NameLabel" element="_xInjYNovEdqRBPR5WyT36A">
+ <children xmi:id="_xInjZtovEdqRBPR5WyT36A" type="Stereotype" element="_xInjYNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_xInjZ9ovEdqRBPR5WyT36A" type="Name" element="_xInjYNovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_xInjZdovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_xInjYtovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_xInjY9ovEdqRBPR5WyT36A" points="[-4, -31, 1, 113]$[-4, -115, 1, 29]"/>
+ </edges>
+ <edges xmi:id="_3Ic-4NovEdqRBPR5WyT36A" element="_3IW4QNovEdqRBPR5WyT36A" source="_1y-ZsNovEdqRBPR5WyT36A" target="_z_m-oNovEdqRBPR5WyT36A">
+ <children xmi:id="_3Ic-49ovEdqRBPR5WyT36A" type="NameLabel" element="_3IW4QNovEdqRBPR5WyT36A">
+ <children xmi:id="_3Ic-5dovEdqRBPR5WyT36A" type="Stereotype" element="_3IW4QNovEdqRBPR5WyT36A"/>
+ <children xmi:id="_3Ic-5tovEdqRBPR5WyT36A" type="Name" element="_3IW4QNovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_3Ic-5NovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_3Ic-4dovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_3Ic-4tovEdqRBPR5WyT36A" points="[6, -24, -37, 154]$[-22, -170, -65, 8]"/>
+ </edges>
+ <edges xmi:id="_9XeF4tovEdqRBPR5WyT36A" element="_9XeF4NovEdqRBPR5WyT36A" source="_4WSrANovEdqRBPR5WyT36A" target="_z_m-oNovEdqRBPR5WyT36A">
+ <children xmi:id="_9XeF5dovEdqRBPR5WyT36A" type="NameLabel" element="_9XeF4NovEdqRBPR5WyT36A">
+ <children xmi:id="_9XeF59ovEdqRBPR5WyT36A" type="Stereotype" element="_9XeF4NovEdqRBPR5WyT36A"/>
+ <children xmi:id="_9XeF6NovEdqRBPR5WyT36A" type="Name" element="_9XeF4NovEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9XeF5tovEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_9XeF49ovEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_9XeF5NovEdqRBPR5WyT36A" points="[-23, -23, 162, 151]$[-121, -170, 64, 4]"/>
+ </edges>
+ <edges xmi:id="_BkUg0dowEdqRBPR5WyT36A" element="_Bj8GUNowEdqRBPR5WyT36A" source="_tZF9odovEdqRBPR5WyT36A" target="_1y-ZsNovEdqRBPR5WyT36A">
+ <children xmi:id="_BkancNowEdqRBPR5WyT36A" type="NameLabel" element="_Bj8GUNowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanctowEdqRBPR5WyT36A" type="Stereotype" element="_Bj8GUNowEdqRBPR5WyT36A"/>
+ <children xmi:id="_Bkanc9owEdqRBPR5WyT36A" type="Name" element="_Bj8GUNowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkancdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_BkandNowEdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <children xmi:id="_BkandtowEdqRBPR5WyT36A" type="ToMultiplicity" element="_Bj8GUtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkanddowEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_Bkand9owEdqRBPR5WyT36A" type="ToRoleLabel" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanedowEdqRBPR5WyT36A" type="ToRole" element="_Bj8GUtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkaneNowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_BkanetowEdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanfNowEdqRBPR5WyT36A" type="FromMultiplicity" element="_Bj8GUdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Bkane9owEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_BkanfdowEdqRBPR5WyT36A" type="FromRoleLabel" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <children xmi:id="_Bkanf9owEdqRBPR5WyT36A" type="FromRole" element="_Bj8GUdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkanftowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_BkangNowEdqRBPR5WyT36A" type="ToQualifierLabel" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <children xmi:id="_BkangtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_Bj8GUtowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Bkang9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkangdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_BkanhNowEdqRBPR5WyT36A" type="FromQualifierLabel" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <children xmi:id="_BkanhtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_Bj8GUdowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Bkanh9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_BkanhdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_BkUg0towEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_BkUg09owEdqRBPR5WyT36A" points="[83, -24, -490, 123]$[486, -151, -87, -4]"/>
+ </edges>
+ <edges xmi:id="_Fd3lQdowEdqRBPR5WyT36A" element="_FdlRYNowEdqRBPR5WyT36A" source="_ePDcYdovEdqRBPR5WyT36A" target="_z_m-oNovEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lRNowEdqRBPR5WyT36A" type="NameLabel" element="_FdlRYNowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lRtowEdqRBPR5WyT36A" type="Stereotype" element="_FdlRYNowEdqRBPR5WyT36A"/>
+ <children xmi:id="_Fd3lR9owEdqRBPR5WyT36A" type="Name" element="_FdlRYNowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lRdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_Fd3lSNowEdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_FdlRYtowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lStowEdqRBPR5WyT36A" type="ToMultiplicity" element="_FdlRYtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lSdowEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_Fd3lS9owEdqRBPR5WyT36A" type="ToRoleLabel" element="_FdlRYtowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lTdowEdqRBPR5WyT36A" type="ToRole" element="_FdlRYtowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lTNowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_Fd3lTtowEdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_FdlRYdowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lUNowEdqRBPR5WyT36A" type="FromMultiplicity" element="_FdlRYdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lT9owEdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_Fd3lUdowEdqRBPR5WyT36A" type="FromRoleLabel" element="_FdlRYdowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lU9owEdqRBPR5WyT36A" type="FromRole" element="_FdlRYdowEdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lUtowEdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_Fd3lVNowEdqRBPR5WyT36A" type="ToQualifierLabel" element="_FdlRYtowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lVtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_FdlRYtowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Fd3lV9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lVdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_Fd3lWNowEdqRBPR5WyT36A" type="FromQualifierLabel" element="_FdlRYdowEdqRBPR5WyT36A">
+ <children xmi:id="_Fd3lWtowEdqRBPR5WyT36A" type="QualifierCompartment" element="_FdlRYdowEdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_Fd3lW9owEdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Fd3lWdowEdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_Fd3lQtowEdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Fd3lQ9owEdqRBPR5WyT36A" points="[46, -11, -369, -9]$[351, -11, -64, -9]"/>
+ </edges>
+ <edges xmi:id="_R5Rjwdo1EdqRBPR5WyT36A" element="_R5RjwNo1EdqRBPR5WyT36A" source="_ePDcYdovEdqRBPR5WyT36A" target="_M0FLkNo1EdqRBPR5WyT36A">
+ <children xmi:id="_R5RjxNo1EdqRBPR5WyT36A" type="NameLabel" element="_R5RjwNo1EdqRBPR5WyT36A">
+ <children xmi:id="_R5Rjxto1EdqRBPR5WyT36A" type="Stereotype" element="_R5RjwNo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_R5Rjx9o1EdqRBPR5WyT36A" type="Name" element="_R5RjwNo1EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_R5Rjxdo1EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_R5Rjwto1EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_R5Rjw9o1EdqRBPR5WyT36A" points="[-2, -31, -2, 91]$[-2, -91, -2, 31]"/>
+ </edges>
+ <edges xmi:id="_V7zlEdo1EdqRBPR5WyT36A" element="_V7zlENo1EdqRBPR5WyT36A" source="_TJHbANo1EdqRBPR5WyT36A" target="_M0FLkNo1EdqRBPR5WyT36A">
+ <children xmi:id="_V7zlFNo1EdqRBPR5WyT36A" type="NameLabel" element="_V7zlENo1EdqRBPR5WyT36A">
+ <children xmi:id="_V7zlFto1EdqRBPR5WyT36A" type="Stereotype" element="_V7zlENo1EdqRBPR5WyT36A"/>
+ <children xmi:id="_V7zlF9o1EdqRBPR5WyT36A" type="Name" element="_V7zlENo1EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_V7zlFdo1EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_V7zlEto1EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_V7zlE9o1EdqRBPR5WyT36A" points="[-73, 0, 339, 0]$[-457, 0, -45, 0]"/>
+ </edges>
+ <edges xmi:id="_cN4xsdo2EdqRBPR5WyT36A" targetEdges="_pdfmkNo2EdqRBPR5WyT36A" element="_cNskcNo2EdqRBPR5WyT36A" source="_z_m-oNovEdqRBPR5WyT36A" target="_TJHbANo1EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xtNo2EdqRBPR5WyT36A" type="NameLabel" element="_cNskcNo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xtto2EdqRBPR5WyT36A" type="Stereotype" element="_cNskcNo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_cN4xt9o2EdqRBPR5WyT36A" type="Name" element="_cNskcNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN4xtdo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_cN4xuNo2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_cNskcto2EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xuto2EdqRBPR5WyT36A" type="ToMultiplicity" element="_cNskcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN4xudo2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_cN4xu9o2EdqRBPR5WyT36A" type="ToRoleLabel" element="_cNskcto2EdqRBPR5WyT36A">
+ <children xmi:id="_cN4xvdo2EdqRBPR5WyT36A" type="ToRole" element="_cNskcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN4xvNo2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_cN_fYNo2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_cNskcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_fYto2EdqRBPR5WyT36A" type="FromMultiplicity" element="_cNskcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fYdo2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_cN_fY9o2EdqRBPR5WyT36A" type="FromRoleLabel" element="_cNskcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_fZdo2EdqRBPR5WyT36A" type="FromRole" element="_cNskcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fZNo2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_cN_fZto2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_cNskcto2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_faNo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_cNskcto2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_cN_fado2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fZ9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_cN_fato2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_cNskcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_cN_fbNo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_cNskcdo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_cN_fbdo2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_cN_fa9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_cN4xsto2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_cN4xs9o2EdqRBPR5WyT36A" points="[-2, -29, 1, 91]$[26, -89, 29, 31]"/>
+ </edges>
+ <edges xmi:id="_pdfmkNo2EdqRBPR5WyT36A" element="_pdHMENo2EdqRBPR5WyT36A" source="_ePDcYdovEdqRBPR5WyT36A" target="_cN4xsdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfml9o2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmmdo2EdqRBPR5WyT36A" type="ToMultiplicity" element="_pdTZUdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmmNo2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pdfmmto2EdqRBPR5WyT36A" type="ToRoleLabel" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmnNo2EdqRBPR5WyT36A" type="ToRole" element="_pdTZUdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmm9o2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pdfmndo2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmn9o2EdqRBPR5WyT36A" type="FromMultiplicity" element="_pdTZUNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmnto2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_pdfmoNo2EdqRBPR5WyT36A" type="FromRoleLabel" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmoto2EdqRBPR5WyT36A" type="FromRole" element="_pdTZUNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmodo2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_pdfmo9o2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmpdo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_pdTZUdo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmpto2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmpNo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pdfmp9o2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmqdo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_pdTZUNo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmqto2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pdfmqNo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_pdfmq9o2EdqRBPR5WyT36A" element="_pdHMENo2EdqRBPR5WyT36A">
+ <children xmi:id="_pdfmrto2EdqRBPR5WyT36A" type="ImageCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <layoutConstraint xmi:type="notation:Size" xmi:id="_pdfmr9o2EdqRBPR5WyT36A" width="1320" height="1320"/>
+ </children>
+ <children xmi:id="_pdfmsNo2EdqRBPR5WyT36A" type="Stereotype" element="_pdHMENo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_pdfmsdo2EdqRBPR5WyT36A" type="Name" element="_pdHMENo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_pdfmsto2EdqRBPR5WyT36A" type="AttributeCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfms9o2EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_pdfmtNo2EdqRBPR5WyT36A" type="OperationCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmtdo2EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_pdfmtto2EdqRBPR5WyT36A" visible="false" type="SignalCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_pdfmt9o2EdqRBPR5WyT36A"/>
+ </children>
+ <children xmi:id="_pdfmuNo2EdqRBPR5WyT36A" visible="false" type="StructureCompartment" element="_pdHMENo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLShapeCompartmentStyle" xmi:id="_pdfmudo2EdqRBPR5WyT36A"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLShapeStyle" xmi:id="_pdfmrNo2EdqRBPR5WyT36A" showStereotype="Label"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_pdfmrdo2EdqRBPR5WyT36A" y="1323"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_pdfmkdo2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_pdfmkto2EdqRBPR5WyT36A" points="[46, 3, -366, 94]$[412, -91, 0, 0]"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_pdrz0No2EdqRBPR5WyT36A" id="100"/>
+ </edges>
+ <edges xmi:id="_9PaR4No2EdqRBPR5WyT36A" element="_9PH-ANo2EdqRBPR5WyT36A" source="_4WSrANovEdqRBPR5WyT36A" target="_o2m3oNo0EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR49o2EdqRBPR5WyT36A" type="NameLabel" element="_9PH-ANo2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR5do2EdqRBPR5WyT36A" type="Stereotype" element="_9PH-ANo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_9PaR5to2EdqRBPR5WyT36A" type="Name" element="_9PH-ANo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR5No2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9PaR59o2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR6do2EdqRBPR5WyT36A" type="ToMultiplicity" element="_9PH-Ato2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR6No2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9PaR6to2EdqRBPR5WyT36A" type="ToRoleLabel" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR7No2EdqRBPR5WyT36A" type="ToRole" element="_9PH-Ato2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR69o2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9PaR7do2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR79o2EdqRBPR5WyT36A" type="FromMultiplicity" element="_9PH-Ado2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR7to2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9PaR8No2EdqRBPR5WyT36A" type="FromRoleLabel" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <children xmi:id="_9PaR8to2EdqRBPR5WyT36A" type="FromRole" element="_9PH-Ado2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PaR8do2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9PgYgNo2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <children xmi:id="_9PgYgto2EdqRBPR5WyT36A" type="QualifierCompartment" element="_9PH-Ato2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9PgYg9o2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PgYgdo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9PgYhNo2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <children xmi:id="_9PgYhto2EdqRBPR5WyT36A" type="QualifierCompartment" element="_9PH-Ado2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9PgYh9o2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9PgYhdo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_9PaR4do2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_9PaR4to2EdqRBPR5WyT36A" points="[12, -24, -94, 162]$[80, -155, -26, 31]"/>
+ </edges>
+ <edges xmi:id="_9-BEUNo2EdqRBPR5WyT36A" element="_99uwcNo2EdqRBPR5WyT36A" source="_1y-ZsNovEdqRBPR5WyT36A" target="_o2m3oNo0EdqRBPR5WyT36A">
+ <children xmi:id="_9-BEU9o2EdqRBPR5WyT36A" type="NameLabel" element="_99uwcNo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK8No2EdqRBPR5WyT36A" type="Stereotype" element="_99uwcNo2EdqRBPR5WyT36A"/>
+ <children xmi:id="_9-HK8do2EdqRBPR5WyT36A" type="Name" element="_99uwcNo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-BEVNo2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9-HK8to2EdqRBPR5WyT36A" type="ToMultiplicityLabel" element="_99uwcto2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK9No2EdqRBPR5WyT36A" type="ToMultiplicity" element="_99uwcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK89o2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9-HK9do2EdqRBPR5WyT36A" type="ToRoleLabel" element="_99uwcto2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK99o2EdqRBPR5WyT36A" type="ToRole" element="_99uwcto2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK9to2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9-HK-No2EdqRBPR5WyT36A" type="FromMultiplicityLabel" element="_99uwcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK-to2EdqRBPR5WyT36A" type="FromMultiplicity" element="_99uwcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK-do2EdqRBPR5WyT36A" y="397"/>
+ </children>
+ <children xmi:id="_9-HK-9o2EdqRBPR5WyT36A" type="FromRoleLabel" element="_99uwcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HK_do2EdqRBPR5WyT36A" type="FromRole" element="_99uwcdo2EdqRBPR5WyT36A"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK_No2EdqRBPR5WyT36A" y="-397"/>
+ </children>
+ <children xmi:id="_9-HK_to2EdqRBPR5WyT36A" type="ToQualifierLabel" element="_99uwcto2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HLANo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_99uwcto2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9-HLAdo2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HK_9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <children xmi:id="_9-HLAto2EdqRBPR5WyT36A" type="FromQualifierLabel" element="_99uwcdo2EdqRBPR5WyT36A">
+ <children xmi:id="_9-HLBNo2EdqRBPR5WyT36A" type="QualifierCompartment" element="_99uwcdo2EdqRBPR5WyT36A">
+ <styles xmi:type="umlnotation:UMLListCompartmentStyle" xmi:id="_9-HLBdo2EdqRBPR5WyT36A"/>
+ </children>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_9-HLA9o2EdqRBPR5WyT36A" y="-185"/>
+ </children>
+ <styles xmi:type="umlnotation:UMLConnectorStyle" xmi:id="_9-BEUdo2EdqRBPR5WyT36A" showStereotype="Text"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_9-BEUto2EdqRBPR5WyT36A" points="[49, -24, -290, 162]$[404, -163, 65, 23]"/>
+ </edges>
+ </contents>
+ </eAnnotations>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S9NovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S9dovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S9tovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_PROFILES/Basic.profile.uml2#_6mFRgK86Edih9-GG5afQ0g"/>
+ <importedProfile href="pathmap://UML2_PROFILES/Basic.profile.uml2#_6mFRgK86Edih9-GG5afQ0g"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S99ovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S-NovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S-dovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_PROFILES/Intermediate.profile.uml2#_Cz7csK87Edih9-GG5afQ0g"/>
+ <importedProfile href="pathmap://UML2_PROFILES/Intermediate.profile.uml2#_Cz7csK87Edih9-GG5afQ0g"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S-tovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S-9ovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S_NovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_PROFILES/Complete.profile.uml2#_M7pTkK87Edih9-GG5afQ0g"/>
+ <importedProfile href="pathmap://UML2_PROFILES/Complete.profile.uml2#_M7pTkK87Edih9-GG5afQ0g"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1S_dovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1S_tovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1S_9ovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_MSL_PROFILES/Default.epx#_a_S3wNWLEdiy4IqP8whjFA?Default"/>
+ <importedProfile href="pathmap://UML2_MSL_PROFILES/Default.epx#_a_S3wNWLEdiy4IqP8whjFA?Default"/>
+ </packageImport>
+ <packageImport xmi:type="uml:ProfileApplication" xmi:id="_al1TANovEdqRBPR5WyT36A">
+ <eAnnotations xmi:id="_al1TAdovEdqRBPR5WyT36A" source="attributes">
+ <details xmi:id="_al1TAtovEdqRBPR5WyT36A" key="version" value="0"/>
+ </eAnnotations>
+ <importedPackage xmi:type="uml:Profile" href="pathmap://UML2_MSL_PROFILES/Deployment.epx#_vjbuwOvHEdiDX5bji0iVSA?Deployment"/>
+ <importedProfile href="pathmap://UML2_MSL_PROFILES/Deployment.epx#_vjbuwOvHEdiDX5bji0iVSA?Deployment"/>
+ </packageImport>
+ <packageImport xmi:id="_al1TA9ovEdqRBPR5WyT36A">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML2_LIBRARIES/UML2PrimitiveTypes.library.uml2#_EfRZoK86EdieaYgxtVWN8Q"/>
+ </packageImport>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_ePDcYNovEdqRBPR5WyT36A" name="Context">
+ <generalization xmi:id="_R5RjwNo1EdqRBPR5WyT36A" general="_Mz_E8No1EdqRBPR5WyT36A"/>
+ <ownedAttribute xmi:id="_FdlRYdowEdqRBPR5WyT36A" name="scopecontext" visibility="private" type="_z_g4ANovEdqRBPR5WyT36A" association="_FdlRYNowEdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_FdlRZNowEdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_FdlRY9owEdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_fsviYNovEdqRBPR5WyT36A" name="CompositeContext">
+ <generalization xmi:id="_hmIF4NovEdqRBPR5WyT36A" general="_ePDcYNovEdqRBPR5WyT36A"/>
+ <ownedAttribute xmi:id="_peM1YdovEdqRBPR5WyT36A" name="context" visibility="private" type="_ePDcYNovEdqRBPR5WyT36A" association="_peM1YNovEdqRBPR5WyT36A" aggregation="composite">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_peM1ZNovEdqRBPR5WyT36A" value="-1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_peM1Y9ovEdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_ikl5QNovEdqRBPR5WyT36A" name="AtomicContext">
+ <generalization xmi:id="_mu9A4NovEdqRBPR5WyT36A" general="_ePDcYNovEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_peM1YNovEdqRBPR5WyT36A" memberEnd="_peM1YdovEdqRBPR5WyT36A _peM1YtovEdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_peM1YtovEdqRBPR5WyT36A" visibility="private" type="_fsviYNovEdqRBPR5WyT36A" association="_peM1YNovEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_tZF9oNovEdqRBPR5WyT36A" name="DeploymentContext">
+ <generalization xmi:id="_xInjYNovEdqRBPR5WyT36A" general="_fsviYNovEdqRBPR5WyT36A"/>
+ <ownedAttribute xmi:id="_Bj8GUdowEdqRBPR5WyT36A" name="modulescopecontext" visibility="private" type="_1yyMcNovEdqRBPR5WyT36A" association="_Bj8GUNowEdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_Bj8GVNowEdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_Bj8GU9owEdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_z_g4ANovEdqRBPR5WyT36A" name="ScopeContext">
+ <ownedAttribute xmi:id="_cNskcdo2EdqRBPR5WyT36A" name="instancewrapper" visibility="private" type="_TI7NwNo1EdqRBPR5WyT36A" association="_cNskcNo2EdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_cNskdNo2EdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_cNskc9o2EdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Class" xmi:id="_1yyMcNovEdqRBPR5WyT36A" name="ModuleScopeContext" clientDependency="_3IW4QNovEdqRBPR5WyT36A">
+ <implementation xmi:id="_3IW4QNovEdqRBPR5WyT36A" client="_1yyMcNovEdqRBPR5WyT36A" supplier="_z_g4ANovEdqRBPR5WyT36A" realizingClassifier="_z_g4ANovEdqRBPR5WyT36A" contract="_z_g4ANovEdqRBPR5WyT36A">
+ <mapping xmi:id="_3IW4QdovEdqRBPR5WyT36A"/>
+ </implementation>
+ <ownedAttribute xmi:id="_99uwcdo2EdqRBPR5WyT36A" name="scoperegistry" visibility="private" type="_o2gxANo0EdqRBPR5WyT36A" association="_99uwcNo2EdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_99uwdNo2EdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_99uwc9o2EdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Class" xmi:id="_4WMkYNovEdqRBPR5WyT36A" name="HTTPSessionScopeContext" clientDependency="_9XeF4NovEdqRBPR5WyT36A">
+ <implementation xmi:id="_9XeF4NovEdqRBPR5WyT36A" client="_4WMkYNovEdqRBPR5WyT36A" supplier="_z_g4ANovEdqRBPR5WyT36A" realizingClassifier="_z_g4ANovEdqRBPR5WyT36A" contract="_z_g4ANovEdqRBPR5WyT36A">
+ <mapping xmi:id="_9XeF4dovEdqRBPR5WyT36A"/>
+ </implementation>
+ <ownedAttribute xmi:id="_9PH-Ado2EdqRBPR5WyT36A" name="scoperegistry" visibility="private" type="_o2gxANo0EdqRBPR5WyT36A" association="_9PH-ANo2EdqRBPR5WyT36A">
+ <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_9PH-BNo2EdqRBPR5WyT36A" value="1"/>
+ <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_9PH-A9o2EdqRBPR5WyT36A"/>
+ </ownedAttribute>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_Bj8GUNowEdqRBPR5WyT36A" memberEnd="_Bj8GUdowEdqRBPR5WyT36A _Bj8GUtowEdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_Bj8GUtowEdqRBPR5WyT36A" visibility="private" type="_tZF9oNovEdqRBPR5WyT36A" association="_Bj8GUNowEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_FdlRYNowEdqRBPR5WyT36A" memberEnd="_FdlRYdowEdqRBPR5WyT36A _FdlRYtowEdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_FdlRYtowEdqRBPR5WyT36A" visibility="private" type="_ePDcYNovEdqRBPR5WyT36A" association="_FdlRYNowEdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_o2gxANo0EdqRBPR5WyT36A" name="ScopeRegistry"/>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_Mz_E8No1EdqRBPR5WyT36A" name="Lifecycle"/>
+ <ownedMember xmi:type="uml:Interface" xmi:id="_TI7NwNo1EdqRBPR5WyT36A" name="InstanceWrapper">
+ <generalization xmi:id="_V7zlENo1EdqRBPR5WyT36A" general="_Mz_E8No1EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_cNskcNo2EdqRBPR5WyT36A" memberEnd="_cNskcdo2EdqRBPR5WyT36A _cNskcto2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_cNskcto2EdqRBPR5WyT36A" visibility="private" type="_z_g4ANovEdqRBPR5WyT36A" association="_cNskcNo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:AssociationClass" xmi:id="_pdHMENo2EdqRBPR5WyT36A" name="AssociationClass1" memberEnd="_pdTZUNo2EdqRBPR5WyT36A _pdTZUdo2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_pdTZUNo2EdqRBPR5WyT36A" visibility="private" type="_cNskcNo2EdqRBPR5WyT36A" association="_pdHMENo2EdqRBPR5WyT36A"/>
+ <ownedEnd xmi:id="_pdTZUdo2EdqRBPR5WyT36A" visibility="private" type="_ePDcYNovEdqRBPR5WyT36A" association="_pdHMENo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_9PH-ANo2EdqRBPR5WyT36A" memberEnd="_9PH-Ado2EdqRBPR5WyT36A _9PH-Ato2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_9PH-Ato2EdqRBPR5WyT36A" visibility="private" type="_4WMkYNovEdqRBPR5WyT36A" association="_9PH-ANo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+ <ownedMember xmi:type="uml:Association" xmi:id="_99uwcNo2EdqRBPR5WyT36A" memberEnd="_99uwcdo2EdqRBPR5WyT36A _99uwcto2EdqRBPR5WyT36A">
+ <ownedEnd xmi:id="_99uwcto2EdqRBPR5WyT36A" visibility="private" type="_1yyMcNovEdqRBPR5WyT36A" association="_99uwcNo2EdqRBPR5WyT36A"/>
+ </ownedMember>
+</uml:Model>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java
new file mode 100644
index 0000000000..e8597a55fc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+/**
+ * Base class providing a simple implementation of Lifecycle.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractLifecycle implements Lifecycle {
+ protected volatile int lifecycleState = UNINITIALIZED;
+
+ public int getLifecycleState() {
+ return lifecycleState;
+ }
+
+ /**
+ * Set the current state of the Lifecycle.
+ *
+ * @param lifecycleState the new state
+ */
+ protected void setLifecycleState(int lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
+
+ public void start() {
+ setLifecycleState(RUNNING);
+ }
+
+ public void stop() {
+ setLifecycleState(STOPPED);
+ }
+
+ /**
+ * Returns the current lifecycle as a String (for example, "RUNNING").
+ *
+ * @return the current lifecycle as a String
+ */
+ public String toString() {
+ switch (lifecycleState) {
+ case Lifecycle.CONFIG_ERROR:
+ return "CONFIG_ERROR";
+ case Lifecycle.ERROR:
+ return "ERROR";
+ case Lifecycle.INITIALIZING:
+ return "INITIALIZING";
+ case Lifecycle.INITIALIZED:
+ return "INITIALIZED";
+ case Lifecycle.RUNNING:
+ return "RUNNING";
+ case Lifecycle.STOPPING:
+ return "STOPPING";
+ case Lifecycle.STOPPED:
+ return "STOPPED";
+ case Lifecycle.UNINITIALIZED:
+ return "UNINITIALIZED";
+ default:
+ return "UNKNOWN";
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java
new file mode 100644
index 0000000000..74a076778e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class CoreRuntimeException extends TuscanyRuntimeException {
+
+ public CoreRuntimeException() {
+ super();
+ }
+
+ public CoreRuntimeException(String message) {
+ super(message);
+ }
+
+ public CoreRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CoreRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java
new file mode 100644
index 0000000000..28bc8652b2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+/**
+ * Denotes an invalid name
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidNameException extends CoreRuntimeException {
+
+ public InvalidNameException() {
+ super();
+ }
+
+ public InvalidNameException(String message) {
+ super(message);
+ }
+
+ public InvalidNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidNameException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java
new file mode 100644
index 0000000000..94e7d2027f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+/**
+ * Implementations adhere to runtime lifecycle semantics
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Lifecycle {
+ /* A configuration error state */
+ int CONFIG_ERROR = -1;
+ /* Has not been initialized */
+ int UNINITIALIZED = 0;
+ /* In the process of being configured and initialized */
+ int INITIALIZING = 1;
+ /* Instantiated and configured */
+ int INITIALIZED = 2;
+ /* Configured and initialized */
+ int RUNNING = 4;
+ /* In the process of being shutdown */
+ int STOPPING = 5;
+ /* Has been shutdown and removed from the module */
+ int STOPPED = 6;
+ /* In an error state */
+ int ERROR = 7;
+
+ /**
+ * Returns the lifecycle state
+ *
+ * @see #UNINITIALIZED
+ * @see #INITIALIZING
+ * @see #INITIALIZED
+ * @see #RUNNING
+ * @see #STOPPING
+ * @see #STOPPED
+ */
+ int getLifecycleState();
+
+ /**
+ * Starts the Lifecycle.
+ *
+ * @throws CoreRuntimeException
+ */
+ void start() throws CoreRuntimeException;
+
+ /**
+ * Stops the Lifecycle.
+ *
+ * @throws CoreRuntimeException
+ */
+ void stop() throws CoreRuntimeException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java
new file mode 100644
index 0000000000..635a5f9090
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ObjectCreationException extends TuscanyRuntimeException {
+ private static final long serialVersionUID = -6423113430265944499L;
+
+ public ObjectCreationException() {
+ super();
+ }
+
+ public ObjectCreationException(String message) {
+ super(message);
+ }
+
+ public ObjectCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java
new file mode 100644
index 0000000000..d505e14f61
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+/**
+ * Implementations create new instances of a particular type
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ObjectFactory<T> {
+
+ /**
+ * Return a instance of the type that this factory creates.
+ *
+ * @return a instance from this factory
+ */
+ T getInstance() throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java
new file mode 100644
index 0000000000..ec1c181afc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+/**
+ * An evaluated name consisting of a part/port pair. In the runtime, a part generally 'contains' or 'provides' ports
+ * such as a component/service point or a component/reference pair.
+ *
+ * @version $Rev$ $Date$
+ */
+public class QualifiedName {
+ public static final String NAME_SEPARATOR = "/";
+
+ private String qName;
+ private String partName;
+ private String portName;
+
+ /**
+ * Constructs a new qualified name in the form of part/port where part is the parent context and port represents a
+ * child, which is either a service in the case of an atomic context or a contained context in the case of a
+ * composite.
+ *
+ * @throws InvalidNameException if the name is in an invalid format
+ */
+ public QualifiedName(String qualifiedName) throws InvalidNameException {
+ if (qualifiedName == null) {
+ return;
+ }
+ int pos = qualifiedName.indexOf(QualifiedName.NAME_SEPARATOR);
+ switch (pos) {
+ case -1:
+ partName = qualifiedName;
+ break;
+ case 0:
+ throw new InvalidNameException(qualifiedName);
+ default:
+ partName = qualifiedName.substring(0, pos);
+ portName = qualifiedName.substring(pos + 1);
+ break;
+ }
+ qName = qualifiedName;
+ }
+
+ /**
+ * Returns the parsed part name
+ */
+ public String getPartName() {
+ return partName;
+ }
+
+ /**
+ * Returns the parsed port name if the original is of the compound for part/port
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ * Returns the full part/port name pair
+ */
+ public String getQualifiedName() {
+ return qName;
+ }
+
+ public String toString() {
+ return qName;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
new file mode 100644
index 0000000000..0e48f1bc1b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * A system annotation to inject an autowired instance
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface Autowire {
+ /**
+ * The name of the autowire. If not specified then the name will be derived from the annotated field.
+ */
+ String name() default "";
+
+ /**
+ * Indicates if a reference must be specified.
+ */
+ boolean required() default true;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java
new file mode 100644
index 0000000000..5fd9be89b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.bootstrap;
+
+/**
+ * Class that defines the names of well known component
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ComponentNames {
+ /**
+ * The name of the component that forms the root of the runtime tree.
+ */
+ public static final String TUSCANY_RUNTIME = "tuscany.runtime";
+
+ /**
+ * The name of the component that forms the root of the application context tree.
+ */
+ public static final String TUSCANY_ROOT = "tuscany.root";
+
+ /**
+ * The name of the component that form the root of the system context tree.
+ */
+ public static final String TUSCANY_SYSTEM = "tuscany.system";
+
+ /**
+ * The name of the component that contains the deployer.
+ */
+ public static final String TUSCANY_DEPLOYER = "tuscany.deployer";
+
+ private ComponentNames() {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java
new file mode 100644
index 0000000000..380abb474b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.bootstrap;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+
+/**
+ * Interface that represents the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeComponent extends CompositeComponent {
+ /**
+ * Returns the component that forms the root of the user component tree. All user components will be managed by
+ * composites that are children of this root.
+ *
+ * @return the root of the user component tree
+ */
+ CompositeComponent getRootComponent();
+
+ /**
+ * Returns the component that forms the root of the system component tree. All system components, components that
+ * provide system services needed by the Tuscany runtime itself, will be managed by composites that are children of
+ * this root.
+ *
+ * @return the root of the system component tree
+ */
+ CompositeComponent getSystemComponent();
+
+ /**
+ * Returns the deployer for this runtime. This interface can be used to deploy new SCA bundles to the runtime.
+ *
+ * @return the deployer for this runtime
+ */
+ Deployer getDeployer();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java
new file mode 100644
index 0000000000..9586cdb6fd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+/**
+ * Responsible for processing a service or reference in an assembly configured with a particular binding. The builder
+ * will create and return corresponding {@link org.apache.tuscany.spi.component.Service} or {@link
+ * org.apache.tuscany.spi.component.Reference}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingBuilder<B extends Binding> {
+ Service build(CompositeComponent parent,
+ BoundServiceDefinition<B> boundServiceDefinition,
+ DeploymentContext deploymentContext);
+
+ Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<B> boundReferenceDefinition,
+ DeploymentContext deploymentContext);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindlessBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindlessBuilder.java
new file mode 100644
index 0000000000..94ddb39a59
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindlessBuilder.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+
+/**
+ * Responsible for processing a service or reference in an assembly configured without any binding. The builder
+ * will create and return corresponding {@link org.apache.tuscany.spi.component.Service} or {@link
+ * org.apache.tuscany.spi.component.Reference}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindlessBuilder {
+
+ Service build(CompositeComponent parent,
+ BindlessServiceDefinition serviceDefinition,
+ DeploymentContext deploymentContext);
+
+ Reference build(CompositeComponent parent,
+ ReferenceDefinition referenceDefinition,
+ DeploymentContext deploymentContext);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java
new file mode 100644
index 0000000000..c1d314297e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+
+/**
+ * Implementations build <code>SCAObject</code> types from model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Builder {
+ /**
+ * Builds a <code>Component</code> context from a <code>ComponentDefinition</code>
+ *
+ * @param parent the composite that will be the parent of the newly built component
+ * @param componentDefinition the component definition as parsed from an SCA assembly
+ * @param deploymentContext the current deployment context
+ * @return a newly created component
+ */
+ <I extends Implementation<?>> Component build(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition,
+ DeploymentContext deploymentContext);
+
+ /**
+ * TODO: JavaDoc this when we know if we will still register Services as contexts
+ */
+ <B extends Binding> SCAObject build(CompositeComponent parent,
+ BoundServiceDefinition<B> boundServiceDefinition,
+ DeploymentContext deploymentContext);
+
+ /**
+ * TODO: JavaDoc this when we know if we will still register References as contexts
+ */
+ <B extends Binding> SCAObject build(CompositeComponent parent,
+ BoundReferenceDefinition<B> boundReferenceDefinition,
+ DeploymentContext deploymentContext);
+
+ /**
+ * TODO: Make sure that this method belongs here
+ * Allow a builder registry to provide building of bindless services via
+ * appropriate registered builder
+ */
+ SCAObject build(CompositeComponent parent,
+ BindlessServiceDefinition serviceDefinition,
+ DeploymentContext deploymentContext);
+
+ /**
+ * TODO: Make sure that this method belongs here
+ * Allow a builder registry to provide building of targetless references via
+ * appropriate registered builder
+ */
+ SCAObject build(CompositeComponent parent,
+ ReferenceDefinition referenceDefinition,
+ DeploymentContext deploymentContext);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java
new file mode 100644
index 0000000000..e4c07e53f9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+/**
+ * Represents an error processing an assembly model
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderConfigException extends BuilderException {
+
+ public BuilderConfigException() {
+ super();
+ }
+
+ public BuilderConfigException(String message) {
+ super(message);
+ }
+
+ public BuilderConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderConfigException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java
new file mode 100644
index 0000000000..6e5e6ab124
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * The root exception for the builder package. Builder exceptions denote a non-recoverable failure.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BuilderException extends CoreRuntimeException {
+
+ public BuilderException() {
+ super();
+ }
+
+ public BuilderException(String message) {
+ super(message);
+ }
+
+ public BuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java
new file mode 100644
index 0000000000..9d75f360d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Maintains a registry of builders in the runtime, dispatching to the appropriate one as an assembly model is processed
+ * into runtime artifacts
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BuilderRegistry extends Builder {
+
+ /**
+ * Register a builder for an implementation type.
+ *
+ * @param implClass the type of implementation that this builder can handle
+ * @param builder the builder to be registered
+ */
+ <I extends Implementation<?>> void register(Class<I> implClass, ComponentBuilder<I> builder);
+
+ /**
+ * Unregister a builder for an implementation type.
+ *
+ * @param implClass the implementation whose builder should be unregistered
+ */
+ <I extends Implementation<?>> void unregister(Class<I> implClass);
+
+ /**
+ * TODO: JavaDoc this once we know if we will be building contexts for bindings
+ */
+ <B extends Binding> void register(BindingBuilder<B> builder);
+
+ /**
+ * TODO: JavaDoc this once we know if we will be building contexts for bindings
+ */
+ <B extends Binding> void register(Class<B> implClass, BindingBuilder<B> builder);
+
+ /**
+ * TODO: Make sure this belongs here
+ */
+ void register(BindlessBuilder builder);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java
new file mode 100644
index 0000000000..ca1e25e8b1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Responsible for building a {@link Component} from an atomic or composite component configured in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentBuilder<I extends Implementation<?>> {
+ Component build(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
new file mode 100644
index 0000000000..07ea5352ff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Implementations are responsible for bridging invocation chains as an assembly is converted to runtime artifacts
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface Connector {
+
+ /**
+ * Connects the given source's wires to corresponding wires to a target. Wires are connected by bridging invocation
+ * chains.
+ *
+ * @param source the source, i.e. a <code>Service</code>, <code>Component</code>, or <code>Reference</code>
+ */
+ void connect(SCAObject source);
+
+ /**
+ * Bridges the invocation chains associated with an inbound and outbound wire.
+ *
+ * @param inbound the wire to bridge from
+ * @param outbound the target wire
+ * @param optimizable if the bridge may be optimized
+ * @throws BuilderConfigException
+ */
+ void connect(InboundWire inbound, OutboundWire outbound, boolean optimizable)
+ throws BuilderConfigException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java
new file mode 100644
index 0000000000..78bb5a5cc8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidServiceInterfaceException extends BuilderConfigException {
+ private final Class<?> interfaceClass;
+
+ public InvalidServiceInterfaceException(String message, Class<?> interfaceClass) {
+ super(message);
+ this.interfaceClass = interfaceClass;
+ }
+
+ public Class<?> getInterfaceClass() {
+ return interfaceClass;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/PostProcessingException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/PostProcessingException.java
new file mode 100644
index 0000000000..6868a7b2d5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/PostProcessingException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+/**
+ * Denotes an error during post-processing of a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class PostProcessingException extends BuilderException {
+ public PostProcessingException() {
+ }
+
+ public PostProcessingException(String message) {
+ super(message);
+ }
+
+ public PostProcessingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PostProcessingException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessor.java
new file mode 100644
index 0000000000..26de89a9f1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessor.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Implementations are called after inbound and outbound wires are decorated with policy and before they are connected.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WirePostProcessor {
+
+ /**
+ * @param source
+ * @param target
+ */
+ void process(OutboundWire source, InboundWire target);
+
+ /**
+ * @param source
+ * @param target
+ */
+ void process(InboundWire source, OutboundWire target);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorExtension.java
new file mode 100644
index 0000000000..0795c5783a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorExtension.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+
+@Scope("MODULE")
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class WirePostProcessorExtension implements WirePostProcessor {
+
+ protected WirePostProcessorRegistry registry;
+
+ @Autowire
+ public void setRegistry(WirePostProcessorRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ registry.register(this);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorRegistry.java
new file mode 100644
index 0000000000..a1750943eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WirePostProcessorRegistry.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+/**
+ * Acts as a delegating <code>WirePostProcessor</code>, delegating post-processing of wires after policies have been
+ * applied and source an targets have been matched but before they are connected.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WirePostProcessorRegistry extends WirePostProcessor {
+
+
+ /**
+ * Registers a post-processor in the runtime
+ *
+ * @param processor the processor to register
+ */
+ void register(WirePostProcessor processor);
+
+ /**
+ * De-registers a post-processor in the runtime
+ *
+ * @param processor the processor to de-register
+ */
+ void unregister(WirePostProcessor processor);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
new file mode 100644
index 0000000000..d7de7c0d6b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.spi.AbstractLifecycle;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.TrueFilter;
+
+/**
+ * Functionality common to all <code>SCAObject<code> implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractSCAObject extends AbstractLifecycle implements SCAObject {
+ protected static final EventFilter TRUE_FILTER = new TrueFilter();
+
+ protected Map<EventFilter, List<RuntimeEventListener>> listeners;
+ protected final CompositeComponent parent;
+ private final String name;
+ private final Map<Object, Object> extensions = new HashMap<Object, Object>();
+
+ public AbstractSCAObject(String name, CompositeComponent parent) {
+ this.name = name;
+ this.parent = parent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public CompositeComponent getParent() {
+ return parent;
+ }
+
+ public void addListener(RuntimeEventListener listener) {
+ addListener(TRUE_FILTER, listener);
+ }
+
+ public void removeListener(RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ for (List<RuntimeEventListener> currentList : getListeners().values()) {
+ for (RuntimeEventListener current : currentList) {
+ if (current == listener) {
+ currentList.remove(current);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ List<RuntimeEventListener> list = getListeners().get(filter);
+ if (list == null) {
+ list = new CopyOnWriteArrayList<RuntimeEventListener>();
+ listeners.put(filter, list);
+ }
+ list.add(listener);
+ }
+ }
+
+ public void publish(Event event) {
+ assert event != null : "Event object was null";
+ for (Map.Entry<EventFilter, List<RuntimeEventListener>> entry : getListeners().entrySet()) {
+ if (entry.getKey().match(event)) {
+ for (RuntimeEventListener listener : entry.getValue()) {
+ listener.onEvent(event);
+ }
+ }
+ }
+ }
+
+ protected Map<EventFilter, List<RuntimeEventListener>> getListeners() {
+ if (listeners == null) {
+ listeners = new ConcurrentHashMap<EventFilter, List<RuntimeEventListener>>();
+ }
+ return listeners;
+ }
+
+ public void prepare() {
+
+ }
+
+ public String toString() {
+ return "[" + name + "] in state [" + super.toString() + ']';
+ }
+
+ public Map<Object, Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isSystem() {
+ return false;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
new file mode 100644
index 0000000000..532debddeb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+
+/**
+ * The runtime instantiation of an SCA atomic, or leaf-type, component
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AtomicComponent extends Component {
+
+ /**
+ * Returns whether component instances should be eagerly initialized
+ */
+ boolean isEagerInit();
+
+ /**
+ * Returns the initialization level for this component.
+ *
+ * @return the initialization level for this component
+ * @see org.apache.tuscany.spi.model.ComponentDefinition#getInitLevel()
+ */
+ int getInitLevel();
+
+ /**
+ * Notifies the given instance of an initialization event
+ *
+ * @throws TargetException
+ */
+ void init(Object instance) throws TargetException;
+
+ /**
+ * Notifies the given instance of a destroy event
+ *
+ * @throws TargetException
+ */
+ void destroy(Object instance) throws TargetException;
+
+ /**
+ * Creates a new implementation instance, generally used as a callback by a {@link
+ * org.apache.tuscany.spi.component.ScopeContainer}
+ *
+ * @throws ObjectCreationException
+ */
+ Object createInstance() throws ObjectCreationException;
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AutowireResolutionException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AutowireResolutionException.java
new file mode 100644
index 0000000000..00e1392a9c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AutowireResolutionException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Denotes an exception while resolving an automatic wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class AutowireResolutionException extends TargetException {
+
+ public AutowireResolutionException() {
+ super();
+ }
+
+ public AutowireResolutionException(String message) {
+ super(message);
+ }
+
+ public AutowireResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AutowireResolutionException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java
new file mode 100644
index 0000000000..2f4453eb41
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The runtime instantiation of an SCA component
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface Component extends SCAObject {
+
+ /**
+ * Returns a service associated with the given name
+ *
+ * @throws TargetException if an error occurs retrieving the service instance
+ */
+ Object getServiceInstance(String name) throws TargetException;
+
+ /**
+ * Returns the service interfaces implemented by the component
+ */
+ List<Class<?>> getServiceInterfaces();
+
+ /**
+ * Adds a target-side wire. Target-side wire factories contain the invocation chains associated with the destination
+ * service of a wire
+ */
+ void addInboundWire(InboundWire wire);
+
+ /**
+ * Returns the target-side wire associated with the given service name
+ */
+ InboundWire getInboundWire(String serviceName);
+
+ /**
+ * Returns a map of inbound wires for a service.
+ */
+ Map<String, InboundWire> getInboundWires();
+
+ /**
+ * Adds a source-side wire for the given reference. Source-side wires contain the invocation chains for a reference
+ * in the implementation associated with the instance wrapper created by this configuration.
+ */
+ void addOutboundWire(OutboundWire wire);
+
+ /**
+ * Adds a set of source-side multiplicity wires for the given reference. Source-side wires contain the invocation
+ * chains for a reference in the implementation associated with the instance wrapper created by this configuration.
+ */
+ void addOutboundWires(Class<?> multiplicityClass, List<OutboundWire> wires);
+
+ /**
+ * Returns a map of source-side wires for references. There may be 1..n wires per reference.
+ */
+ Map<String, List<OutboundWire>> getOutboundWires();
+
+ /**
+ * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to a service offered by
+ * the component
+ *
+ * @param targetName
+ * @param operation the operation to invoke
+ */
+ TargetInvoker createTargetInvoker(String targetName, Operation operation);
+
+ /**
+ * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to a service offered by
+ * the component
+ *
+ * @param operation the operation to invoke
+ */
+ TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentNotFoundException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentNotFoundException.java
new file mode 100644
index 0000000000..a71fe5aeba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentNotFoundException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Thrown when a component cannot be found
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ComponentNotFoundException extends ComponentRuntimeException {
+ public ComponentNotFoundException() {
+ }
+
+ public ComponentNotFoundException(String message) {
+ super(message);
+ }
+
+ public ComponentNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComponentNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java
new file mode 100644
index 0000000000..3b17229bed
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * An unchecked exception encountered by an {@link SCAObject}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentRuntimeException extends CoreRuntimeException {
+
+ public ComponentRuntimeException() {
+ super();
+ }
+
+ public ComponentRuntimeException(String message) {
+ super(message);
+ }
+
+ public ComponentRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComponentRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java
new file mode 100644
index 0000000000..1f847b319a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.List;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+
+/**
+ * The runtime instantiation of an SCA composite component. Composites may contain child components, offer services, and
+ * have references. Children are contained in two namespaces, an application namespace for end-user components deployed
+ * to a runtime, and a system namespace for components that provide system services.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeComponent extends Component, RuntimeEventListener {
+
+ /**
+ * Registers a child of this composite.
+ *
+ * @param context the context to add as a child
+ * @throws InvalidComponentTypeException
+ */
+ void register(SCAObject context) throws InvalidComponentTypeException;
+
+ /**
+ * Register a simple Java Object as a system component. This is primarily intended for use by bootstrap code to
+ * create the initial configuration components.
+ *
+ * @param name the name of the resulting component
+ * @param service the service interface the component should expose
+ * @param instance the Object that will become the component's implementation
+ * @throws ObjectRegistrationException
+ */
+ <S, I extends S> void registerJavaObject(String name, Class<S> service, I instance)
+ throws ObjectRegistrationException;
+
+ /**
+ * Returns the child associated with a given name
+ */
+ SCAObject getChild(String name);
+
+ /**
+ * Returns the system child associated with a given name
+ */
+ SCAObject getSystemChild(String name);
+
+ /**
+ * Returns the children contained by the composite
+ */
+ List<SCAObject> getChildren();
+
+ /**
+ * Returns the system children contained by the composite
+ */
+ List<SCAObject> getSystemChildren();
+
+ /**
+ * Returns the services contained by the composite
+ */
+ List<Service> getServices();
+
+ /**
+ * Returns the system services contained by the composite
+ */
+ List<Service> getSystemServices();
+
+ /**
+ * Returns the service associated with the given name
+ *
+ * @throws ComponentNotFoundException
+ */
+ Service getService(String name) throws ComponentNotFoundException;
+
+ /**
+ * Returns the system service associated with the given name
+ *
+ * @throws ComponentNotFoundException
+ */
+ Service getSystemService(String name) throws ComponentNotFoundException;
+
+ /**
+ * Returns a system service associated with the given name
+ *
+ * @throws TargetException if an error occurs retrieving the service instance
+ */
+ Object getSystemServiceInstance(String name) throws TargetException;
+
+ /**
+ * Returns the references contained by the composite
+ */
+ List<Reference> getReferences();
+
+ /**
+ * Returns the system references contained by the composite
+ */
+ List<Reference> getSystemReferences();
+
+ /**
+ * Returns the service instance for associated with the child registered for the given name
+ */
+ <T> T locateService(Class<T> serviceInterface, String serviceName);
+
+ /**
+ * Returns the system service instance for associated with the child registered for the given name
+ */
+ <T> T locateSystemService(Class<T> serviceInterface, String serviceName);
+
+ /**
+ * @param scopeContainer
+ */
+ void setScopeContainer(ScopeContainer scopeContainer);
+
+ /**
+ * Returns the value of a Property of this composite.
+ *
+ * @param name the name of the Property
+ * @return its value, or null if there is not such property or if it has no defined value
+ */
+ Document getPropertyValue(String name);
+
+ /**
+ * Invoked by child components to return an an autowire target. Resolved targets may be services or components in
+ * the parent or its ancestors, or references in a sibling component
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if none can be found
+ * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire
+ */
+ <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException;
+
+ /**
+ * Invoked by system child components to return an an autowire target. Resolved targets may be system services or
+ * components in the parent or its ancestors, or references in a sibling component
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if none can be found
+ * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire
+ */
+ <T> T resolveSystemInstance(Class<T> instanceInterface) throws AutowireResolutionException;
+
+ /**
+ * Invoked by a parent component to return an autowire target in a child. Resolved targets must be services. For
+ * example, given a parent P and two siblings, A and B, A would request an autowire by invoking {@link
+ * #resolveInstance(Class<T>)} on P, which in turn could invoke the present method on B in order to resolve a
+ * target.
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if none can be found
+ * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire
+ */
+ <T> T resolveExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException;
+
+ /**
+ * Invoked by a parent component to return a system autowire target in a child. Resolved targets must be system
+ * services. For example, given a parent P and two siblings, A and B, A would request an autowire by invoking {@link
+ * #resolveInstance(Class<T>)} on P, which in turn could invoke the present method on B in order to resolve a
+ * target.
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if none can be found
+ * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire
+ */
+ <T> T resolveSystemExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java
new file mode 100644
index 0000000000..f6c71b078b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Denotes an attempt to add an child to a composite component with a name equal to an existing child
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateNameException extends ComponentRuntimeException {
+
+ public DuplicateNameException() {
+ super();
+ }
+
+ public DuplicateNameException(String message) {
+ super(message);
+ }
+
+ public DuplicateNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicateNameException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java
new file mode 100644
index 0000000000..8ed3f68e1f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Thrown when a target for an operation is not of the required type
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class IllegalTargetException extends TargetException {
+ public IllegalTargetException() {
+ }
+
+ public IllegalTargetException(String message) {
+ super(message);
+ }
+
+ public IllegalTargetException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalTargetException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidComponentTypeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidComponentTypeException.java
new file mode 100644
index 0000000000..6ad53f08b0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidComponentTypeException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Thrown when an operation is attempted using the wrong context type
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class InvalidComponentTypeException extends ComponentRuntimeException {
+ public InvalidComponentTypeException() {
+ }
+
+ public InvalidComponentTypeException(String message) {
+ super(message);
+ }
+
+ public InvalidComponentTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidComponentTypeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ObjectRegistrationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ObjectRegistrationException.java
new file mode 100644
index 0000000000..66547e3143
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ObjectRegistrationException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Thrown when an error is encountered registering an object
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ObjectRegistrationException extends ComponentRuntimeException {
+ public ObjectRegistrationException() {
+ }
+
+ public ObjectRegistrationException(String message) {
+ super(message);
+ }
+
+ public ObjectRegistrationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectRegistrationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java
new file mode 100644
index 0000000000..44eb112d56
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+/**
+ * Manages an SCA reference configured with a binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Reference extends SCAObject {
+
+ /**
+ * Returns the service interface configured for the reference
+ */
+ Class<?> getInterface();
+
+ /**
+ * Returns the handler responsible for flowing a request through the reference
+ *
+ * @throws TargetException
+ */
+ WireInvocationHandler getHandler() throws TargetException;
+
+ /**
+ * Returns the inbound wire for flowing a request through the reference
+ */
+ InboundWire getInboundWire();
+
+ /**
+ * Sets the inbound wire for flowing a request through the reference
+ */
+ void setInboundWire(InboundWire wire);
+
+ /**
+ * Returns the outbound wire used by the reference to connect to a target
+ */
+ OutboundWire getOutboundWire();
+
+ /**
+ * Sets the outbound wire used by the reference to connect to a target
+ */
+ void setOutboundWire(OutboundWire wire);
+
+ /**
+ * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to the target service of
+ * the reference
+ *
+ * @param contract the service contract to invoke on
+ * @param operation the operation to invoke
+ */
+ TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation);
+
+ /**
+ * Creates a target invoker for callbacks
+ */
+ TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation);
+
+ /**
+ * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which issues a non-blocking dispatch
+ *
+ * @param wire the outbound wire of the invocation source, used for callbacks
+ * @param operation the operation to invoke
+ */
+ TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation);
+
+ /**
+ * Get the ServiceContract for the binding
+ * @return
+ */
+ ServiceContract<?> getBindingServiceContract();
+
+
+ /**
+ * Set the ServiceContract for the binding. This contract will be used for the outbound wire.
+ * If not set, it will be the same as the ServideContract from the interface.
+ *
+ * @param serviceContract
+ */
+ void setBindingServiceContract(ServiceContract<?> serviceContract);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceNotFoundException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceNotFoundException.java
new file mode 100644
index 0000000000..7020ede3a5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceNotFoundException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Thrown when a component reference is not defined in the compoenent type
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ReferenceNotFoundException extends CoreRuntimeException {
+ private static final long serialVersionUID = 737170534780079573L;
+
+ public ReferenceNotFoundException() {
+ }
+
+ public ReferenceNotFoundException(String message) {
+ super(message);
+ }
+
+ public ReferenceNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ReferenceNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java
new file mode 100644
index 0000000000..3a335a3200
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.Lifecycle;
+import org.apache.tuscany.spi.event.EventPublisher;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * Represents the base SCA artifact type in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCAObject extends EventPublisher, Lifecycle {
+
+ /**
+ * Returns the artifact name
+ */
+ String getName();
+
+ /**
+ * Returns the parent composite, or null if the artifact does not have one
+ */
+ CompositeComponent getParent();
+
+ /**
+ * Returns the artifact scope
+ */
+ Scope getScope();
+
+ /**
+ * Returns an instance associated with the default service
+ *
+ * @throws TargetException if an error occurs retrieving the instance
+ */
+ Object getServiceInstance() throws TargetException;
+
+ /**
+ * Called to signal that the composite should perform and required steps prior to registration with its parent such
+ * as wiring of its children
+ */
+ void prepare();
+
+ /**
+ * The extensions map contains other runtime context such as type systems for various databindings
+ *
+ * @return A live map of extended context
+ */
+ Map<Object, Object> getExtensions();
+
+ /**
+ * Returns true if the artifact is a system artifact
+ *
+ * @return true if the artifact is a system artifact
+ */
+ boolean isSystem();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java
new file mode 100644
index 0000000000..58ac3c6502
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.Lifecycle;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.model.Scope;
+
+
+/**
+ * Manages the lifecycle and visibility of instances associated with a set of {@link AtomicComponent}s.
+ *
+ * @version $Rev$ $Date$
+ * @see SCAObject
+ */
+public interface ScopeContainer extends Lifecycle, RuntimeEventListener {
+
+ /**
+ * Returns the scope value representing the scope context
+ */
+ Scope getScope();
+
+ /**
+ * Sets the work context used by the scope container
+ */
+ void setWorkContext(WorkContext workContext);
+
+ /**
+ * Registers a component with the scope component
+ */
+ void register(AtomicComponent component);
+
+ /**
+ * Returns an instance associated with the current component
+ *
+ * @throws TargetException
+ */
+ Object getInstance(AtomicComponent component) throws TargetException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeNotFoundException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeNotFoundException.java
new file mode 100644
index 0000000000..b42e6afaeb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeNotFoundException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Throw when a scope context cannot be found for a given scope
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ScopeNotFoundException extends ScopeRuntimeException {
+ public ScopeNotFoundException() {
+ }
+
+ public ScopeNotFoundException(String message) {
+ super(message);
+ }
+
+ public ScopeNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ScopeNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java
new file mode 100644
index 0000000000..2f3fe47b72
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * Manages {@link ScopeContainer}s in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface ScopeRegistry {
+
+ ScopeContainer getScopeContainer(Scope scope) throws ScopeNotFoundException;
+
+ <T extends ScopeContainer> void registerFactory(Scope scope, ObjectFactory<T> factory);
+
+ void deregisterFactory(Scope scope);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRuntimeException.java
new file mode 100644
index 0000000000..2724c34ffe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRuntimeException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes a general runtime exception encountered by a scope context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeRuntimeException extends CoreRuntimeException {
+
+ public ScopeRuntimeException() {
+ super();
+ }
+
+ public ScopeRuntimeException(String message) {
+ super(message);
+ }
+
+ public ScopeRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ScopeRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java
new file mode 100644
index 0000000000..b165931ac0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+/**
+ * The runtime instantiation of an SCA service configured with a binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Service extends SCAObject {
+
+ /**
+ * Returns the handler responsible for flowing a request through the service
+ *
+ * @throws TargetException
+ */
+ WireInvocationHandler getHandler() throws TargetException;
+
+ /**
+ * Returns the service interface configured for the service
+ */
+ Class<?> getInterface();
+
+ /**
+ * Returns the inbound wire for flowing a request through the service
+ *
+ * @return the inbound wire for flowing a request through the service
+ */
+ InboundWire getInboundWire();
+
+ /**
+ * Sets the inbound wire for flowing a request through the service
+ *
+ * @param wire the inbound wire for flowing a request through the service
+ */
+ void setInboundWire(InboundWire wire);
+
+ /**
+ * Returns the outbound wire for flowing a request out of the service
+ *
+ * @return the outbound wire for flowing a request out of the service
+ */
+ OutboundWire getOutboundWire();
+
+ /**
+ * Sets the outbound wire for flowing a request out of the service
+ *
+ * @param wire the outbound wire for flowing a request out of the service
+ */
+ void setOutboundWire(OutboundWire wire);
+
+ /**
+ * Returns the target invoker for dispatching callback invocations
+ *
+ * @param contract the callback contract
+ * @param operation the callback operation the target invoker dispatches to
+ */
+ TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation);
+
+ /**
+ * Get the ServiceContract for the binding
+ * @return
+ */
+ ServiceContract<?> getBindingServiceContract();
+
+
+ /**
+ * Set the ServiceContract for the binding. This contract will be used for the inbound wire.
+ * If not set, it will be the same as the ServideContract from the interface.
+
+ * @param serviceContract
+ */
+ void setBindingServiceContract(ServiceContract<?> serviceContract);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SystemAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SystemAtomicComponent.java
new file mode 100644
index 0000000000..2c7376f5fb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SystemAtomicComponent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Implementations are specialized atomic components used to provide system services by the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface SystemAtomicComponent extends AtomicComponent {
+
+ /**
+ * Returns the target instance associated with the component. A target instance is the actual object a request is
+ * dispatched to sans wire chain.
+ *
+ * @throws org.apache.tuscany.spi.component.TargetException
+ *
+ */
+ Object getTargetInstance() throws TargetException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java
new file mode 100644
index 0000000000..3c0bf22dd0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes an error while performing an operation on a target component implementation instance or proxy
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetException extends CoreRuntimeException {
+
+ public TargetException() {
+ super();
+ }
+
+ public TargetException(String message) {
+ super(message);
+ }
+
+ public TargetException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java
new file mode 100644
index 0000000000..1dc67f046d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Thrown when a target of an operation cannot be found
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class TargetNotFoundException extends TargetException {
+ public TargetNotFoundException() {
+ }
+
+ public TargetNotFoundException(String message) {
+ super(message);
+ }
+
+ public TargetNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java
new file mode 100644
index 0000000000..fed65a039b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+/**
+ * Implementations track information associated with a request as it is processed by the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WorkContext {
+
+ Object getCurrentMessageId();
+
+ void setCurrentMessageId(Object messageId);
+
+ Object getCurrentCorrelationId();
+
+ void setCurrentCorrelationId(Object correlationId);
+
+ /**
+ * Returns the composite where a remote request came in
+ */
+ CompositeComponent getRemoteComponent();
+
+ /**
+ * Sets the composite where a remote request came in
+ */
+ void setRemoteComponent(CompositeComponent component);
+
+ /**
+ * Returns the unique key for the given identifier associated with the current request
+ */
+ Object getIdentifier(Object type);
+
+ /**
+ * Sets the unique key for the given identifier associated with the current request
+ */
+ void setIdentifier(Object type, Object identifier);
+
+ /**
+ * Clears the unique key for the given identifier associated with the current request
+ */
+ void clearIdentifier(Object type);
+
+ /**
+ * Clears all identifiers associated with the current request
+ */
+ void clearIdentifiers();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java
new file mode 100644
index 0000000000..2f48aa2292
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * DataBinding represents a data representation, for example, SDO, JAXB and AXIOM
+ */
+public interface DataBinding {
+ /**
+ * The name of a databinding should be case-insensitive and unique
+ *
+ * @return The name of the databinding
+ */
+ String getName();
+
+ /**
+ * Introspect a java class or interface to create a DataType model
+ *
+ * @param javaType The java class or interface to be introspected
+ * @return The DataType or null if the java type is not supported by this databinding
+ */
+ DataType introspect(Class<?> javaType);
+
+ /**
+ * Introspect the data to figure out the corresponding data type
+ *
+ * @param value The object to be checked
+ * @return The DataType or null if the java type is not supported by this databinding
+ */
+ DataType introspect(Object value);
+
+ /**
+ * Provide a WrapperHandler for this databinding
+ * @return A wrapper handler which can handle wrapping/wrapping for this databinding
+ */
+ WrapperHandler getWrapperHandler();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
new file mode 100644
index 0000000000..ba47401cc2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * The registry for data bindings
+ */
+public interface DataBindingRegistry {
+ /**
+ * Register a data binding
+ *
+ * @param dataBinding
+ */
+ void register(DataBinding dataBinding);
+
+ /**
+ * Look up a data binding by id
+ *
+ * @param id The name of the databinding
+ * @return The databinding
+ */
+ DataBinding getDataBinding(String id);
+
+ /**
+ * Unregister a data binding
+ *
+ * @param id
+ * @return The unregistered databinding
+ */
+ DataBinding unregister(String id);
+
+ /**
+ * Introspect the java class to figure out what DataType supports it
+ *
+ * @param javaType The java class or interface
+ * @return A DataType representing the java type or null if no databinding
+ * recognizes the java type
+ */
+ DataType introspectType(Class<?> javaType);
+
+ /**
+ * Introspect the value to figure out the corresponding DataType
+ *
+ * @param value The object value
+ * @return A DataType representing the value or null if no databinding
+ * recognizes the value
+ */
+ DataType introspectType(Object value);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java
new file mode 100755
index 0000000000..a0eb7ac10d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+/**
+ * Data pipe allows a data source pushes data into its sink and pipe the data into its result
+ *
+ * @param <S> The data binding type of the sink
+ * @param <R> The data binding type of the result
+ */
+public interface DataPipe<S, R> extends Transformer {
+
+ /**
+ * Returns a sink (for example, java.io.OutputStream, java.io.Writer or org.xml.sax.ContentHandler) to receive data
+ * pushed by the source
+ *
+ * @return The sink to consume data
+ */
+ S getSink();
+
+ /**
+ * Returns the data populated by the sink
+ *
+ * @return
+ */
+ R getResult();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
new file mode 100755
index 0000000000..ba936b46db
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * This interface will be used as a Tuscany system service to perform data mediations
+ *
+ * Mediate the data from one type to the other one
+ *
+ */
+public interface Mediator {
+
+ /**
+ * Mediate the data from the source type to the target type
+ * @param source The data to be mediated
+ * @param sourceDataType Data type for the source data
+ * @param targetDataType Data type for the target data
+ * @param context
+ * @return
+ */
+ Object mediate(Object source, DataType sourceDataType, DataType targetDataType, Map<Class<?>, Object> context);
+ /**
+ * Mediate the source data into the target which is a sink to receive the data
+ * @param source The data to be mediated
+ * @param target The sink to receive data
+ * @param sourceDataType Data type for the source data
+ * @param targetDataType Data type for the target data
+ */
+ void mediate(
+ Object source,
+ Object target,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map<Class<?>, Object> context);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java
new file mode 100644
index 0000000000..21e8cc2750
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+/**
+ * PullTransformer transforms data from one binding format to the other one which can be directly consumed
+ *
+ * @param <S> The source data type
+ * @param <R> the target data type
+ */
+public interface PullTransformer<S, R> extends Transformer {
+ /**
+ * Transform source data into the result type.
+ *
+ * @param source The source data
+ * @param context The context for the transformation
+ * @return The transformed result
+ */
+ R transform(S source, TransformationContext context);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java
new file mode 100644
index 0000000000..d68b6aa772
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+/**
+ * A transformer that pushes data from its source into the sink
+ *
+ * @param <S>
+ * @param <R>
+ */
+public interface PushTransformer<S, R> extends Transformer {
+ /**
+ * @param source The source data
+ * @param sink The sink to receive the data
+ * @param context
+ */
+ void transform(S source, R sink, TransformationContext context);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java
new file mode 100644
index 0000000000..7c0bf4d01a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding;
+
+import org.apache.tuscany.spi.idl.TypeInfo;
+
+/**
+ * Type Mapper between XML schema simple data types and java objects
+ */
+public interface SimpleTypeMapper {
+ /**
+ * Parse the XML lexical representation into a java object
+ * @param simpleType The XSD simple type
+ * @param value the XML lexical representation
+ * @param context The context of the transformation
+ * @return A java object for the XML value
+ */
+ Object toJavaObject(TypeInfo simpleType, String value, TransformationContext context);
+ /**
+ * Create the XML lexical representation for a java object
+ * @param simpleType The XSD simple type
+ * @param obj The java object
+ * @param context The context of the transformation
+ * @return The XML lexical representation
+ */
+ String toXMLLiteral(TypeInfo simpleType, Object obj, TransformationContext context);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java
new file mode 100755
index 0000000000..8287de1707
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * Context for data transformation
+ *
+ */
+public interface TransformationContext {
+ /**
+ * Get the source data type
+ *
+ * @return
+ */
+ DataType getSourceDataType();
+
+ /**
+ * Get the target data type
+ *
+ * @return
+ */
+ DataType getTargetDataType();
+
+ /**
+ * Set the source data type
+ *
+ * @param sourceDataType
+ */
+ void setSourceDataType(DataType sourceDataType);
+
+ /**
+ * Set the target data type
+ *
+ * @param targetDataType
+ */
+ void setTargetDataType(DataType targetDataType);
+
+ /**
+ * Get the classloader
+ *
+ * @return
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Get a map of metadata
+ *
+ * @return
+ */
+ Map<Class<?>, Object> getMetadata();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java
new file mode 100755
index 0000000000..9b57e1cf70
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Reports problems during data transformation
+ */
+public class TransformationException extends TuscanyRuntimeException {
+
+ private static final long serialVersionUID = 7662385613693006428L;
+
+ public TransformationException() {
+ super();
+ }
+
+ public TransformationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TransformationException(String message) {
+ super(message);
+ }
+
+ public TransformationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java
new file mode 100755
index 0000000000..2f969e979d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+/**
+ * A transformer provides the data transformation from source type to target type. The cost of the transformation is
+ * modeled as weight.
+ */
+public interface Transformer {
+ /**
+ * Get the source type that this transformer transforms data from. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
+ * @return A key indentifying the source type
+ */
+ String getSourceDataBinding();
+
+ /**
+ * Get the target type that this transformer transforms data into. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
+ * @return A key indentifying the target type
+ */
+ String getTargetDataBinding();
+
+ /**
+ * Get the cost of the transformation. The weight can be used to choose the most efficient path if there are more
+ * than one available from the source to the target.
+ *
+ * @return An integer representing the cost of the transformation
+ */
+ int getWeight();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
new file mode 100755
index 0000000000..5381dfa081
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import java.util.List;
+
+/**
+ * Registry for data transformers
+ */
+public interface TransformerRegistry {
+ /**
+ * Register a transformer
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @param weight
+ * @param transformer
+ */
+ void registerTransformer(String sourceDataBinding,
+ String targetDataBinding,
+ int weight,
+ Transformer transformer);
+
+ /**
+ * Register a transformer
+ *
+ * @param transformer
+ */
+ void registerTransformer(Transformer transformer);
+
+ /**
+ * Unregister a transformer
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ boolean unregisterTransformer(String sourceDataBinding, String targetDataBinding);
+
+ /**
+ * Get the direct Transformer which can transform data from source type to
+ * result type
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ Transformer getTransformer(String sourceDataBinding, String targetDataBinding);
+
+ /**
+ * Get the a chain of Transformers which can transform data from source type
+ * to result type
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ List<Transformer> getTransformerChain(String sourceDataBinding, String targetDataBinding);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java
new file mode 100644
index 0000000000..e60cb2af92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding;
+
+import org.apache.tuscany.spi.idl.ElementInfo;
+
+/**
+ * A contract for transformers to deal with wrapping/unwrapping for WSDL wrapper style operations
+ */
+public interface WrapperHandler<T> {
+ /**
+ * Create a wrapper element
+ *
+ * @param element The XSD element
+ * @param context The transformation context
+ * @return An object representing the wrapper element
+ */
+ T create(ElementInfo element, TransformationContext context);
+
+ /**
+ * Set child element for the wrapper
+ *
+ * @param wrapper The wrapper
+ * @param i The index
+ * @param childElement The XSD element
+ * @param value The value of the child
+ */
+ void setChild(T wrapper, int i, ElementInfo childElement, Object value);
+
+ /**
+ * Get child element from the wrapper
+ *
+ * @param wrapper The wrapper
+ * @param i The index
+ * @param element The XSD element
+ * @return The value of the child
+ */
+ Object getChild(T wrapper, int i, ElementInfo element);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java
new file mode 100644
index 0000000000..2b927b8e55
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Helper for DOM
+ */
+public final class DOMHelper {
+ private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();
+ static {
+ FACTORY.setNamespaceAware(true);
+ }
+
+ private DOMHelper() {
+ }
+
+ public static Document newDocument() throws ParserConfigurationException {
+ return newDocumentBuilder().newDocument();
+ }
+
+ public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
+ return FACTORY.newDocumentBuilder();
+ }
+
+ public static QName getQName(Node node) {
+ String ns = node.getNamespaceURI();
+ if (ns == null) {
+ ns = "";
+ }
+ // node.getLocalName() will return null if it is created using DOM Level
+ // 1 method
+ // such as createElement()
+ return new QName(ns, node.getNodeName());
+ }
+
+ public static Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname =
+ (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name
+ .getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
new file mode 100644
index 0000000000..e40b75de55
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Base Implementation of DataBinding
+ */
+@Scope("MODULE")
+@Service(DataBinding.class)
+public abstract class DataBindingExtension implements DataBinding {
+ protected DataBindingRegistry registry;
+
+ protected Class<?> baseType;
+
+ protected String name;
+
+ /**
+ * Create a databinding with the base java type whose name will be used as
+ * the name of the databinding
+ *
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected DataBindingExtension(Class<?> baseType) {
+ this(baseType.getName(), baseType);
+ }
+
+ /**
+ * Create a databinding with the name and base java type
+ *
+ * @param name The name of the databinding
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected DataBindingExtension(String name, Class<?> baseType) {
+ this.name = name;
+ this.baseType = baseType;
+ }
+
+ @Autowire
+ public void setDataBindingRegistry(DataBindingRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ registry.register(this);
+ }
+
+ public DataType introspect(Class<?> javaType) {
+ if (baseType == null || javaType == null) {
+ return null;
+ }
+ if (baseType.isAssignableFrom(javaType)) {
+ return new DataType<Class>(name, javaType, baseType);
+ } else {
+ return null;
+ }
+ }
+
+ public DataType introspect(Object value) {
+ if (value == null) {
+ return null;
+ } else {
+ return introspect(value.getClass());
+ }
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.DataBinding#getWrapperHandler()
+ */
+ public WrapperHandler getWrapperHandler() {
+ return null;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java
new file mode 100644
index 0000000000..4605f945e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.TypeInfo;
+
+/**
+ * Transformer to convert data from a simple java object to a databinding's representation
+ */
+public abstract class Java2SimpleTypeTransformer<T> extends TransformerExtension<Object, T> implements
+ PullTransformer<Object, T> {
+
+ protected SimpleTypeMapper mapper;
+
+ public Java2SimpleTypeTransformer() {
+ this.mapper = new SimpleTypeMapperExtension();
+ }
+
+ public Java2SimpleTypeTransformer(SimpleTypeMapper mapper) {
+ this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension();
+ }
+
+ public T transform(Object source, TransformationContext context) {
+ ElementInfo element =
+ (ElementInfo) context.getTargetDataType().getMetadata(ElementInfo.class.getName());
+ TypeInfo simpleType = (TypeInfo) element.getType();
+ String text = mapper.toXMLLiteral(simpleType, source, context);
+ return createElement(element, text, context);
+ }
+
+ public Class getSourceType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ return 10000;
+ }
+
+ protected abstract T createElement(ElementInfo element, String literal, TransformationContext context);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java
new file mode 100644
index 0000000000..d861bdce92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.TypeInfo;
+
+/**
+ * Transformer to convert data from a databinding's representation of simple
+ * types to Java Objects
+ */
+public abstract class SimpleType2JavaTransformer<T> extends TransformerExtension<T, Object> implements
+ PullTransformer<T, Object> {
+
+ protected SimpleTypeMapper mapper;
+
+ public SimpleType2JavaTransformer() {
+ this.mapper = new SimpleTypeMapperExtension();
+ }
+
+ public SimpleType2JavaTransformer(SimpleTypeMapper mapper) {
+ this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension();
+ }
+
+ public Object transform(T source, TransformationContext context) {
+ TypeInfo simpleType = (TypeInfo)context.getSourceDataType().getMetadata(TypeInfo.class.getName());
+ if (simpleType == null) {
+ ElementInfo element =
+ (ElementInfo)context.getSourceDataType().getMetadata(ElementInfo.class.getName());
+ simpleType = (TypeInfo)element.getType();
+ }
+ return mapper.toJavaObject(simpleType, getText(source), context);
+ }
+
+ public Class getTargetType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ // Cannot be used for imtermediate
+ return 10000;
+ }
+
+ /**
+ * Get the string value from the source
+ * @param source
+ * @return A string
+ */
+ protected abstract String getText(T source);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
new file mode 100644
index 0000000000..40dca934d5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.TypeInfo;
+
+public class SimpleTypeMapperExtension extends XSDDataTypeConverter implements SimpleTypeMapper {
+ public static final Map<Class, String> JAVA2XML = new HashMap<Class, String>();
+
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+
+ public static final Map<String, Class> XML2JAVA = new HashMap<String, Class>();
+
+ public static final QName XSD_ANY = new QName(URI_2001_SCHEMA_XSD, "any");
+
+ public static final QName XSD_ANYSIMPLETYPE = new QName(URI_2001_SCHEMA_XSD, "anySimpleType");
+
+ public static final QName XSD_ANYTYPE = new QName(URI_2001_SCHEMA_XSD, "anyType");
+
+ public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
+
+ public static final QName XSD_BASE64 = new QName(URI_2001_SCHEMA_XSD, "base64Binary");
+
+ public static final QName XSD_BOOLEAN = new QName(URI_2001_SCHEMA_XSD, "boolean");
+
+ public static final QName XSD_BYTE = new QName(URI_2001_SCHEMA_XSD, "byte");
+
+ public static final QName XSD_DATE = new QName(URI_2001_SCHEMA_XSD, "date");
+
+ public static final QName XSD_DATETIME = new QName(URI_2001_SCHEMA_XSD, "dateTime");
+
+ public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
+
+ public static final QName XSD_DECIMAL = new QName(URI_2001_SCHEMA_XSD, "decimal");
+
+ public static final QName XSD_DOUBLE = new QName(URI_2001_SCHEMA_XSD, "double");
+
+ public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
+
+ public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
+
+ public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
+
+ public static final QName XSD_FLOAT = new QName(URI_2001_SCHEMA_XSD, "float");
+
+ public static final QName XSD_HEXBIN = new QName(URI_2001_SCHEMA_XSD, "hexBinary");
+
+ public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
+
+ public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
+
+ public static final QName XSD_INT = new QName(URI_2001_SCHEMA_XSD, "int");
+
+ public static final QName XSD_INTEGER = new QName(URI_2001_SCHEMA_XSD, "integer");
+
+ public static final QName XSD_LONG = new QName(URI_2001_SCHEMA_XSD, "long");
+
+ public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
+
+ public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
+
+ public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
+
+ public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
+
+ public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
+
+ public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
+
+ public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS");
+
+ public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
+
+ public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
+
+ public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
+
+ public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION");
+
+ public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
+
+ public static final QName XSD_QNAME = new QName(URI_2001_SCHEMA_XSD, "QName");
+
+ public static final QName XSD_SHORT = new QName(URI_2001_SCHEMA_XSD, "short");
+
+ public static final Map<String, TypeInfo> XSD_SIMPLE_TYPES = new HashMap<String, TypeInfo>();
+
+ public static final QName XSD_STRING = new QName(URI_2001_SCHEMA_XSD, "string");
+
+ public static final QName XSD_TIME = new QName(URI_2001_SCHEMA_XSD, "time");
+
+ public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
+
+ public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
+
+ public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
+
+ public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
+
+ public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
+
+ public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
+
+ public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
+
+ private static final String[] XSD_TYPE_NAMES =
+ {"string", "boolean", "double", "float", "int", "integer", "long", "short", "byte", "decimal",
+ "base64Binary", "hexBinary", "anySimpleType", "anyType", "any", "QName", "dateTime", "date", "time",
+ "normalizedString", "token", "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte",
+ "positiveInteger", "negativeInteger", "nonNegativeInteger", "nonPositiveInteger", "gYearMonth",
+ "gMonthDay", "gYear", "gMonth", "gDay", "duration", "Name", "NCName", "NMTOKEN", "NMTOKENS",
+ "NOTATION", "ENTITY", "ENTITIES", "IDREF", "IDREFS", "anyURI", "language", "ID"};
+
+ static {
+ for (String type : XSD_TYPE_NAMES) {
+ TypeInfo simpleType = new TypeInfo(new QName(URI_2001_SCHEMA_XSD, type), true, null);
+ XSD_SIMPLE_TYPES.put(type, simpleType);
+ }
+ }
+
+ static {
+ JAVA2XML.put(boolean.class, "boolean");
+ JAVA2XML.put(byte.class, "byte");
+ JAVA2XML.put(short.class, "short");
+ JAVA2XML.put(int.class, "int");
+ JAVA2XML.put(long.class, "long");
+ JAVA2XML.put(float.class, "float");
+ JAVA2XML.put(double.class, "double");
+ JAVA2XML.put(Boolean.class, "boolean");
+ JAVA2XML.put(Byte.class, "byte");
+ JAVA2XML.put(Short.class, "short");
+ JAVA2XML.put(Integer.class, "int");
+ JAVA2XML.put(Long.class, "long");
+ JAVA2XML.put(Float.class, "float");
+ JAVA2XML.put(Double.class, "double");
+ JAVA2XML.put(java.lang.String.class, "string");
+ JAVA2XML.put(java.math.BigInteger.class, "integer");
+ JAVA2XML.put(java.math.BigDecimal.class, "decimal");
+ JAVA2XML.put(java.util.Calendar.class, "dateTime");
+ JAVA2XML.put(java.util.Date.class, "dateTime");
+ JAVA2XML.put(javax.xml.namespace.QName.class, "QName");
+ JAVA2XML.put(java.net.URI.class, "string");
+ JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, "anySimpleType");
+ JAVA2XML.put(javax.xml.datatype.Duration.class, "duration");
+ JAVA2XML.put(java.lang.Object.class, "anyType");
+ JAVA2XML.put(java.awt.Image.class, "base64Binary");
+ JAVA2XML.put(byte[].class, "base64Binary");
+ // java2XSD.put(javax.activation.DataHandler.class, "base64Binary");
+ JAVA2XML.put(javax.xml.transform.Source.class, "base64Binary");
+ JAVA2XML.put(java.util.UUID.class, "string");
+ }
+
+ static {
+ XML2JAVA.put("string", java.lang.String.class);
+ XML2JAVA.put("integer", java.math.BigInteger.class);
+ XML2JAVA.put("int", int.class);
+ XML2JAVA.put("long", long.class);
+ XML2JAVA.put("short", short.class);
+ XML2JAVA.put("decimal", java.math.BigDecimal.class);
+ XML2JAVA.put("float", float.class);
+ XML2JAVA.put("double", double.class);
+ XML2JAVA.put("boolean", boolean.class);
+ XML2JAVA.put("byte", byte.class);
+ XML2JAVA.put("QName", javax.xml.namespace.QName.class);
+ XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("base64Binary", byte[].class);
+ XML2JAVA.put("hexBinary", byte[].class);
+ XML2JAVA.put("unsignedInt", long.class);
+ XML2JAVA.put("unsignedShort", int.class);
+ XML2JAVA.put("unsignedByte", short.class);
+ XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements
+ // XML2JAVA.put("anySimpleType", java.lang.String.class); // For
+ // attributes
+ XML2JAVA.put("duration", javax.xml.datatype.Duration.class);
+ XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
+ }
+
+ private DatatypeFactory factory;
+
+ public SimpleTypeMapperExtension() {
+ super();
+ try {
+ this.factory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Class getJavaType(TypeInfo xmlType) {
+ TypeInfo baseType = xmlType;
+ while (baseType.getBaseType() != null) {
+ baseType = baseType.getBaseType();
+ }
+ return XML2JAVA.get(baseType.getQName().getLocalPart());
+ }
+
+ public TypeInfo getXMLType(Class javaType) {
+ return XSD_SIMPLE_TYPES.get(JAVA2XML.get(javaType));
+ }
+
+ public Object toJavaObject(TypeInfo simpleType, String literal, TransformationContext context) {
+ /**
+ * <ul>
+ * <li>xsd:string --- java.lang.String
+ * <li>xsd:integer --- java.math.BigInteger
+ * <li>xsd:int --- int
+ * <li>xsd:long --- long
+ * <li>xsd:short --- short
+ * <li>xsd:decimal --- java.math.BigDecimal
+ * <li>xsd:float --- float
+ * <li>xsd:double --- double
+ * <li>xsd:boolean --- boolean
+ * <li>xsd:byte --- byte
+ * <li>xsd:QName --- javax.xml.namespace.QName
+ * <li>xsd:dateTime --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:base64Binary --- byte[]
+ * <li>xsd:hexBinary --- byte[]
+ * <li>xsd:unsignedInt --- long
+ * <li>xsd:unsignedShort --- int
+ * <li>xsd:unsignedByte --- short
+ * <li>xsd:time --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:date --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:g* --- javax.xml.datatype.XMLGregorianCalendar
+ * <li>xsd:anySimpleType (for xsd:element of this type)a
+ * java.lang.Object
+ * <li>xsd:anySimpleType (for xsd:attribute of this type)
+ * java.lang.String
+ * <li>xsd:duration javax.xml.datatype.Duration
+ * <li>xsd:NOTATION javax.xml.namespace.QName
+ * </ul>
+ */
+
+ if (literal == null) {
+ return null;
+ }
+ String value = literal.trim();
+ if (!simpleType.isSimpleType()) {
+ throw new IllegalArgumentException("Complex type is not supported for simple java databinding.");
+ }
+ TypeInfo baseType = simpleType;
+ while (baseType.getBaseType() != null) {
+ baseType = (TypeInfo)baseType.getBaseType();
+ }
+
+ QName type = baseType.getQName();
+ if (type.equals(XSD_STRING)) {
+ return parseString(value);
+ } else if (type.equals(XSD_INT)) {
+ return parseInt(value);
+ } else if (type.equals(XSD_INTEGER)) {
+ return parseInteger(value);
+ } else if (type.equals(XSD_INT)) {
+ return parseInt(value);
+ } else if (type.equals(XSD_FLOAT)) {
+ return parseFloat(value);
+ } else if (type.equals(XSD_DOUBLE)) {
+ return parseDouble(value);
+ } else if (type.equals(XSD_SHORT)) {
+ return parseShort(value);
+ } else if (type.equals(XSD_DECIMAL)) {
+ return parseDecimal(value);
+ } else if (type.equals(XSD_BOOLEAN)) {
+ return parseBoolean(value);
+ } else if (type.equals(XSD_BYTE)) {
+ return parseByte(value);
+ } else if (type.equals(XSD_LONG)) {
+ return parseLong(value);
+ } else if (type.equals(XSD_UNSIGNEDBYTE)) {
+ return parseUnsignedShort(value);
+ } else if (type.equals(XSD_UNSIGNEDSHORT)) {
+ return parseUnsignedShort(value);
+ } else if (type.equals(XSD_UNSIGNEDINT)) {
+ return parseUnsignedInt(value);
+ } else if (type.equals(XSD_UNSIGNEDLONG)) {
+ return parseUnsignedInt(value);
+ } else if (type.equals(XSD_DATETIME)) {
+ return parseDateTime(value);
+ } else if (type.equals(XSD_DATE)) {
+ return parseDate(value);
+ } else if (type.equals(XSD_TIME)) {
+ return parseTime(value);
+ } else if (type.equals(XSD_DURATION)) {
+ return parseDuration(value);
+ } else if (type.equals(XSD_HEXBIN)) {
+ return parseHexBinary(value);
+ } else if (type.equals(XSD_BASE64)) {
+ return parseBase64Binary(value);
+ } else if (type.equals(XSD_QNAME)) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class)
+ : null);
+ return parseQName(value, namespaceContext);
+ } else if (type.equals(XSD_NOTATION)) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class)
+ : null);
+ return parseQName(value, namespaceContext);
+ } else if (type.equals(XSD_YEAR)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_MONTH)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_DAY)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_YEARMONTH)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_MONTHDAY)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else {
+ return value;
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
+ GregorianCalendar c =
+ new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), date.getHours(), date
+ .getMinutes(), date.getSeconds());
+ return factory.newXMLGregorianCalendar(c);
+ }
+
+ private XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) {
+ return factory.newXMLGregorianCalendar(calendar);
+ }
+
+ public String toXMLLiteral(TypeInfo simpleType, Object obj, TransformationContext context) {
+ if (obj instanceof Float || obj instanceof Double) {
+ if (obj instanceof Float) {
+ return printDouble(((Float)obj).floatValue());
+ } else {
+ return printDouble(((Double)obj).doubleValue());
+ }
+ } else if (obj instanceof GregorianCalendar) {
+ GregorianCalendar calendar = (GregorianCalendar)obj;
+ return toXMLGregorianCalendar(calendar).toXMLFormat();
+ } else if (obj instanceof Date) {
+ return toXMLGregorianCalendar((Date)obj).toXMLFormat();
+ } else if (obj instanceof XMLGregorianCalendar) {
+ return ((XMLGregorianCalendar)obj).toXMLFormat();
+ } else if (obj instanceof byte[]) {
+ if (simpleType.getQName().equals(XSD_BASE64)) {
+ return printBase64Binary((byte[])obj);
+ } else if (simpleType.getQName().equals(XSD_HEXBIN)) {
+ return printHexBinary((byte[])obj);
+ }
+ } else if (obj instanceof QName) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class)
+ : null);
+ return printQName((QName)obj, namespaceContext);
+ }
+ return obj.toString();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java
new file mode 100644
index 0000000000..d4f2cef9a2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Base Implementation of Transformer which provides the registration to the transformer registry
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+@Service(Transformer.class)
+public abstract class TransformerExtension<S, T> implements Transformer {
+
+ protected TransformerRegistry registry;
+
+ protected TransformerExtension() {
+ super();
+ }
+
+ @Autowire
+ public void setTransformerRegistry(TransformerRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ registry.registerTransformer(this);
+ }
+
+ protected abstract Class getSourceType();
+ protected abstract Class getTargetType();
+
+ public String getSourceDataBinding() {
+ return getSourceType().getName();
+ }
+
+ public String getTargetDataBinding() {
+ return getTargetType().getName();
+ }
+
+ public int getWeight() {
+ // default to 50
+ return 50;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
new file mode 100644
index 0000000000..6e7cc8808f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
@@ -0,0 +1,940 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+import java.util.Calendar;
+import java.util.TimeZone;
+import javax.xml.XMLConstants;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * Utility class for XSD data type conversions
+ */
+public class XSDDataTypeConverter {
+ public static final class Base64Binary {
+ private static final char[] S_BASE64CHAR =
+ {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4',
+ '5', '6', '7', '8', '9', '+', '/'};
+
+ private static final char S_BASE64PAD = '=';
+
+ private static final byte[] S_DECODETABLE = new byte[128];
+
+ static {
+ for (int i = 0; i < S_DECODETABLE.length; i++) {
+ S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
+ }
+ for (int i = 0; i < S_BASE64CHAR.length; i++) {
+ // 0 to 63
+ S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
+ }
+ }
+
+ private Base64Binary() {
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(char[] data, int off, int len) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[len / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(String data) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[data.length() / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(String data, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ private static int decode0(char[] ibuf, byte[] obuf, int index) {
+ int wp = index;
+ int outlen = 3;
+ if (ibuf[3] == S_BASE64PAD) {
+ outlen = 2;
+ }
+ if (ibuf[2] == S_BASE64PAD) {
+ outlen = 1;
+ }
+ int b0 = S_DECODETABLE[ibuf[0]];
+ int b1 = S_DECODETABLE[ibuf[1]];
+ int b2 = S_DECODETABLE[ibuf[2]];
+ int b3 = S_DECODETABLE[ibuf[3]];
+ switch (outlen) {
+ case 1:
+ obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ return 1;
+ case 2:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ return 2;
+ case 3:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
+ return 3;
+ default:
+ throw new IllegalArgumentException("The character sequence is not base64 encoded.");
+ }
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data) {
+ return encode(data, 0, data.length);
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data, int off, int len) {
+ if (len <= 0) {
+ return "";
+ }
+ char[] out = new char[len / 3 * 4 + 4];
+ int rindex = off;
+ int windex = 0;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 18];
+ out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[windex++] = S_BASE64CHAR[i & 0x3f];
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[windex++] = S_BASE64CHAR[i >> 2];
+ out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ out[windex++] = S_BASE64PAD;
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 10];
+ out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ }
+ return new String(out, 0, windex);
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a byte stream.
+ */
+ public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ byte[] out = new byte[4];
+ int rindex = off;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 18];
+ out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = (byte) S_BASE64CHAR[i & 0x3f];
+ ostream.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = (byte) S_BASE64CHAR[i >> 2];
+ out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = (byte) S_BASE64PAD;
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 10];
+ out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ }
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a character stream.
+ */
+ public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ char[] out = new char[4];
+ int rindex = off;
+ int rest = len - off;
+ int output = 0;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 18];
+ out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = S_BASE64CHAR[i & 0x3f];
+ writer.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ output += 4;
+ if (output % 76 == 0) {
+ writer.write("\n");
+ }
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = S_BASE64CHAR[i >> 2];
+ out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = S_BASE64PAD;
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 10];
+ out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ }
+ }
+ }
+
+ /**
+ * <p/>
+ * Utility class for xs:hexbinary. </p>
+ */
+ public static final class HexBinary {
+ private HexBinary() {
+ }
+
+ /**
+ * Converts the string <code>pValue</code> into an array of hex bytes.
+ */
+ public static byte[] decode(String pValue) {
+ if ((pValue.length() % 2) != 0) {
+ throw new IllegalArgumentException("A HexBinary string must have even length.");
+ }
+ byte[] result = new byte[pValue.length() / 2];
+ int j = 0;
+ int i = 0;
+ while (i < pValue.length()) {
+ byte b;
+ char c = pValue.charAt(i++);
+ char d = pValue.charAt(i++);
+ if (c >= '0' && c <= '9') {
+ b = (byte) ((c - '0') << 4);
+ } else if (c >= 'A' && c <= 'F') {
+ b = (byte) ((c - 'A' + 10) << 4);
+ } else if (c >= 'a' && c <= 'f') {
+ b = (byte) ((c - 'a' + 10) << 4);
+ } else {
+ throw new IllegalArgumentException("Invalid hex digit: " + c);
+ }
+ if (d >= '0' && d <= '9') {
+ b += (byte) (d - '0');
+ } else if (d >= 'A' && d <= 'F') {
+ b += (byte) (d - 'A' + 10);
+ } else if (d >= 'a' && d <= 'f') {
+ b += (byte) (d - 'a' + 10);
+ } else {
+ throw new IllegalArgumentException("Invalid hex digit: " + d);
+ }
+ result[j++] = b;
+ }
+ return result;
+ }
+
+ /**
+ * Converts the byte array <code>pHexBinary</code> into a string.
+ */
+ public static String encode(byte[] pHexBinary) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < pHexBinary.length; i++) {
+ byte b = pHexBinary[i];
+ byte c = (byte) ((b & 0xf0) >> 4);
+ if (c <= 9) {
+ result.append((char) ('0' + c));
+ } else {
+ result.append((char) ('A' + c - 10));
+ }
+ c = (byte) (b & 0x0f);
+ if (c <= 9) {
+ result.append((char) ('0' + c));
+ } else {
+ result.append((char) ('A' + c - 10));
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Creates a clone of the given byte array.
+ */
+ public static byte[] getClone(byte[] pHexBinary) {
+ byte[] result = new byte[pHexBinary.length];
+ System.arraycopy(pHexBinary, 0, result, 0, pHexBinary.length);
+ return result;
+ }
+ }
+
+ public class XSDDateFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = -1629412916827246627L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateFormat() {
+ super(true, false);
+ }
+ }
+
+ /**
+ * <p/>
+ * An instance of {@link java.text.Format}, which may be used to parse and format <code>xs:dateTime</code> values.
+ * </p>
+ */
+ public static class XSDDateTimeFormat extends Format {
+ private static final long serialVersionUID = -1148332471737068969L;
+
+ final boolean parseDate;
+
+ final boolean parseTime;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateTimeFormat() {
+ this(true, true);
+ }
+
+ XSDDateTimeFormat(boolean pParseDate, boolean pParseTime) {
+ parseDate = pParseDate;
+ parseTime = pParseTime;
+ }
+
+ private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
+ String s = Integer.toString(pNum);
+ for (int i = s.length(); i < pMinLen; i++) {
+ pBuffer.append('0');
+ }
+ pBuffer.append(s);
+ }
+
+ public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
+ assert pCalendar != null : "The Calendar argument must not be null.";
+ assert pBuffer != null : "The StringBuffer argument must not be null.";
+ assert pPos != null : "The FieldPosition argument must not be null.";
+
+ Calendar cal = (Calendar) pCalendar;
+ if (parseDate) {
+ int year = cal.get(Calendar.YEAR);
+ if (year < 0) {
+ pBuffer.append('-');
+ year = -year;
+ }
+ append(pBuffer, year, 4);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.MONTH) + 1, 2);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
+ if (parseTime) {
+ pBuffer.append('T');
+ }
+ }
+ if (parseTime) {
+ append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.MINUTE), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.SECOND), 2);
+ int millis = cal.get(Calendar.MILLISECOND);
+ if (millis > 0) {
+ pBuffer.append('.');
+ append(pBuffer, millis, 3);
+ }
+ }
+ TimeZone tz = cal.getTimeZone();
+ // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
+ int offset = cal.get(Calendar.ZONE_OFFSET);
+ if (tz.inDaylightTime(cal.getTime())) {
+ offset += cal.get(Calendar.DST_OFFSET);
+ }
+ if (offset == 0) {
+ pBuffer.append('Z');
+ } else {
+ if (offset < 0) {
+ pBuffer.append('-');
+ offset = -offset;
+ } else {
+ pBuffer.append('+');
+ }
+ int minutes = offset / (60 * 1000);
+ int hours = minutes / 60;
+ minutes -= hours * 60;
+ append(pBuffer, hours, 2);
+ pBuffer.append(':');
+ append(pBuffer, minutes, 2);
+ }
+ return pBuffer;
+ }
+
+ private int parseInt(String pString, int offset, StringBuffer pDigits) {
+ int length = pString.length();
+ int pOffset = offset;
+ pDigits.setLength(0);
+ while (pOffset < length) {
+ char c = pString.charAt(pOffset);
+ if (Character.isDigit(c)) {
+ pDigits.append(c);
+ ++pOffset;
+ } else {
+ break;
+ }
+ }
+ return pOffset;
+ }
+
+ public Object parseObject(String pString, ParsePosition pParsePosition) {
+ assert pString != null : "The String argument must not be null.";
+ assert pParsePosition != null : "The ParsePosition argument must not be null.";
+ int offset = pParsePosition.getIndex();
+ int length = pString.length();
+
+ boolean isMinus = false;
+ StringBuffer digits = new StringBuffer();
+ int year = 0;
+ int month = 0;
+ int mday = 0;
+ if (parseDate) {
+ // Sign
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == '+') {
+ ++offset;
+ } else if (c == '-') {
+ ++offset;
+ isMinus = true;
+ }
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() < 4) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ year = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ month = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ mday = Integer.parseInt(digits.toString());
+
+ if (parseTime) {
+ if (offset < length && pString.charAt(offset) == 'T') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ }
+ } else {
+ year = month = mday = 0;
+ }
+
+ int hour = 0;
+ int minute = 0;
+ int second = 0;
+ int millis = 0;
+ if (parseTime) {
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ hour = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ minute = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ second = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '.') {
+ ++offset;
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() > 0) {
+ millis = Integer.parseInt(digits.toString());
+ } else {
+ millis = 0;
+ }
+ } else {
+ millis = 0;
+ }
+ } else {
+ hour = minute = second = millis = 0;
+ }
+
+ digits.setLength(0);
+ digits.append("GMT");
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == 'Z') {
+ // Ignore UTC, it is the default
+ ++offset;
+ } else if (c == '+' || c == '-') {
+ digits.append(c);
+ ++offset;
+ for (int i = 0; i < 5; i++) {
+ if (offset >= length) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ c = pString.charAt(offset);
+ if ((i != 2 && Character.isDigit(c)) || (i == 2 && c == ':')) {
+ digits.append(c);
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ ++offset;
+ }
+ }
+ }
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(digits.toString()));
+ cal.set(isMinus ? -year : year, parseDate ? month - 1 : month, mday, hour, minute, second);
+ cal.set(Calendar.MILLISECOND, millis);
+ pParsePosition.setIndex(offset);
+ return cal;
+ }
+ }
+
+ public static class XSDTimeFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = 1346506860724640517L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDTimeFormat() {
+ super(false, true);
+ }
+ }
+
+ private static final long MAX_UNSIGNED_INT = (((long) Integer.MAX_VALUE) * 2) + 1;
+
+ private static final int MAX_UNSIGNED_SHORT = Short.MAX_VALUE * 2 + 1;
+
+ public String parseAnySimpleType(String value) {
+ return value;
+ }
+
+ public byte[] parseBase64Binary(String value) {
+ return Base64Binary.decode(value);
+ }
+
+ public boolean parseBoolean(String value) {
+ return Boolean.valueOf(value).booleanValue();
+ }
+
+ public byte parseByte(String value) {
+ return Byte.parseByte(value);
+ }
+
+ public Calendar parseDate(String value) {
+ XSDDateFormat format = new XSDDateFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse date " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public Calendar parseDateTime(String value) {
+ XSDDateTimeFormat format = new XSDDateTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public BigDecimal parseDecimal(String value) {
+ return new BigDecimal(value);
+ }
+
+ public double parseDouble(String value) {
+ if ("INF".equals(value)) {
+ return Double.POSITIVE_INFINITY;
+ } else if ("-INF".equals(value)) {
+ return Double.NEGATIVE_INFINITY;
+ } else if ("NaN".equals(value)) {
+ return Double.NaN;
+ } else {
+ return Double.parseDouble(value);
+ }
+ }
+
+ public Duration parseDuration(String pDuration) {
+ try {
+ return DatatypeFactory.newInstance().newDuration(pDuration);
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public float parseFloat(String value) {
+ if ("INF".equals(value)) {
+ return Float.POSITIVE_INFINITY;
+ } else if ("-INF".equals(value)) {
+ return Float.NEGATIVE_INFINITY;
+ } else if ("NaN".equals(value)) {
+ return Float.NaN;
+ } else {
+ return Float.parseFloat(value);
+ }
+ }
+
+ public byte[] parseHexBinary(String value) {
+ return HexBinary.decode(value);
+ }
+
+ public int parseInt(String value) {
+ return Integer.parseInt(value);
+ }
+
+ public BigInteger parseInteger(String value) {
+ return new BigInteger(value);
+ }
+
+ public long parseLong(String value) {
+ return Long.parseLong(value);
+ }
+
+ public QName parseQName(String value, NamespaceContext context) {
+ int offset = value.indexOf(':');
+ String uri;
+ String localName;
+ switch (offset) {
+ case -1:
+ localName = value;
+ uri = context.getNamespaceURI("");
+ if (uri == null) {
+ // Should not happen, indicates an error in the
+ // NamespaceContext
+ // implementation
+ throw new IllegalArgumentException("The default prefix is not bound.");
+ }
+ break;
+ case 0:
+ throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: "
+ + value);
+ default:
+ String prefix = value.substring(0, offset);
+ localName = value.substring(offset + 1);
+ uri = context.getNamespaceURI(prefix);
+ if (uri == null) {
+ throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
+ }
+ }
+ return new QName(uri, localName);
+ }
+
+ public short parseShort(String value) {
+ return Short.parseShort(value);
+ }
+
+ public String parseString(String value) {
+ return value;
+ }
+
+ public Calendar parseTime(String value) {
+ XSDTimeFormat format = new XSDTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse time " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public long parseUnsignedInt(String value) {
+ long l = Long.parseLong(value);
+ if (l < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result is negative");
+ }
+ if (l > MAX_UNSIGNED_INT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_INT);
+ }
+ return l;
+ }
+
+ public int parseUnsignedShort(String value) {
+ int i = Integer.parseInt(value);
+ if (i < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result is negative");
+ }
+ if (i > MAX_UNSIGNED_SHORT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT);
+ }
+ return i;
+ }
+
+ public String printAnySimpleType(String value) {
+ return value;
+ }
+
+ public String printBase64Binary(byte[] value) {
+ return Base64Binary.encode(value);
+ }
+
+ public String printBoolean(boolean value) {
+ return (value ? Boolean.TRUE : Boolean.FALSE).toString();
+ }
+
+ public String printByte(byte value) {
+ return Byte.toString(value);
+ }
+
+ public String printDate(Calendar value) {
+ return new XSDDateFormat().format(value);
+ }
+
+ public String printDateTime(Calendar value) {
+ return new XSDDateTimeFormat().format(value);
+ }
+
+ public String printDecimal(BigDecimal value) {
+ return value.toString();
+ }
+
+ public String printDouble(double value) {
+ return Double.toString(value);
+ }
+
+ public String printDuration(Duration pDuration) {
+ return pDuration.toString();
+ }
+
+ public String printFloat(float value) {
+ return Float.toString(value);
+ }
+
+ public String printHexBinary(byte[] value) {
+ return HexBinary.encode(value);
+ }
+
+ public String printInt(int value) {
+ return Integer.toString(value);
+ }
+
+ public String printInteger(BigInteger value) {
+ return value.toString();
+ }
+
+ public String printLong(long value) {
+ return Long.toString(value);
+ }
+
+ public String printQName(QName value, NamespaceContext context) {
+ String prefix = context.getPrefix(value.getNamespaceURI());
+ if (prefix == null) {
+ throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI()
+ + " is not bound.");
+ } else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
+ return value.getLocalPart();
+ } else {
+ return prefix + ":" + value.getLocalPart();
+ }
+ }
+
+ public String printShort(short value) {
+ return Short.toString(value);
+ }
+
+ public String printString(String value) {
+ return value;
+ }
+
+ public String printTime(Calendar value) {
+ return new XSDTimeFormat().format(value);
+ }
+
+ public String printUnsignedInt(long value) {
+ return Long.toString(value);
+ }
+
+ public String printUnsignedShort(int value) {
+ return Integer.toString(value);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java
new file mode 100644
index 0000000000..63db5b9e24
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.deployer;
+
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * ClassLoader associated with a composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeClassLoader extends URLClassLoader {
+ private static final URL[] NOURLS = {};
+
+ public CompositeClassLoader(ClassLoader classLoader) {
+ super(NOURLS, classLoader);
+ }
+
+ public CompositeClassLoader(URL[] urls, ClassLoader classLoader) {
+ super(urls, classLoader);
+ }
+
+ public CompositeClassLoader(URL[] urls) {
+ super(urls);
+ }
+
+ public CompositeClassLoader(URL[] urls, ClassLoader classLoader, URLStreamHandlerFactory urlStreamHandlerFactory) {
+ super(urls, classLoader, urlStreamHandlerFactory);
+ }
+
+ public void addURL(URL url) {
+ super.addURL(url);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
new file mode 100644
index 0000000000..4e53a5d0ea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.deployer;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Interface that can be used to deploy SCA bundles to a runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Deployer {
+ /**
+ * Deploy a component as a child of the supplied parent. This operation creates a new component in the runtime to
+ * represent the supplied component definition. The type of component created will depend on the component
+ * definition implementation; for example, if the implementation of the component definition is a composite then
+ * typically a CompositeComponent would be returned.
+ *
+ * @param parent the parent context
+ * @param componentDefinition the component definition as parsed from an assembly
+ * @return the newly deployed component
+ */
+ <I extends Implementation<?>> Component deploy(CompositeComponent parent,
+ ComponentDefinition<I> componentDefinition)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java
new file mode 100644
index 0000000000..1a3a2ffb75
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.deployer;
+
+import java.net.URL;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+/**
+ * A holder that can be used during the load process to store information that is not part of the logical assembly
+ * model. This should be regarded as transient and references to this context should not be stored inside the model.
+ *
+ * $Rev$ $Date$
+ */
+public interface DeploymentContext {
+ /**
+ * Returns the parent of this deployment context.
+ * Will be null for the context created at the root of a deployment.
+ *
+ * @return the parent of this deployment context; may be null
+ */
+ DeploymentContext getParent();
+
+ /**
+ * Returns a class loader that can be used to load application resources.
+ *
+ * @return a class loader that can be used to load application resources
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Returns a factory that can be used to obtain an StAX XMLStreamReader.
+ *
+ * @return a factory that can be used to obtain an StAX XMLStreamReader
+ */
+ XMLInputFactory getXmlFactory();
+
+ /**
+ * Returns the ScopeContainer for the MODULE scope that will be associated with this deployment unit.
+ *
+ * @return the ScopeContainer for the MODULE scope that will be associated with this deployment unit
+ */
+ ScopeContainer getModuleScope();
+
+ /**
+ * Returns the location of the SCDL definition being deployed.
+ *
+ * @return the location of the SCDL definition being deployed
+ */
+ URL getScdlLocation();
+
+ /**
+ * Return the extension property with the supplied name.
+ *
+ * @param name the name of the property
+ * @return the property value; if null indicates that no property is present
+ */
+ Object getExtension(String name);
+
+ /**
+ * Set the value of an extension property.
+ *
+ * @param name the name of the property
+ * @param value the property value; if null then the extension property is removed
+ */
+ void putExtension(String name, Object value);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java
new file mode 100644
index 0000000000..b874ca43c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.event;
+
+/**
+ * Represents an event that is propagated in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface Event {
+
+ /**
+ * Returns the source of the event
+ */
+ Object getSource();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java
new file mode 100644
index 0000000000..d61d04cdc8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.event;
+
+/**
+ * Evaluates whether a {@link RuntimeEventListener} is applicable to a given runtime event
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface EventFilter {
+
+ /**
+ * Performs the actual evaluation on an event
+ */
+ boolean match(Event event);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java
new file mode 100644
index 0000000000..35df22fb9c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.event;
+
+/**
+ * Publishes events in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface EventPublisher {
+
+ /**
+ * Publish an event
+ */
+ void publish(Event object);
+
+ /**
+ * Registers a listener to receive notifications for the context
+ */
+ void addListener(RuntimeEventListener listener);
+
+ /**
+ * Registers a listener to receive notifications for the context
+ */
+ void addListener(EventFilter filter, RuntimeEventListener listener);
+
+
+ /**
+ * Removes a previously registered listener
+ */
+ void removeListener(RuntimeEventListener listener);
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java
new file mode 100644
index 0000000000..5146559098
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.event;
+
+import java.util.EventListener;
+
+/**
+ * Listeners observe events fired in the SCA runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeEventListener extends EventListener {
+
+ void onEvent(Event event);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java
new file mode 100644
index 0000000000..81382b86ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.event;
+
+/**
+ * An event filter that always returns a true condition
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class TrueFilter implements EventFilter {
+
+ public boolean match(Event event) {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
new file mode 100644
index 0000000000..2a74409088
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * An extension point for atomic component type, which new implementation types may extend
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class AtomicComponentExtension extends AbstractSCAObject implements AtomicComponent {
+
+ protected ScopeContainer scopeContainer;
+ protected Scope scope;
+ protected Map<String, InboundWire> serviceWires = new HashMap<String, InboundWire>();
+ protected Map<String, List<OutboundWire>> referenceWires = new HashMap<String, List<OutboundWire>>();
+ protected WireService wireService;
+ protected WorkContext workContext;
+ protected WorkScheduler workScheduler;
+ private final int initLevel;
+
+ protected AtomicComponentExtension(String name,
+ CompositeComponent parent,
+ ScopeContainer scopeContainer,
+ WireService wireService,
+ WorkContext workContext,
+ WorkScheduler workScheduler,
+ int initLevel) {
+ super(name, parent);
+ this.scopeContainer = scopeContainer;
+ this.wireService = wireService;
+ this.workContext = workContext;
+ this.workScheduler = workScheduler;
+ this.initLevel = initLevel;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ public boolean isEagerInit() {
+ return initLevel > 0;
+ }
+
+ public void start() throws CoreRuntimeException {
+ super.start();
+ scopeContainer.register(this);
+ }
+
+ public void init(Object instance) throws TargetException {
+
+ }
+
+ public void destroy(Object instance) throws TargetException {
+
+ }
+
+ public void addInboundWire(InboundWire wire) {
+ serviceWires.put(wire.getServiceName(), wire);
+ onServiceWire(wire);
+ }
+
+ public InboundWire getInboundWire(String serviceName) {
+ if (serviceName == null) {
+ if (serviceWires.size() < 1) {
+ return null;
+ }
+ return serviceWires.values().iterator().next();
+ } else {
+ return serviceWires.get(serviceName);
+ }
+ }
+
+ public Map<String, InboundWire> getInboundWires() {
+ return Collections.unmodifiableMap(serviceWires);
+ }
+
+ public void addOutboundWire(OutboundWire wire) {
+ List<OutboundWire> list = new ArrayList<OutboundWire>();
+ list.add(wire);
+ referenceWires.put(wire.getReferenceName(), list);
+ onReferenceWire(wire);
+ }
+
+ public Map<String, List<OutboundWire>> getOutboundWires() {
+ return Collections.unmodifiableMap(referenceWires);
+ }
+
+ public void addOutboundWires(Class<?> multiplicityClass, List<OutboundWire> wires) {
+ assert wires != null && wires.size() > 0;
+ referenceWires.put(wires.get(0).getReferenceName(), wires);
+ onReferenceWires(multiplicityClass, wires);
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void onReferenceWire(OutboundWire wire) {
+ }
+
+ protected void onReferenceWires(Class<?> multiplicityClass, List<OutboundWire> wires) {
+ }
+
+ protected void onServiceWire(InboundWire wire) {
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java
new file mode 100644
index 0000000000..170840ac32
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BindingBuilder;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * An extension point for binding builders. When adding support for new bindings, implementations may extend this class
+ * as a convenience.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@Scope("MODULE")
+public abstract class BindingBuilderExtension<B extends Binding> implements BindingBuilder<B> {
+
+ protected BuilderRegistry builderRegistry;
+ protected WireService wireService;
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry registry) {
+ this.builderRegistry = registry;
+ }
+
+ @Autowire
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ builderRegistry.register(getBindingType(), this);
+ }
+
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<B> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+ return null;
+ }
+
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<B> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ return null;
+ }
+
+ protected abstract Class<B> getBindingType();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java
new file mode 100644
index 0000000000..1f5466dfcd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.ComponentBuilder;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.wire.WireService;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.policy.PolicyBuilderRegistry;
+
+/**
+ * An extension point for component builders. When adding support for new component types, implementations may extend
+ * this class as a convenience.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@Scope("MODULE")
+public abstract class ComponentBuilderExtension<I extends Implementation<?>> implements ComponentBuilder<I> {
+
+ protected BuilderRegistry builderRegistry;
+ protected ScopeRegistry scopeRegistry;
+ protected WireService wireService;
+ protected WorkScheduler workScheduler;
+ protected WorkContext workContext;
+ protected PolicyBuilderRegistry policyBuilderRegistry;
+ protected Connector connector;
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry registry) {
+ this.builderRegistry = registry;
+ }
+
+ @Autowire
+ public void setScopeRegistry(ScopeRegistry scopeRegistry) {
+ this.scopeRegistry = scopeRegistry;
+ }
+
+ @Autowire
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ @Autowire
+ public void setWorkScheduler(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ @Autowire
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ @Autowire
+ public void setPolicyBuilderRegistry(PolicyBuilderRegistry registry) {
+ policyBuilderRegistry = registry;
+ }
+
+ @Autowire
+ public void setConnector(Connector connector) {
+ this.connector = connector;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ builderRegistry.register(getImplementationType(), this);
+ }
+
+ protected abstract Class<I> getImplementationType();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java
new file mode 100644
index 0000000000..6c5086aec4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.loader.ComponentTypeLoader;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public abstract class ComponentTypeLoaderExtension<I extends Implementation> implements ComponentTypeLoader<I> {
+ protected LoaderRegistry loaderRegistry;
+
+ protected ComponentTypeLoaderExtension() {
+ }
+
+ protected ComponentTypeLoaderExtension(LoaderRegistry loaderRegistry) {
+ this.loaderRegistry = loaderRegistry;
+ }
+
+ @Autowire
+ public void setLoaderRegistry(LoaderRegistry loaderRegistry) {
+ this.loaderRegistry = loaderRegistry;
+ }
+
+ @Init(eager = true)
+ public void start() {
+ loaderRegistry.registerLoader(getImplementationClass(), this);
+ }
+
+ @Destroy
+ public void stop() {
+ loaderRegistry.unregisterLoader(getImplementationClass());
+ }
+
+ protected abstract Class<I> getImplementationClass();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
new file mode 100644
index 0000000000..93aec79bfd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
@@ -0,0 +1,524 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.AutowireResolutionException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ComponentNotFoundException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.DuplicateNameException;
+import org.apache.tuscany.spi.component.IllegalTargetException;
+import org.apache.tuscany.spi.component.ObjectRegistrationException;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * An extension point for composite components, which new types may extend
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class CompositeComponentExtension extends AbstractSCAObject implements CompositeComponent {
+
+ protected final Map<String, SCAObject> children = new ConcurrentHashMap<String, SCAObject>();
+ protected final List<Service> services = new ArrayList<Service>();
+ protected final List<Reference> references = new ArrayList<Reference>();
+
+ protected final Map<String, Document> propertyValues;
+ protected final Connector connector;
+
+ protected final Map<String, SCAObject> systemChildren = new ConcurrentHashMap<String, SCAObject>();
+ protected final List<Service> systemServices = new ArrayList<Service>();
+ protected final List<Reference> systemReferences = new ArrayList<Reference>();
+
+ // autowire mappings
+ protected final Map<Class, SCAObject> autowireInternal = new ConcurrentHashMap<Class, SCAObject>();
+ protected final Map<Class, Service> autowireExternal = new ConcurrentHashMap<Class, Service>();
+ protected final Map<Class, SCAObject> systemAutowireInternal = new ConcurrentHashMap<Class, SCAObject>();
+ protected final Map<Class, Service> systemAutowireExternal = new ConcurrentHashMap<Class, Service>();
+
+ protected CompositeComponentExtension(String name,
+ CompositeComponent parent,
+ Connector connector,
+ Map<String, Document> propertyValues) {
+ super(name, parent);
+ this.propertyValues = propertyValues;
+ this.connector = connector;
+ }
+
+ public Scope getScope() {
+ return Scope.COMPOSITE;
+ }
+
+ public void onEvent(Event event) {
+ publish(event);
+ }
+
+ public <S, I extends S> void registerJavaObject(String name, Class<S> service, I instance)
+ throws ObjectRegistrationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Document getPropertyValue(String name) {
+ return propertyValues.get(name);
+ }
+
+ public SCAObject getChild(String name) {
+ assert name != null : "Name was null";
+ return children.get(name);
+ }
+
+ public SCAObject getSystemChild(String name) {
+ assert name != null : "Name was null";
+ return systemChildren.get(name);
+ }
+
+ public List<SCAObject> getSystemChildren() {
+ return Collections.unmodifiableList(new ArrayList<SCAObject>(systemChildren.values()));
+ }
+
+ public List<Service> getSystemServices() {
+ return Collections.unmodifiableList(systemServices);
+ }
+
+ public List<Reference> getSystemReferences() {
+ return Collections.unmodifiableList(systemReferences);
+ }
+
+ public List<SCAObject> getChildren() {
+ return Collections.unmodifiableList(new ArrayList<SCAObject>(children.values()));
+ }
+
+ public List<Service> getServices() {
+ return Collections.unmodifiableList(services);
+ }
+
+ public List<Reference> getReferences() {
+ return Collections.unmodifiableList(references);
+ }
+
+ public void register(SCAObject child) {
+ if (child.isSystem()) {
+ if (systemChildren.get(child.getName()) != null) {
+ DuplicateNameException e =
+ new DuplicateNameException("A system child is already registered with the name");
+ e.setIdentifier(child.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ systemChildren.put(child.getName(), child);
+ } else {
+ if (children.get(child.getName()) != null) {
+ DuplicateNameException e = new DuplicateNameException("A child is already registered with the name");
+ e.setIdentifier(child.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ children.put(child.getName(), child);
+ }
+ if (child instanceof Service) {
+ Service service = (Service) child;
+ synchronized (services) {
+ if (service.isSystem()) {
+ systemServices.add(service);
+ } else {
+ services.add(service);
+ }
+ }
+ registerAutowire(service);
+ } else if (child instanceof Reference) {
+ Reference reference = (Reference) child;
+ synchronized (references) {
+ if (reference.isSystem()) {
+ systemReferences.add(reference);
+ } else {
+ references.add(reference);
+ }
+ }
+ registerAutowire(reference);
+ } else if (child instanceof AtomicComponent) {
+ AtomicComponent atomic = (AtomicComponent) child;
+ registerAutowire(atomic);
+ } else if (child instanceof CompositeComponent) {
+ CompositeComponent component = (CompositeComponent) child;
+ if (lifecycleState == RUNNING && component.getLifecycleState() == UNINITIALIZED) {
+ component.start();
+ }
+ registerAutowire(component);
+ addListener(component);
+ }
+ }
+
+
+ public void addOutboundWire(OutboundWire wire) {
+
+ }
+
+ public void addOutboundWires(Class<?> multiplicityClass, List<OutboundWire> wires) {
+
+ }
+
+ public Map<String, List<OutboundWire>> getOutboundWires() {
+ return null;
+ }
+
+ public void addInboundWire(InboundWire wire) {
+ //TODO implement
+ }
+
+ public InboundWire getInboundWire(String serviceName) {
+ SCAObject object = children.get(serviceName);
+ if (!(object instanceof Service)) {
+ throw new ComponentNotFoundException(serviceName);
+ }
+ return ((Service) object).getInboundWire();
+ }
+
+ public Map<String, InboundWire> getInboundWires() {
+ synchronized (services) {
+ Map<String, InboundWire> map = new HashMap<String, InboundWire>();
+ for (Service service : services) {
+ map.put(service.getName(), service.getInboundWire());
+ }
+ return map;
+ }
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Service getService(String name) {
+ SCAObject ctx = children.get(name);
+ if (ctx == null) {
+ ComponentNotFoundException e = new ComponentNotFoundException("Service not found");
+ e.setIdentifier(name);
+ e.addContextName(getName());
+ throw e;
+ } else if (!(ctx instanceof Service)) {
+ ComponentNotFoundException e = new ComponentNotFoundException("SCAObject not a service");
+ e.setIdentifier(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ return (Service) ctx;
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ Service service = services.get(0);
+ if (service == null) {
+ throw new TargetException("Component has no services");
+ }
+ return service.getServiceInstance();
+ }
+
+ public Service getSystemService(String name) {
+ SCAObject ctx = systemChildren.get(name);
+ if (ctx == null) {
+ ComponentNotFoundException e = new ComponentNotFoundException("Service not found");
+ e.setIdentifier(name);
+ e.addContextName(getName());
+ throw e;
+ } else if (!(ctx instanceof Service)) {
+ ComponentNotFoundException e = new ComponentNotFoundException("SCAObject not a service");
+ e.setIdentifier(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ return (Service) ctx;
+ }
+
+ public <T> T locateService(Class<T> serviceInterface, String name) {
+ SCAObject target = children.get(name);
+ if (target == null) {
+ TargetNotFoundException e = new TargetNotFoundException(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ return serviceInterface.cast(target.getServiceInstance());
+ }
+
+ public <T> T locateSystemService(Class<T> serviceInterface, String name) {
+ SCAObject object = systemChildren.get(name);
+ if (object == null) {
+ TargetNotFoundException e = new TargetNotFoundException(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ return serviceInterface.cast(object.getServiceInstance());
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ SCAObject context = children.get(name);
+ if (context == null) {
+ TargetNotFoundException e = new TargetNotFoundException(name);
+ e.addContextName(getName());
+ throw e;
+ } else if (context instanceof Service) {
+ return context.getServiceInstance();
+ } else {
+ IllegalTargetException e = new IllegalTargetException("Target must be a service");
+ e.setIdentifier(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+
+ public Object getSystemServiceInstance(String name) throws TargetException {
+ SCAObject target = systemChildren.get(name);
+ if (target == null) {
+ TargetNotFoundException e = new TargetNotFoundException(name);
+ e.addContextName(getName());
+ throw e;
+ } else if (target instanceof Service) {
+ return target.getServiceInstance();
+ } else {
+ IllegalTargetException e = new IllegalTargetException("Target must be a service");
+ e.setIdentifier(name);
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>(services.size());
+ synchronized (services) {
+ for (Service service : services) {
+ serviceInterfaces.add(service.getInterface());
+ }
+ }
+ return serviceInterfaces;
+ }
+
+ public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ if (CompositeComponent.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ }
+ SCAObject context = autowireInternal.get(instanceInterface);
+ if (context != null) {
+ try {
+ if (context instanceof AtomicComponent || context instanceof Reference || context instanceof Service) {
+ return instanceInterface.cast(context.getServiceInstance());
+ } else {
+ IllegalTargetException e = new IllegalTargetException("Autowire target must be a system "
+ + "service, atomic component, or reference");
+ e.setIdentifier(instanceInterface.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ } catch (CoreRuntimeException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ } else {
+ try {
+ if (CompositeComponent.class.isAssignableFrom(instanceInterface)) {
+ return instanceInterface.cast(this);
+ }
+ // resolve to parent
+ if (getParent() == null) {
+ return null;
+ }
+ return getParent().resolveInstance(instanceInterface);
+ } catch (AutowireResolutionException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ public <T> T resolveSystemInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ if (CompositeComponent.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ }
+ SCAObject context = systemAutowireInternal.get(instanceInterface);
+ if (context != null) {
+ try {
+ if (context instanceof AtomicComponent || context instanceof Reference || context instanceof Service) {
+ return instanceInterface.cast(context.getServiceInstance());
+ } else {
+ IllegalTargetException e = new IllegalTargetException("Autowire target must be a system "
+ + "service, atomic component, or reference");
+ e.setIdentifier(instanceInterface.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ } catch (CoreRuntimeException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ } else {
+ try {
+ // resolve to parent
+ if (getParent() != null) {
+ return getParent().resolveSystemInstance(instanceInterface);
+ } else {
+ return null;
+ }
+ } catch (AutowireResolutionException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ public <T> T resolveExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ Service service = autowireExternal.get(instanceInterface);
+ if (service != null) {
+ try {
+ return instanceInterface.cast(service.getServiceInstance());
+ } catch (CoreRuntimeException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public <T> T resolveSystemExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ Service service = systemAutowireExternal.get(instanceInterface);
+ if (service != null) {
+ try {
+ return instanceInterface.cast(service.getServiceInstance());
+ } catch (CoreRuntimeException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public void prepare() {
+ // Connect services and references first so that their wires are linked first
+ List<SCAObject> childList = new ArrayList<SCAObject>();
+ for (SCAObject child : systemChildren.values()) {
+ if (child instanceof Component) {
+ childList.add(child);
+ } else {
+ childList.add(0, child);
+ }
+ }
+ // connect system artifacts
+ for (SCAObject child : childList) {
+ // connect all children
+ // TODO for composite wires, should delegate down
+ connector.connect(child);
+ child.prepare();
+ }
+
+ // connect application artifacts
+ childList.clear();
+ for (SCAObject child : children.values()) {
+ if (child instanceof Component) {
+ childList.add(child);
+ } else {
+ childList.add(0, child);
+ }
+ }
+ for (SCAObject child : childList) {
+ // connect all children
+ // TODO for composite wires, should delegate down
+ connector.connect(child);
+ child.prepare();
+ }
+ }
+
+ protected void registerAutowireExternal(Class<?> interfaze, Service service) {
+ if (interfaze == null) {
+ // The ServiceContract is not from Java
+ return;
+ }
+ if (service.isSystem()) {
+ if (systemAutowireExternal.containsKey(interfaze)) {
+ return;
+ }
+ systemAutowireExternal.put(interfaze, service);
+ } else {
+ if (autowireExternal.containsKey(interfaze)) {
+ return;
+ }
+ autowireExternal.put(interfaze, service);
+ }
+ }
+
+ protected void registerAutowireInternal(Class<?> interfaze, SCAObject object) {
+ if (interfaze == null) {
+ // The ServiceContract is not from Java
+ return;
+ }
+ if (object.isSystem()) {
+ if (systemAutowireInternal.containsKey(interfaze)) {
+ return;
+ }
+ systemAutowireInternal.put(interfaze, object);
+ } else {
+ if (autowireInternal.containsKey(interfaze)) {
+ return;
+ }
+ autowireInternal.put(interfaze, object);
+ }
+ }
+
+ protected void registerAutowire(CompositeComponent component) {
+ List<Service> services = component.getServices();
+ for (Service service : services) {
+ registerAutowireInternal(service.getInterface(), service);
+ }
+ }
+
+ protected void registerAutowire(AtomicComponent component) {
+ List<Class<?>> services = component.getServiceInterfaces();
+ for (Class<?> service : services) {
+ registerAutowireInternal(service, component);
+ }
+ }
+
+ protected void registerAutowire(Reference reference) {
+ registerAutowireInternal(reference.getInterface(), reference);
+ }
+
+ protected void registerAutowire(Service service) {
+ registerAutowireExternal(service.getInterface(), service);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java
new file mode 100644
index 0000000000..cc42247c33
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import javax.xml.namespace.QName;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.StAXElementLoader;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Support class for extending the Loader mechanism.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class LoaderExtension<T extends ModelObject> implements StAXElementLoader<T> {
+ /**
+ * The LoaderRegistry that this loader should register with; usually set by injection. This registry may also be
+ * used to load sub-elements.
+ */
+ protected LoaderRegistry registry;
+
+ /**
+ * Constructor specifies the registry to register with.
+ *
+ * @param registry the LoaderRegistry this loader should register with
+ */
+ protected LoaderExtension(@Autowire LoaderRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Initialize the loader. The base implementation registers this loader with the registry as a handler for the XML
+ * type returned by {@link #getXMLType()}. Implementations may override this to register the loader as a handler for
+ * multiple XML types.
+ */
+ @Init(eager = true)
+ public void start() {
+ registry.registerLoader(getXMLType(), this);
+ }
+
+ /**
+ * Destroy the loader. The base implementation unregisters the loader from the regsitry based on the type returned
+ * by {@link #getXMLType()}.
+ */
+ @Destroy
+ public void stop() {
+ registry.unregisterLoader(getXMLType(), this);
+ }
+
+ /**
+ * Returns the QName of the element that this implementation handles.
+ *
+ * @return the QName of the element that this implementation handles
+ */
+ public abstract QName getXMLType();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java
new file mode 100644
index 0000000000..d6c3222c38
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceExtension.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * The default implementation of an SCA reference
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ReferenceExtension extends AbstractSCAObject implements Reference {
+
+ protected InboundWire inboundWire;
+ protected OutboundWire outboundWire;
+ protected Class<?> referenceInterface;
+ protected WireService wireService;
+ protected ServiceContract<?> bindingServiceContract;
+
+ protected ReferenceExtension(String name,
+ Class<?> referenceInterface,
+ CompositeComponent parent,
+ WireService wireService) {
+ super(name, parent);
+ this.referenceInterface = referenceInterface;
+ this.wireService = wireService;
+ }
+
+ public Scope getScope() {
+ return Scope.COMPOSITE;
+ }
+
+ public void setInboundWire(InboundWire wire) {
+ this.inboundWire = wire;
+ }
+
+ public InboundWire getInboundWire() {
+ return inboundWire;
+ }
+
+ public OutboundWire getOutboundWire() {
+ return outboundWire;
+ }
+
+ public void setOutboundWire(OutboundWire outboundWire) {
+ this.outboundWire = outboundWire;
+ }
+
+ public Class<?> getInterface() {
+ return referenceInterface;
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return wireService.createProxy(inboundWire);
+ }
+
+ public WireInvocationHandler getHandler() throws TargetException {
+ return wireService.createHandler(inboundWire);
+ }
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceContract<?> getBindingServiceContract() {
+ return bindingServiceContract;
+ }
+
+ public void setBindingServiceContract(ServiceContract<?> serviceContract) {
+ this.bindingServiceContract = serviceContract;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java
new file mode 100644
index 0000000000..2eeddf7727
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceExtension.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * The default implementation of an SCA service
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceExtension extends AbstractSCAObject implements Service {
+
+ protected Class<?> interfaze;
+ protected InboundWire inboundWire;
+ protected OutboundWire outboundWire;
+ protected WireService wireService;
+ protected ServiceContract<?> bindingServiceContract;
+
+ public ServiceExtension(String name, Class<?> interfaze, CompositeComponent parent, WireService wireService)
+ throws CoreRuntimeException {
+ super(name, parent);
+ this.interfaze = interfaze;
+ this.wireService = wireService;
+ }
+
+ public Scope getScope() {
+ return Scope.COMPOSITE;
+ }
+
+ public InboundWire getInboundWire() {
+ return inboundWire;
+ }
+
+ public void setInboundWire(InboundWire wire) {
+ inboundWire = wire;
+ }
+
+ public OutboundWire getOutboundWire() {
+ return outboundWire;
+ }
+
+ public void setOutboundWire(OutboundWire outboundWire) {
+ this.outboundWire = outboundWire;
+ }
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return wireService.createProxy(inboundWire);
+ }
+
+ public WireInvocationHandler getHandler() {
+ return wireService.createHandler(inboundWire);
+ }
+
+ public Class<?> getInterface() {
+ return interfaze;
+ }
+
+ public ServiceContract<?> getBindingServiceContract() {
+ return bindingServiceContract;
+ }
+
+ public void setBindingServiceContract(ServiceContract<?> serviceContract) {
+ this.bindingServiceContract = serviceContract;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java
new file mode 100644
index 0000000000..8a65a91f3a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class SystemAtomicComponentExtension extends AtomicComponentExtension implements SystemAtomicComponent {
+ protected List<Class<?>> interfazes;
+
+ public SystemAtomicComponentExtension(String name,
+ CompositeComponent parent,
+ ScopeContainer scopeContainer,
+ int initLevel) {
+ this(name, null, parent, scopeContainer, initLevel);
+ }
+
+ public SystemAtomicComponentExtension(String name,
+ List<Class<?>> serviceInterfaces,
+ CompositeComponent parent,
+ ScopeContainer scopeContainer,
+ int initLevel) {
+ super(name, parent, scopeContainer, null, null, null, initLevel);
+ this.interfazes = serviceInterfaces;
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getTargetInstance();
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return interfazes;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSystem() {
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
new file mode 100644
index 0000000000..faa13360c7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The default implementation of a TargetInvoker
+ */
+public abstract class TargetInvokerExtension implements TargetInvoker {
+
+ private boolean cacheable;
+
+ public TargetInvokerExtension() {
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable();
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ // TargetInvoker extends Cloneable so this should not have been thrown
+ throw new AssertionError(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java
new file mode 100644
index 0000000000..0e7922f0f1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.host;
+
+import javax.servlet.Servlet;
+
+/**
+ * ServiceDefinition interface implemented by host environments that allow Servlets to be registered.
+ * <p/>
+ * This interface allows an SCA system component to register a servlet to handle inbound requests.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServletHost {
+ /**
+ * Register a mapping for an instance of a Servlet. This requests that the servlet container direct all requests to
+ * the designated mapping to the supplied Servlet instance.
+ *
+ * @param mapping the uri-mapping for the Servlet
+ * @param servlet the Servlet that should be invoked
+ */
+ void registerMapping(String mapping, Servlet servlet);
+
+ /**
+ * Unregister a servlet mapping. This directs the servlet contain not to direct any more requests to a previously
+ * registered Servlet.
+ *
+ * @param mapping the uri-mapping for the Servlet
+ */
+ void unregisterMapping(String mapping);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java
new file mode 100644
index 0000000000..5a0bd3bb5f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.idl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema elements
+ */
+public class ElementInfo {
+ private QName name;
+ private TypeInfo type;
+
+ /**
+ * @param name
+ * @param type
+ */
+ public ElementInfo(QName name, TypeInfo type) {
+ super();
+ this.name = name;
+ this.type = type;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the type
+ */
+ public TypeInfo getType() {
+ return type;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java
new file mode 100644
index 0000000000..5709524573
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class InvalidServiceContractException extends TuscanyException {
+ public InvalidServiceContractException() {
+ }
+
+ public InvalidServiceContractException(String message) {
+ super(message);
+ }
+
+ public InvalidServiceContractException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidServiceContractException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java
new file mode 100644
index 0000000000..0b435e9eb9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl;
+
+/**
+ * Exception thrown to indicate that a service contract specification contains an overloaded method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OverloadedOperationException extends InvalidServiceContractException {
+ private static final long serialVersionUID = -4658711318608885638L;
+
+ public OverloadedOperationException() {
+ }
+
+ public OverloadedOperationException(String message) {
+ super(message);
+ }
+
+ public OverloadedOperationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OverloadedOperationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java
new file mode 100644
index 0000000000..9bb107812c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.idl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema types
+ */
+public class TypeInfo {
+ private QName name;
+
+ private boolean isSimpleType;
+
+ private TypeInfo baseType;
+
+ /**
+ * @param name
+ * @param isSimpleType
+ */
+ public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) {
+ super();
+ this.name = name;
+ this.isSimpleType = isSimpleType;
+ this.baseType = baseType;
+ }
+
+ /**
+ * @return the isSimpleType
+ */
+ public boolean isSimpleType() {
+ return isSimpleType;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the baseType
+ */
+ public TypeInfo getBaseType() {
+ return baseType;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/WrapperInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/WrapperInfo.java
new file mode 100644
index 0000000000..1125da744c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/WrapperInfo.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.idl;
+
+import java.util.List;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based Web Services (JAX-WS) 2.0 specification,
+ * section 2.3.1.2 Wrapper Style.
+ * <p/>
+ * A WSDL operation qualifies for wrapper style mapping only if the following criteria are met: <ul> <li>(i) The
+ * operation’s input and output messages (if present) each contain only a single part <li>(ii) The input message part
+ * refers to a global element declaration whose localname is equal to the operation name <li>(iii) The output message
+ * part refers to a global element declaration <li>(iv) The elements referred to by the input and output message parts
+ * (henceforth referred to as wrapper elements) are both complex types defined using the xsd:sequence compositor <li>(v)
+ * The wrapper elements only contain child elements, they must not contain other structures such as wildcards (element
+ * or attribute), xsd:choice, substitution groups (element references are not permitted) or attributes; furthermore,
+ * they must not be nillable. </ul>
+ */
+public class WrapperInfo {
+ private ElementInfo inputWrapperElement;
+
+ private ElementInfo outputWrapperElement;
+
+ private List<ElementInfo> inputChildElements;
+
+ private List<ElementInfo> outputChildElements;
+
+ private DataType<List<DataType<QName>>> unwrappedInputType;
+
+ private DataType<QName> unwrappedOutputType;
+
+ /**
+ * @param inputWrapperElement
+ * @param outputWrapperElement
+ * @param inputElements
+ * @param outputElements
+ * @param unwrappedInputType
+ * @param unwrappedOutputType
+ */
+ public WrapperInfo(ElementInfo inputWrapperElement,
+ ElementInfo outputWrapperElement,
+ List<ElementInfo> inputElements,
+ List<ElementInfo> outputElements,
+ DataType<List<DataType<QName>>> unwrappedInputType,
+ DataType<QName> unwrappedOutputType) {
+ super();
+ this.inputWrapperElement = inputWrapperElement;
+ this.outputWrapperElement = outputWrapperElement;
+ this.inputChildElements = inputElements;
+ this.outputChildElements = outputElements;
+ this.unwrappedInputType = unwrappedInputType;
+ this.unwrappedOutputType = unwrappedOutputType;
+ }
+
+ /**
+ * @return the inputElements
+ */
+ public List<ElementInfo> getInputChildElements() {
+ return inputChildElements;
+ }
+
+ /**
+ * @return the inputWrapperElement
+ */
+ public ElementInfo getInputWrapperElement() {
+ return inputWrapperElement;
+ }
+
+ /**
+ * @return the outputElements
+ */
+ public List<ElementInfo> getOutputChildElements() {
+ return outputChildElements;
+ }
+
+ /**
+ * @return the outputWrapperElement
+ */
+ public ElementInfo getOutputWrapperElement() {
+ return outputWrapperElement;
+ }
+
+ /**
+ * @return the unwrappedInputType
+ */
+ public DataType<List<DataType<QName>>> getUnwrappedInputType() {
+ return unwrappedInputType;
+ }
+
+ /**
+ * @return the unwrappedOutputType
+ */
+ public DataType<QName> getUnwrappedOutputType() {
+ return unwrappedOutputType;
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java
new file mode 100644
index 0000000000..08f22147b5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * Processor for creating JavaServiceContract definitions from Java Classes.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InterfaceJavaIntrospector {
+
+ /**
+ * Introspect a Java interface and return a service contract definition.
+ *
+ * @param type the interface to inspect
+ * @return a JavaServiceContract corresponding to the Java interface
+ */
+ <I> JavaServiceContract introspect(Class<I> type) throws InvalidServiceContractException;
+
+ /**
+ * Introspect a Java interface and return a service contract definition.
+ *
+ * @param type the interface to inspect
+ * @param callback the callback interface to inspec
+ * @return a JavaServiceContract corresponding to the Java interface
+ */
+ <I, C> JavaServiceContract introspect(Class<I> type, Class<C> callback) throws InvalidServiceContractException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java
new file mode 100644
index 0000000000..c7c7cb2aa8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * Contains methods for mapping between an operation in a {@link org.apache.tuscany.spi.model.ServiceContract} and a
+ * method defined by a Java interface
+ *
+ * @version $Rev$ $Date$
+ */
+public final class JavaIDLUtils {
+
+ private JavaIDLUtils() {
+ }
+
+ /**
+ * Searches an array of methods for a match against the given operation
+ *
+ * @param operation the operation to match
+ * @param methods the methods to match against
+ * @return a matching method or null
+ */
+ public static Method findMethod(Operation<?> operation, Method[] methods) {
+ for (Method method : methods) {
+ if (match(operation, method)) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches a collection of operations for a match against the given method
+ *
+ * @param method the method to match
+ * @param operations the operations to match against
+ * @return a matching operation or null
+ */
+ public static Operation findOperation(Method method, Collection<Operation<?>> operations) {
+ for (Operation<?> operation : operations) {
+ if (match(operation, method)) {
+ return operation;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines if the given operation matches the given method
+ *
+ * @return true if the operation matches, false if does not
+ */
+ private static <T> boolean match(Operation<T> operation, Method method) {
+ Class<?>[] params = method.getParameterTypes();
+ DataType<List<DataType<T>>> inputType = operation.getInputType();
+ List<DataType<T>> types = inputType.getLogical();
+ boolean found = true;
+ if (types.size() == params.length && method.getName().equals(operation.getName())) {
+ for (int i = 0; i < params.length; i++) {
+ Class<?> clazz = params[i];
+ if (!clazz.equals(operation.getInputType().getLogical().get(i).getPhysical())) {
+ found = false;
+ }
+ }
+ } else {
+ found = false;
+ }
+ return found;
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java
new file mode 100644
index 0000000000..afe98f0773
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * Implementations introspect metadata on a Java interface, populating the
+ * corresponding {@link JavaServiceContract}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaInterfaceProcessor {
+
+ void visitInterface(Class<?> clazz, Class<?> callbackClass, JavaServiceContract contract)
+ throws InvalidServiceContractException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java
new file mode 100644
index 0000000000..d0333b0c3d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * A convenience class for <code>JavaInterfaceProcessor</code> extensions that performs autowiring
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class JavaInterfaceProcessorExtension implements JavaInterfaceProcessor {
+
+ protected JavaInterfaceProcessorRegistry registry;
+
+ @Autowire
+ public void setRegistry(JavaInterfaceProcessorRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ registry.registerProcessor(this);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java
new file mode 100644
index 0000000000..38c64e6f88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+/**
+ * A registry of {@link JavaInterfaceProcessor}s. Interface processors update a service contract definition based on a
+ * Java interface
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaInterfaceProcessorRegistry extends InterfaceJavaIntrospector {
+
+ /**
+ * Registers the given processor
+ */
+ void registerProcessor(JavaInterfaceProcessor processor);
+
+ /**
+ * Deregisters the given processor
+ */
+ void unregisterProcessor(JavaInterfaceProcessor processor);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java
new file mode 100644
index 0000000000..ee29846e26
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Represents a service contract specified using a Java interface
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaServiceContract extends ServiceContract<Type> {
+
+ public JavaServiceContract() {
+ }
+
+ public JavaServiceContract(Class<?> interfaceClass) {
+ super(interfaceClass);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java
new file mode 100644
index 0000000000..8014453f0b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Base class for ImplementationProcessors that handle annotations that add Properties.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractPropertyProcessor<A extends Annotation> extends ImplementationProcessorExtension {
+ private final Class<A> annotationClass;
+ private ImplementationProcessorService service;
+
+ protected AbstractPropertyProcessor(Class<A> annotationClass, ImplementationProcessorService service) {
+ this.annotationClass = annotationClass;
+ this.service = service;
+ }
+
+ public void visitMethod(CompositeComponent parent,
+ Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ A annotation = method.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ if (!Void.TYPE.equals(method.getReturnType())) {
+ IllegalPropertyException ipe = new IllegalPropertyException("Method does not have void return type");
+ ipe.setIdentifier(method.toString());
+ throw ipe;
+ }
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length != 1) {
+ IllegalPropertyException ipe = new IllegalPropertyException("Method must have 1 parameter");
+ ipe.setIdentifier(method.toString());
+ throw ipe;
+ }
+ Class<?> javaType = paramTypes[0];
+
+ String name = getName(annotation);
+ if (name == null || name.length() == 0) {
+ name = method.getName();
+ if (name.startsWith("set")) {
+ name = toPropertyName(method.getName());
+ }
+ }
+
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ if (properties.containsKey(name)) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ JavaMappedProperty<?> property = createProperty(name, javaType, method);
+ initProperty(property, annotation, parent, context);
+ properties.put(name, property);
+ }
+
+ public void visitField(CompositeComponent parent,
+ Field field,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ A annotation = field.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ Class<?> javaType = field.getType();
+
+ String name = getName(annotation);
+ if (name == null || name.length() == 0) {
+ name = field.getName();
+ }
+
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ if (properties.containsKey(name)) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ JavaMappedProperty<?> property = createProperty(name, javaType, field);
+ initProperty(property, annotation, parent, context);
+ properties.put(name, property);
+ }
+
+ public <T> void visitConstructor(CompositeComponent parent, Constructor<T> constructor,
+ PojoComponentType<JavaMappedService,
+ JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+
+ ConstructorDefinition<?> definition = type.getConstructorDefinition();
+ Class[] params = constructor.getParameterTypes();
+ Map<String, JavaMappedProperty<?>> properties = type.getProperties();
+ Annotation[][] annotations = constructor.getParameterAnnotations();
+ for (int i = 0; i < params.length; i++) {
+ Class<?> param = params[i];
+ Annotation[] paramAnnotations = annotations[i];
+ for (Annotation annotation : paramAnnotations) {
+ if (annotation.annotationType().equals(annotationClass)) {
+ if (definition == null) {
+ definition = new ConstructorDefinition<T>(constructor);
+ type.setConstructorDefinition(definition);
+ }
+ A monitorAnnot = annotationClass.cast(annotation);
+ String name = getName(monitorAnnot);
+ if (name == null || name.length() == 0) {
+ name = param.getName();
+ }
+ JavaMappedProperty<?> property = createProperty(name, param, constructor);
+ initProperty(property, monitorAnnot, parent, context);
+ properties.put(name, property);
+ service.addName(definition.getInjectionNames(), i, name);
+ }
+ }
+ }
+ }
+
+ protected abstract String getName(A annotation);
+
+ protected <T> void initProperty(JavaMappedProperty<T> property,
+ A annotation,
+ CompositeComponent parent,
+ DeploymentContext context) throws ProcessingException {
+ }
+
+ protected <T> JavaMappedProperty<T> createProperty(String name, Class<T> javaType, Member member)
+ throws ProcessingException {
+ return new JavaMappedProperty<T>(name, null, javaType, member);
+ }
+
+
+ public static String toPropertyName(String name) {
+ if (!name.startsWith("set")) {
+ return name;
+ }
+ return Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java
new file mode 100644
index 0000000000..94c185966f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Hold injection information for the constructor used to instantiate a component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstructorDefinition<T> {
+
+ private Constructor<T> constructor;
+ private List<String> injectionNames;
+
+ public ConstructorDefinition(Constructor<T> constructor) {
+ this.constructor = constructor;
+ injectionNames = new ArrayList<String>();
+ }
+
+ public Constructor<T> getConstructor() {
+ return constructor;
+ }
+
+ public List<String> getInjectionNames() {
+ return injectionNames;
+ }
+
+ public void setInjectionNames(List<String> injectionNames) {
+ this.injectionNames = injectionNames;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java
new file mode 100644
index 0000000000..3582beff7f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+/**
+ * Thrown when an implementation has more than one property injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicatePropertyException extends ProcessingException {
+ public DuplicatePropertyException() {
+ }
+
+ public DuplicatePropertyException(String message) {
+ super(message);
+ }
+
+ public DuplicatePropertyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicatePropertyException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java
new file mode 100644
index 0000000000..40f7eeadb8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+/**
+ * Denotes an illegal property definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalPropertyException extends ProcessingException {
+ public IllegalPropertyException() {
+ }
+
+ public IllegalPropertyException(String message) {
+ super(message);
+ }
+
+ public IllegalPropertyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalPropertyException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java
new file mode 100644
index 0000000000..fb9beca53c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Implementations process class-level metadata, typically parsing annotations and updating the corresponding
+ * <code>ComponentType</code>. A processor may, for example, create a {@link JavaMappedProperty} which is responsible
+ * for injecting a complex type on a component implementation instance when it is instantiated.
+ * <p/>
+ * Processors will receive callbacks as the implementation class is walked while evalauting an assembly. It is the
+ * responsibility of the parser to determine whether to perform an action during the callback.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImplementationProcessor {
+
+ /**
+ * A callback received when the component implementation class is first loaded
+ *
+ * @param parent the parent composite
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ <T> void visitClass(CompositeComponent parent,
+ Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation class hierarchy is evaluated
+ *
+ * @param parent the parent composite
+ * @param clazz the superclass in the component implmentation's class hierarchy
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ <T> void visitSuperClass(CompositeComponent parent,
+ Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's public and protected methods are evaluated
+ *
+ * @param parent the parent composite
+ * @param method the current public or protected method being evaluated
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitMethod(CompositeComponent parent,
+ Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's constructor used for instantiation by the runtime is
+ * evaluated. If an implementation contains more than one constructor, the constructor passed to the callback will
+ * be chosen according to the algorithm described in the SCA Java Client and Implementation Model Specification.
+ *
+ * @param parent the parent composite
+ * @param constructor the constructor used for instantiating component implementation instances
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ <T> void visitConstructor(CompositeComponent parent,
+ Constructor<T> constructor,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's public and protected fields are evaluated
+ *
+ * @param parent the parent composite
+ * @param field the current public or protected field being evaluated
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitField(CompositeComponent parent,
+ Field field,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * The final callback received when all other callbacks during evaluation of the component implementation have been
+ * issued
+ *
+ * @param parent the parent composite
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ <T> void visitEnd(CompositeComponent parent,
+ Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java
new file mode 100644
index 0000000000..79a715ca70
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * A convenience class for annotation processors which alleviates the need to implement unused callbacks
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ImplementationProcessorExtension implements ImplementationProcessor {
+ private IntrospectionRegistry registry;
+
+ @Autowire
+ public void setRegistry(IntrospectionRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ registry.registerProcessor(this);
+ }
+
+ @Destroy
+ public void destroy() {
+ registry.unregisterProcessor(this);
+ }
+
+ public <T> void visitClass(CompositeComponent parent, Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public <T> void visitSuperClass(CompositeComponent parent, Class<T> clazz,
+ PojoComponentType<JavaMappedService,
+ JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public void visitMethod(CompositeComponent parent, Method method,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public <T> void visitConstructor(CompositeComponent parent, Constructor<T> constructor,
+ PojoComponentType<JavaMappedService,
+ JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public void visitField(CompositeComponent parent, Field field,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+ }
+
+ public <T> void visitEnd(CompositeComponent parent, Class<T> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws ProcessingException {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java
new file mode 100644
index 0000000000..c1b0dc07af
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.List;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Provides utility methods for Java implementation processing
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImplementationProcessorService {
+
+ /**
+ * Introspects the given interface to produce a mapped service
+ */
+ JavaMappedService createService(Class<?> interfaze) throws InvalidServiceContractException,
+ InvalidServiceContractException;
+
+ JavaMappedReference createReference(String name, Member member, Class<?> paramType) throws ProcessingException;
+
+ /**
+ * Processes the callback contract for a given interface type
+ *
+ * @param interfaze the interface type to examine
+ * @param contract the service contract the callback is associated wth
+ * @throws InvalidServiceContractException
+ *
+ */
+ void processCallback(Class<?> interfaze, ServiceContract<?> contract) throws InvalidServiceContractException;
+
+ /**
+ * Determines if all the members of a collection have unique types
+ *
+ * @param collection the collection to analyze
+ * @return true if the types are unique
+ */
+ boolean areUnique(Class[] collection);
+
+ /**
+ * Inserts a name at the specified position, paddiling the list if its size is less than the position
+ */
+ void addName(List<String> names, int pos, String name);
+
+ /**
+ * Processes a constructor parameter by introspecting its annotations
+ *
+ * @param param the parameter to process
+ * @param paramAnnotations the parameter annotations
+ * @param constructorNames the array of constructorNames specified by
+ * @param pos the declaration position of the constructor parameter
+ * @param type the component type associated with implementation being reflected
+ * @param injectionNames the list of parameter constructorNames specified on parameter annotations
+ * @throws ProcessingException
+ */
+ boolean processParam(
+ Class<?> param,
+ Annotation[] paramAnnotations,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ List<String> injectionNames) throws ProcessingException;
+
+ /**
+ * Returns true if {@link @Autowire}, {@link @Property}, or {@link @Reference} are present in the given array
+ */
+ boolean injectionAnnotationsPresent(Annotation[][] annots);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java
new file mode 100644
index 0000000000..a6122a6ff1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+/**
+ * A system service which tracks {@link ImplementationProcessor}s
+ *
+ * @version $Rev$ $Date$
+ */
+public interface IntrospectionRegistry extends Introspector {
+
+ /**
+ * Registers the given processor and makes it available during assembly evaluation (i.e. build)
+ */
+ void registerProcessor(ImplementationProcessor processor);
+
+ /**
+ * Deregisters the given processor
+ */
+ void unregisterProcessor(ImplementationProcessor processor);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java
new file mode 100644
index 0000000000..66abc1f686
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Implementations are responsible for walking a component implementation class, adding additional component type
+ * information as appropriate
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Introspector {
+
+ /**
+ * Walks the given component implementation class
+ *
+ * @param parent the parent composite
+ * @param clazz the component implementation class
+ * @param type the component type associated with the implementation class
+ * @return the updated component type
+ * @throws ProcessingException if an error is encountered evaluating the implementation class
+ */
+ PojoComponentType introspect(CompositeComponent parent,
+ Class<?> clazz,
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context)
+ throws ProcessingException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java
new file mode 100644
index 0000000000..34ac8f53f9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import org.apache.tuscany.spi.model.ComponentType;
+
+/**
+ * A specialized component type definition whose services, references and properties can be mapped to the Java
+ * programming model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedComponentType<
+ S extends JavaMappedService,
+ R extends JavaMappedReference,
+ P extends JavaMappedProperty<?>
+ > extends ComponentType<S, R, P> {
+
+ private Class<?> implClass;
+
+ public JavaMappedComponentType() {
+ }
+
+ public JavaMappedComponentType(Class<?> implClass) {
+ this.implClass = implClass;
+ }
+
+ /**
+ * Returns the implementation class associated with this component type.
+ *
+ * @return the implementation class associated with this component type
+ */
+ public Class<?> getImplClass() {
+ return implClass;
+ }
+
+ /**
+ * Sets the implementation class associated with this component type.
+ *
+ * @param implClass the implementation class associated with this component type
+ */
+ public void setImplClass(Class<?> implClass) {
+ this.implClass = implClass;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java
new file mode 100644
index 0000000000..6d1715a035
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.Property;
+
+/**
+ * A Property definition that is mapped to a specific location in the implementation class. This location will typically
+ * be used to inject property values.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedProperty<T> extends Property<T> {
+ private Member member;
+
+ public JavaMappedProperty() {
+ }
+
+ public JavaMappedProperty(String name, QName xmlType, Class<T> javaType) {
+ super(name, xmlType, javaType);
+ }
+
+ public JavaMappedProperty(String name, QName xmlType, Class<T> javaType, Member member) {
+ super(name, xmlType, javaType);
+ this.member = member;
+ }
+
+ /**
+ * Returns the Member that this property is mapped to.
+ *
+ * @return the Member that this property is mapped to
+ */
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Sets the Member that this property is mapped to
+ *
+ * @param member the Member that this property is mapped to
+ */
+ public void setMember(Member member) {
+ this.member = member;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java
new file mode 100644
index 0000000000..8c718a831b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * A ReferenceDefinition definition that is mapped to a specific location in the implementation class. This location
+ * will typically be used to inject reference values.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedReference extends ReferenceDefinition {
+ private Member member;
+
+ public JavaMappedReference() {
+ }
+
+ public JavaMappedReference(String name, ServiceContract serviceContract, Member member) {
+ super(name, serviceContract);
+ this.member = member;
+ }
+
+ /**
+ * Returns the Member that this reference is mapped to.
+ *
+ * @return the Member that this reference is mapped to
+ */
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Sets the Member that this reference is mapped to
+ *
+ * @param member the Member that this reference is mapped to
+ */
+ public void setMember(Member member) {
+ this.member = member;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java
new file mode 100644
index 0000000000..ee5e0bb2a7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * A ServiceDefinition definition that is mapped to a Java interface. The mapped interface is not required to be the
+ * same as the interface specified in the service contract. This is to allow the service contract to be specified using
+ * different interface definition languages or, in the case were the IDL is Java, to allow the service definition to be
+ * loaded from a different classloader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedService extends ServiceDefinition {
+ private Class<?> serviceInterface;
+ private Member callbackMember;
+
+ public JavaMappedService() {
+ }
+
+ public JavaMappedService(Class<?> serviceInterface) {
+ this.serviceInterface = serviceInterface;
+ }
+
+ public JavaMappedService(String name, ServiceContract contract, boolean remotable) {
+ super(name, contract, remotable);
+ }
+
+ public JavaMappedService(String name,
+ ServiceContract contract,
+ boolean remotable,
+ String callbackRefName,
+ Member callbackMember) {
+ super(name, contract, remotable, callbackRefName);
+ this.callbackMember = callbackMember;
+ }
+
+ public JavaMappedService(String name, ServiceContract contract, Class<?> serviceInterface, boolean remotable) {
+ super(name, contract, remotable);
+ this.serviceInterface = serviceInterface;
+ }
+
+ /**
+ * Returns the Java interface for this service. This may be different from the interface that defines the service
+ * contract.
+ *
+ * @return the Java interface for this service
+ */
+ public Class<?> getServiceInterface() {
+ return serviceInterface;
+ }
+
+ /**
+ * Sets the Java interface for this service. This may be different from the interface used to define the service
+ * contract.
+ *
+ * @param serviceInterface the Java interface for this service
+ */
+ public void setServiceInterface(Class<?> serviceInterface) {
+ this.serviceInterface = serviceInterface;
+ }
+
+ public Member getCallbackMember() {
+ return callbackMember;
+ }
+
+ public void setCallbackMember(Member callbackMember) {
+ this.callbackMember = callbackMember;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java
new file mode 100644
index 0000000000..edf3db5538
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * A component type specialization for POJO implementations
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class PojoComponentType<S extends ServiceDefinition, R extends ReferenceDefinition, P extends Property<?>>
+ extends ComponentType<S, R, P> {
+
+ private Scope implementationScope = Scope.UNDEFINED;
+ private ConstructorDefinition<?> constructorDefinition;
+ private Method initMethod;
+ private Method destroyMethod;
+
+ /**
+ * Returns the component implementation scope
+ */
+ public Scope getImplementationScope() {
+ return implementationScope;
+ }
+
+ /**
+ * Sets the component implementation scope
+ */
+ public void setImplementationScope(Scope implementationScope) {
+ this.implementationScope = implementationScope;
+ }
+
+ /**
+ * Returns the constructor used to instantiate implementation instances
+ */
+ public ConstructorDefinition<?> getConstructorDefinition() {
+ return constructorDefinition;
+ }
+
+ /**
+ * Sets the constructor used to instantiate implementation instances
+ */
+ public void setConstructorDefinition(ConstructorDefinition<?> definition) {
+ this.constructorDefinition = definition;
+ }
+
+ /**
+ * Returns the component initializer method
+ */
+ public Method getInitMethod() {
+ return initMethod;
+ }
+
+ /**
+ * Sets the component initializer method
+ */
+ public void setInitMethod(Method initMethod) {
+ this.initMethod = initMethod;
+ }
+
+ /**
+ * Returns the component destructor method
+ */
+ public Method getDestroyMethod() {
+ return destroyMethod;
+ }
+
+ /**
+ * Sets the component destructor method
+ */
+ public void setDestroyMethod(Method destroyMethod) {
+ this.destroyMethod = destroyMethod;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java
new file mode 100644
index 0000000000..126526d082
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+
+/**
+ * Denotes a problem processing annotations on a POJO implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProcessingException extends LoaderException {
+ public ProcessingException() {
+ }
+
+ public ProcessingException(String message) {
+ super(message);
+ }
+
+ public ProcessingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProcessingException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java
new file mode 100644
index 0000000000..8ad01d8197
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Loader that will load the ComponentType definition for the supplied implementation. The actual mechanism used to load
+ * that definition is determined by the Client and Implementation Specification for the implementaion type. In some
+ * cases the definition may be contained in a XML file related to the implementation artifact in some well defined
+ * manner; other implementations may obtain this information from introspection of the artifact itself (for example, by
+ * examining Java annotations).
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentTypeLoader<I extends Implementation> {
+ /**
+ * Load the component type definition for the supplied implementation.
+ *
+ * @param parent the parent composite
+ * @param implementation the implementation whose component type information should be loaded
+ * @param deploymentContext the current deployment context
+ * @throws LoaderException if there was a problem loading the configuration type
+ */
+ void load(CompositeComponent parent, I implementation, DeploymentContext deploymentContext)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java
new file mode 100644
index 0000000000..59db6195d8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidReferenceException extends LoaderException {
+ private static final long serialVersionUID = -4346666572527197558L;
+
+ public InvalidReferenceException() {
+ }
+
+ public InvalidReferenceException(String message) {
+ super(message);
+ }
+
+ public InvalidReferenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java
new file mode 100644
index 0000000000..194a5cc7c7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * Exception that indicates the loader encountered an invalid value.
+ * The message should be set to the invalid value.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidValueException extends LoaderException {
+
+ public InvalidValueException() {
+ }
+
+ public InvalidValueException(String message) {
+ super(message);
+ }
+
+ public InvalidValueException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidValueException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java
new file mode 100644
index 0000000000..e6364fe02b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import java.net.URL;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * System service for loading physical artifacts that represent SCDL configurations and creating the model objects that
+ * represent them.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Loader {
+ /**
+ * Parse the supplied XML stream, dispatching to the appropriate registered loader for each element encountered in
+ * the stream.
+ * <p/>
+ * This method must be called with the XML cursor positioned on a START_ELEMENT event. When this method returns, the
+ * stream will be positioned on the corresponding END_ELEMENT event.
+ *
+ * @param parent
+ * @param reader the XML stream to parse
+ * @param deploymentContext the current deployment context
+ * @return the model object obtained by parsing the current element on the stream
+ * @throws XMLStreamException if there was a problem reading the stream
+ */
+ ModelObject load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException;
+
+ /**
+ * Load a model object from a specified location.
+ *
+ * @param parent
+ * @param url the location of an XML document to be loaded
+ * @param type the type of ModelObject that is expected to be in the document
+ * @param deploymentContext the current deployment context
+ * @return the model ojbect loaded from the document
+ * @throws LoaderException if there was a problem loading the document
+ */
+ <MO extends ModelObject> MO load(CompositeComponent parent, URL url, Class<MO> type,
+ DeploymentContext deploymentContext)
+ throws LoaderException;
+
+ /**
+ * Load the component type definition for a given implementation. How the component type information is located is
+ * defined by the implementation specification. It may include loading from an XML sidefile, introspection of some
+ * artifact related to the implementation, some combination of those techniques or any other implementation-defined
+ * mechanism.
+ *
+ * @param parent the parent composite
+ * @param implementation the implementation whose component type should be loaded
+ * @param deploymentContext the current deployment context
+ * @throws LoaderException if there was a problem loading the component type definition
+ */
+ <I extends Implementation<?>> void loadComponentType(CompositeComponent parent, I implementation,
+ DeploymentContext deploymentContext)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
new file mode 100644
index 0000000000..7b22fbbe94
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Base class for Exceptions raised during the loading process. Loader implementations should throw a subclass of this
+ * to indicate the actual problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoaderException extends TuscanyException {
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+
+ public LoaderException() {
+ }
+
+ public LoaderException(String message) {
+ super(message);
+ }
+
+ public LoaderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public LoaderException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being loaded.
+ *
+ * @return the location of the resource that was being loaded
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being loaded.
+ *
+ * @param resourceURI the location of the resource that was being loaded
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java
new file mode 100644
index 0000000000..ea88b99b22
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Registry for XML loaders that can parse a StAX input stream and return model objects.
+ * <p/>
+ * Loaders will typically be contributed to the system by any extension that needs to handle extension specific
+ * information contained in some XML configuration file. The loader can be contributed as a system component with an
+ * autowire reference to this builderRegistry which is used during initialization to actually register. </p> This
+ * builderRegistry can also be used to parse an input stream, dispatching to the appropriate loader for each element
+ * accepted. Loaders can call back to the builderRegistry to load sub-elements that they are not able to handle
+ * directly.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LoaderRegistry extends Loader {
+ /**
+ * Register a loader. This operation will typically be called by a loader during its initialization.
+ *
+ * @param element the element that should be delegated to the contibuted loader
+ * @param loader a loader that is being contributed to the system
+ */
+ <T extends ModelObject> void registerLoader(QName element, StAXElementLoader<T> loader);
+
+ /**
+ * Unregister a loader. This will typically be called by a loader as it is being destroyed.
+ *
+ * @param element the element that was being delegated to the contibuted loader
+ * @param loader a loader that should no longer be used
+ */
+ <T extends ModelObject> void unregisterLoader(QName element, StAXElementLoader<T> loader);
+
+ /**
+ * Regsiter a component type loader.
+ *
+ * @param key a type of implementation this loader can load component types for
+ * @param loader the loader that is being contributed to the system
+ */
+ <I extends Implementation<?>> void registerLoader(Class<I> key, ComponentTypeLoader<I> loader);
+
+ /**
+ * Unregister a component type loader form the system.
+ *
+ * @param key a type of implementation whose loader should be unregistered
+ */
+ <I extends Implementation<?>> void unregisterLoader(Class<I> key);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java
new file mode 100644
index 0000000000..bf48f91a74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamConstants;
+
+/**
+ * Utility functions to support loader implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class LoaderUtil {
+ private LoaderUtil() {
+ }
+
+ /**
+ * Advance the stream to the next END_ELEMENT event skipping any nested content.
+ *
+ * @param reader the reader to advance
+ * @throws XMLStreamException if there was a problem reading the stream
+ */
+ public static void skipToEndElement(XMLStreamReader reader) throws XMLStreamException {
+ int depth = 0;
+ while (true) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ depth++;
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
+ if (depth == 0) {
+ return;
+ }
+ depth--;
+ }
+ }
+ }
+
+ /**
+ * Load the class using the supplied ClassLoader.
+ * The class will be defined so any initializers present will be fired.
+ * As the class is being loaded, the Thread context ClassLoader will be
+ * set to the supplied classloader.
+ *
+ * @param name the name of the class to load
+ * @param cl the classloader to use to load it
+ * @return the class
+ * @throws MissingResourceException if the class could not be found
+ */
+ public static Class<?> loadClass(String name, ClassLoader cl) throws MissingResourceException {
+ final Thread thread = Thread.currentThread();
+ final ClassLoader oldCL = thread.getContextClassLoader();
+ try {
+ thread.setContextClassLoader(cl);
+ return Class.forName(name, true, cl);
+ } catch (ClassNotFoundException e) {
+ throw new MissingResourceException(name, e);
+ } finally {
+ thread.setContextClassLoader(oldCL);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java
new file mode 100644
index 0000000000..89a44083cc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * Exception that indicates that an implementation was not provided.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingImplementationException extends LoaderException {
+ private static final long serialVersionUID = -2917278473974880124L;
+
+ /**
+ * Default constructor.
+ */
+ public MissingImplementationException() {
+ super();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java
new file mode 100644
index 0000000000..4b44332de6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * Exception that indicates that an include was not provided.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingIncludeException extends LoaderException {
+ private static final long serialVersionUID = -2917278473974880124L;
+
+ /**
+ * Default constructor.
+ */
+ public MissingIncludeException() {
+ super();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java
new file mode 100644
index 0000000000..22042d46ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MissingMustOverridePropertyException extends LoaderException {
+ public MissingMustOverridePropertyException(String name) {
+ super(name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
new file mode 100644
index 0000000000..b24806543c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * Exception that indicates an expected resource could not be found. The message should be set to the name of the
+ * resource.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingResourceException extends LoaderException {
+ private static final long serialVersionUID = 3775013318397916445L;
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param resource the resource that could not be found
+ */
+ public MissingResourceException(String resource) {
+ super(resource);
+ }
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param resource the resource that could not be found
+ */
+ public MissingResourceException(String resource, Throwable cause) {
+ super(resource, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java
new file mode 100644
index 0000000000..4672f22a6a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NotOverridablePropertyException extends LoaderException {
+ private static final long serialVersionUID = 1483304023970967982L;
+
+ public NotOverridablePropertyException(String name) {
+ super(name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java
new file mode 100644
index 0000000000..8b569d76fb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+/**
+ * A factory that will create an ObjectFactory for a property
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PropertyObjectFactory {
+ /**
+ * Return an ObjectFactory for instances of a property defined in an XML. The ObjectFactory must return instances
+ * that can safely be supplied to component implementations. If the instance is mutable and isolation between
+ * components is required, then the factory must clone or otherwise protect the implementation from unexpected
+ * modifications by other implementation instances.
+ *
+ * @param property the Property definition that the resulting ObjectFactory must be able to assign to
+ * @param propertyValue The component configuration of the property
+ * @return an ObjectFactory that can produce instances that can be assigned to the supplied Property
+ * @throws LoaderException if there is a problem creating the ObjectFactory
+ */
+ <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> propertyValue)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java
new file mode 100644
index 0000000000..08e873d86e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * A loader that creates a model object from a StAX input stream.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface StAXElementLoader<T extends ModelObject> {
+ /**
+ * Create the model object for an element in an XML stream. When this method returns the stream will be positioned
+ * on the corresponding END_ELEMENT.
+ *
+ * @param parent
+ * @param reader the XML stream reader positioned on the applicable START_ELEMENT
+ * @param deploymentContext the context for the load operation
+ * @return the model object for that element
+ */
+ T load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java
new file mode 100644
index 0000000000..c2521071e1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UndefinedPropertyException extends LoaderException {
+ public UndefinedPropertyException(String name) {
+ super(name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnexpectedElementException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnexpectedElementException.java
new file mode 100644
index 0000000000..cd5542f901
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnexpectedElementException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Exception that indicates that an element was found during loading that when loaded resulted in an unexpected type.
+ * This should not occur if the document being parsed conforms to its schema. The messages set to the name of the
+ * element
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnexpectedElementException extends LoaderException {
+ public UnexpectedElementException(QName element) {
+ super(element.toString());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
new file mode 100644
index 0000000000..b103c50f79
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Exception that indicates an element was encountered that could not be handled.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnrecognizedElementException extends LoaderException {
+ private static final long serialVersionUID = 2549543622209829032L;
+ private final QName element;
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param element the element that could not be handled
+ */
+ public UnrecognizedElementException(QName element) {
+ super(element.toString());
+ setIdentifier(getMessage());
+ this.element = element;
+ }
+
+ public QName getElement() {
+ return element;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java
new file mode 100644
index 0000000000..8e12e970ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * The base representation of an atomic component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AtomicImplementation<T extends ComponentType> extends Implementation<T> {
+ protected AtomicImplementation() {
+ }
+
+ protected AtomicImplementation(T componentType) {
+ super(componentType);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Binding.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Binding.java
new file mode 100644
index 0000000000..3b9a20c38e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Binding.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * The base representation of a binding specified in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class Binding extends ModelObject {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindlessServiceDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindlessServiceDefinition.java
new file mode 100644
index 0000000000..e17269ddff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindlessServiceDefinition.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URI;
+
+/**
+ * Represents a service in a composite, with an interface and a reference target.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BindlessServiceDefinition extends ServiceDefinition {
+ private URI target;
+
+ public BindlessServiceDefinition(String name, ServiceContract contract, boolean remotable, URI target) {
+ super(name, contract, remotable);
+ this.target = target;
+ }
+
+ public BindlessServiceDefinition() {
+ }
+
+ public URI getTarget() {
+ return target;
+ }
+
+ public void setTarget(URI target) {
+ this.target = target;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java
new file mode 100644
index 0000000000..bb973419b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * Represents a reference configured with a binding in a composite
+ *
+ * @version $Rev$ $Date$
+ */
+public class BoundReferenceDefinition<B extends Binding> extends ReferenceDefinition {
+ private B binding;
+
+ public B getBinding() {
+ return binding;
+ }
+
+ public void setBinding(B binding) {
+ this.binding = binding;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java
new file mode 100644
index 0000000000..8c82d8a815
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URI;
+
+/**
+ * Represents a service offered by a component, that has a particular binding associated with it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BoundServiceDefinition<B extends Binding> extends ServiceDefinition {
+ private B binding;
+ private URI target;
+
+ public BoundServiceDefinition(String name, ServiceContract contract, boolean remotable, B binding, URI target) {
+ super(name, contract, remotable);
+ this.binding = binding;
+ this.target = target;
+ }
+
+ public BoundServiceDefinition() {
+ }
+
+ public B getBinding() {
+ return binding;
+ }
+
+ public void setBinding(B binding) {
+ this.binding = binding;
+ }
+
+ public URI getTarget() {
+ return target;
+ }
+
+ public void setTarget(URI target) {
+ this.target = target;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java
new file mode 100644
index 0000000000..de4abbd4e8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents a component.
+ * <p>A component is a configured instance of an implementation. The services provided and consumed
+ * and the available configuration properties are defined by the implementation (represented by
+ * its componentType).</p>
+ * <p>Every component has a name which uniquely identifies it within the scope of the composite
+ * that contains it; the name must be different from the names of all other components, services and references
+ * immediately contained in the composite (directly or through an &lt;include&gt; element).</p>
+ * <p>A component may define a {@link PropertyValue} that overrides the default value of a {@link Property}
+ * defined in the componentType.</p>
+ * <p>It may also define a {@link ReferenceTarget} for a {@link ReferenceDefinition} defined in the componentType.
+ * The ReferenceTarget must resolve to another component or a reference in the enclosing composite.</p>
+ * <p>Components may specify an initialization level that will determine the order in which it will be eagerly
+ * initialized relative to other components from the enclosing composite that are in the same scope. This can be
+ * used to define a startup sequence for components that are otherwise independent. Any initialization required
+ * to resolve references between components will override this initialization order.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentDefinition<I extends Implementation<?>> extends ModelObject {
+ private String name;
+ private Integer initLevel;
+ private final I implementation;
+ private final Map<String, ReferenceTarget> referenceTargets = new HashMap<String, ReferenceTarget>();
+ private final Map<String, PropertyValue<?>> propertyValues = new HashMap<String, PropertyValue<?>>();
+
+ /**
+ * Constructor specifying the component's name and implementation.
+ *
+ * @param name the name of this component
+ * @param implementation the implementation of this component
+ */
+ public ComponentDefinition(String name, I implementation) {
+ this.name = name;
+ this.implementation = implementation;
+ }
+
+ /**
+ * Constructor specifying the implementation of this component.
+ *
+ * @param implementation the implementation of this component
+ */
+ public ComponentDefinition(I implementation) {
+ this.implementation = implementation;
+ }
+
+ /**
+ * Returns the {@link Implementation} of this component.
+ *
+ * @return the implementation of this component
+ */
+ public I getImplementation() {
+ return implementation;
+ }
+
+ /**
+ * Returns the name of this component.
+ *
+ * @return the name of this component
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of this component.
+ *
+ * @param name the name of this component
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the initialization level of this component.
+ *
+ * @return the initialization level of this component
+ */
+ public Integer getInitLevel() {
+ return initLevel;
+ }
+
+ /**
+ * Sets the initialization level of this component.
+ * If set to null then the level from the componentType is used.
+ * If set to zero or a negative value then the component will not be eagerly initialized.
+ *
+ * @param initLevel the initialization level of this component
+ */
+ public void setInitLevel(Integer initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ /**
+ * Returns a live Map of the {@link ReferenceTarget targets} configured by this component definition.
+ *
+ * @return the reference targets configured by this component
+ */
+ public Map<String, ReferenceTarget> getReferenceTargets() {
+ return referenceTargets;
+ }
+
+ /**
+ * Add a reference target configuration to this component.
+ * Any existing configuration for the reference named in the target is replaced.
+ *
+ * @param target the target to add
+ */
+ public void add(ReferenceTarget target) {
+ referenceTargets.put(target.getReferenceName(), target);
+ }
+
+ /**
+ * Returns a live Map of {@link PropertyValue property values} configured by this component definition.
+ *
+ * @return the property values configured by this component
+ */
+ public Map<String, PropertyValue<?>> getPropertyValues() {
+ return propertyValues;
+ }
+
+ /**
+ * Add a property value configuration to this component.
+ * Any existing configuration for the property names in the property value is replaced.
+ *
+ * @param value the property value to add
+ */
+ public void add(PropertyValue<?> value) {
+ propertyValues.put(value.getName(), value);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
new file mode 100644
index 0000000000..5d254d5437
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * <p>The definition of the configurable aspects of an implementation in terms of the services it exposes,
+ * the services it references, and properties that can be used to configure it.</p>
+ * <p>A service represents an addressable interface provided by the implementation. Such a service
+ * may be the target of a wire from another component.</p>
+ * <p>A reference represents a requirement that an implementation has on a service provided by another
+ * component or by a resource outside the SCA system. Such a reference may be the source of a wire to another
+ * component.</p>
+ * <p>A property allows the behaviour of the implementation to be configured through externally set values.</p>
+ * <p>A component type may also declare that it wishes to be initialized upon activation of the scope that
+ * contains it and may specify an order relative to other eagerly initializing components. For example, an
+ * implementation that pre-loads some form of cache could declare that it should be eagerly initialized at
+ * the start of the scope so that the cache load occured on startup rather than first use.</p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentType<S extends ServiceDefinition, R extends ReferenceDefinition, P extends Property<?>>
+ extends ModelObject {
+ private int initLevel;
+ private final Map<String, S> services = new HashMap<String, S>();
+ private final Map<String, R> references = new HashMap<String, R>();
+ private final Map<String, P> properties = new HashMap<String, P>();
+
+ /**
+ * Returns the default initialization level for components of this type.
+ * A value greater than zero indicates that components should be eagerly initialized.
+ *
+ * @return the default initialization level
+ */
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ /**
+ * Sets the default initialization level for components of this type.
+ * A value greater than zero indicates that components should be eagerly initialized.
+ *
+ * @param initLevel default initialization level for components of this type
+ */
+ public void setInitLevel(int initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ /**
+ * Returns true if this component should be eagerly initialized.
+ *
+ * @return true if this component should be eagerly initialized
+ */
+ public boolean isEagerInit() {
+ return initLevel > 0;
+ }
+
+ /**
+ * Obsolete method for indicating that this component should be eagerly initialized.
+ * If true, sets the init level to 50; if false, sets it to zero.
+ *
+ * @param eagerInit flag indicating that this component should be eagerly initialized
+ */
+ @Deprecated
+ public void setEagerInit(boolean eagerInit) {
+ initLevel = eagerInit ? 50 : 0;
+ }
+
+ /**
+ * Returns a live Map of the services provided by the implementation.
+ *
+ * @return a live Map of the services provided by the implementation
+ */
+ public Map<String, S> getServices() {
+ return services;
+ }
+
+ /**
+ * Add a service to those provided by the implementation.
+ * Any existing service with the same name is replaced.
+ *
+ * @param service a service provided by the implementation
+ */
+ public void add(S service) {
+ services.put(service.getName(), service);
+ }
+
+ /**
+ * Returns a live Map of references to services consumed by the implementation.
+ *
+ * @return a live Map of references to services consumed by the implementation
+ */
+ public Map<String, R> getReferences() {
+ return references;
+ }
+
+ /**
+ * Add a reference to a service consumed by the implementation.
+ * Any existing reference with the same name is replaced.
+ *
+ * @param reference a reference to a service consumed by the implementation
+ */
+ public void add(R reference) {
+ references.put(reference.getName(), reference);
+ }
+
+ /**
+ * Returns a live Map of properties that can be used to configure the implementation.
+ *
+ * @return a live Map of properties that can be used to configure the implementation
+ */
+ public Map<String, P> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Add a property that can be used to configure the implementation.
+ * Any existing property with the same name is replaced.
+ *
+ * @param property a property that can be used to configure the implementation
+ */
+ public void add(P property) {
+ properties.put(property.getName(), property);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java
new file mode 100644
index 0000000000..c13cceca8c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A specialization of component type for composite components.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentType<S extends ServiceDefinition,
+ R extends ReferenceDefinition,
+ P extends Property<?>> extends ComponentType<S, R, P> {
+
+ private String name;
+ private final Map<String, ComponentDefinition<? extends Implementation<?>>> components =
+ new HashMap<String, ComponentDefinition<? extends Implementation<?>>>();
+ private final Map<String, Include> includes = new HashMap<String, Include>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ /**
+ * Get all properties including the ones are from included composites
+ * @return
+ */
+ public Map<String, P> getProperties() {
+ Map<String, P> view = new HashMap<String, P>(super.getProperties());
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getProperties());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ /**
+ * Get all references including the ones are from included composites
+ * @return
+ */
+ public Map<String, R> getReferences() {
+ Map<String, R> view = new HashMap<String, R>(super.getReferences());
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getReferences());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ /**
+ * Get all services including the ones are from included composites
+ * @return
+ */
+ public Map<String, S> getServices() {
+ Map<String, S> view = new HashMap<String, S>(super.getServices());
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getServices());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ /**
+ * Get all components including the ones are from included composites
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public Map<String, ComponentDefinition<? extends Implementation<?>>> getComponents() {
+ Map<String, ComponentDefinition<? extends Implementation<?>>> view =
+ new HashMap<String, ComponentDefinition<? extends Implementation<?>>>(components);
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getComponents());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ /**
+ * Get declared properties in this composite type, included doesn't count
+ * @return
+ */
+ public Map<String, P> getDeclaredProperties() {
+ return super.getProperties();
+ }
+
+ /**
+ * Get declared references in this composite type, included doesn't count
+ * @return
+ */
+ public Map<String, R> getDeclaredReferences() {
+ return super.getReferences();
+ }
+
+ /**
+ * Get declared services in this composite type, included doesn't count
+ * @return
+ */
+ public Map<String, S> getDeclaredServices() {
+ return super.getServices();
+ }
+
+ /**
+ * Get declared components in this composite type, included doesn't count
+ * @return
+ */
+ public Map<String, ComponentDefinition<? extends Implementation<?>>> getDeclaredComponents() {
+ return components;
+ }
+
+ public void add(ComponentDefinition<? extends Implementation<?>> componentDefinition) {
+ components.put(componentDefinition.getName(), componentDefinition);
+ }
+
+ public Map<String, Include> getIncludes() {
+ return includes;
+ }
+
+ public void add(Include include) {
+ includes.put(include.getName(), include);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java
new file mode 100644
index 0000000000..6948c52286
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URL;
+
+/**
+ * A specialization of an implementation associated with composite components
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeImplementation extends Implementation<CompositeComponentType> {
+ private String name;
+ private URL scdlLocation;
+ private ClassLoader classLoader;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public URL getScdlLocation() {
+ return scdlLocation;
+ }
+
+ public void setScdlLocation(URL scdlLocation) {
+ this.scdlLocation = scdlLocation;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java
new file mode 100644
index 0000000000..c98c113d95
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Representation of the type of data associated with an operation. Data is represented in two forms: the physical form
+ * used by the runtime and a logical form used by the assembly. The physical form is a Java Type because the runtime is
+ * written in Java. This may be the same form used by the application but it may not; for example, an application that
+ * is performing stream processing may want a physical form such as an {@link java.io.InputStream InputStream} to
+ * semantially operate on application data such as a purchase order. The logical description is that used by the
+ * assembly model and is an identifier into some well-known type space; examples may be a Java type represented by its
+ * Class or an XML type represented by its QName. Every data type may also contain metadata describing the expected
+ * data; for example, it could specify a preferred data binding technology or the size of a typical instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataType<L> extends ModelObject {
+ private String dataBinding = Object.class.getName();
+
+ private final Type physical;
+
+ private final L logical;
+
+ private final Map<String, Object> metadata = new HashMap<String, Object>();
+
+ /**
+ * Construct a data type specifying the physical and logical types.
+ *
+ * @param physical the physical class used by the runtime
+ * @param logical the logical type
+ * @see #getLogical()
+ */
+ public DataType(Type physical, L logical) {
+ this.physical = physical;
+ this.logical = logical;
+ if (physical instanceof Class) {
+ this.dataBinding = ((Class) physical).getName();
+ }
+ }
+
+ public DataType(String dataBinding, Type physical, L logical) {
+ this.dataBinding = dataBinding;
+ this.physical = physical;
+ this.logical = logical;
+ }
+
+ /**
+ * Returns the physical type used by the runtime.
+ *
+ * @return the physical type used by the runtime
+ */
+ public Type getPhysical() {
+ return physical;
+ }
+
+ /**
+ * Returns the logical identifier used by the assembly. The type of this value identifies the logical type system in
+ * use. Known values are: <ul> <li>a java.lang.reflect.Type identifies a Java type by name and ClassLoader; this
+ * includes Java Classes as they are specializations of Type</li> <li>a javax.xml.namespace.QName identifies an XML
+ * type by local name and namespace</li> </ul>
+ *
+ * @return the logical type name
+ */
+ public L getLogical() {
+ return logical;
+ }
+
+ /**
+ * Returns all metadata about this type.
+ *
+ * @return all metadata about this type
+ */
+ public Map<String, ?> getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Returns the specified metadata item or null if not present.
+ *
+ * @param name the name of the metadata item
+ * @return the value, or null if not present
+ */
+ public Object getMetadata(String name) {
+ return metadata.get(name);
+ }
+
+ /**
+ * Sets the specified metadata value. A null value undefines it.
+ *
+ * @param name the name of the metadata item
+ * @param value the value, or null to undefine
+ * @return the old value for the item, or null if not present
+ */
+ public Object setMetadata(String name, Object value) {
+ if (value == null) {
+ return metadata.remove(name);
+ } else {
+ return metadata.put(name, value);
+ }
+ }
+
+ public String getDataBinding() {
+ if (dataBinding == null) {
+ // databinding is not set at the DataType level, check the operation
+ Operation<?> operation = (Operation<?>) getMetadata(Operation.class.getName());
+ if (operation != null) {
+ return operation.getDataBinding();
+ }
+ }
+ return dataBinding;
+ }
+
+ /**
+ * @param dataBinding the dataBinding to set
+ */
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ public int hashCode() {
+ int result;
+ result = dataBinding != null ? dataBinding.hashCode() : 0;
+ result = 29 * result + (physical != null ? physical.hashCode() : 0);
+ result = 29 * result + (logical != null ? logical.hashCode() : 0);
+ // Commented the following line out since it causes infinite loop from Operation.hashCode()
+ // if the metadata map contains the Operation
+ // result = 29 * result + (metadata != null ? metadata.hashCode() : 0);
+ return result;
+ }
+
+ public boolean equals(Object o){
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final DataType dataType = (DataType) o;
+
+ if (dataBinding != null ? !dataBinding.equals(dataType.dataBinding) : dataType.dataBinding != null) {
+ return false;
+ }
+ if (logical != null ? !logical.equals(dataType.logical) : dataType.logical != null) {
+ return false;
+ }
+ return !(physical != null ? !physical.equals(dataType.physical) : dataType.physical != null);
+
+ }
+
+// @SuppressWarnings("unchecked")
+// public boolean equals(Object o) {
+// if (this == o) {
+// return true;
+// }
+// if (o == null || getClass() != o.getClass()) {
+// return false;
+// }
+//
+// final DataType dataType = (DataType) o;
+//
+// if (logical instanceof Class && dataType.logical instanceof Class) {
+// Class<?> logicalClass = (Class<?>) logical;
+// Class<?> targetLogicalClass = (Class<?>) dataType.logical;
+// if (!logicalClass.isAssignableFrom(targetLogicalClass)) {
+// return false;
+// }
+// } else {
+// if (logical != null ? !logical.equals(dataType.logical) : dataType.logical != null) {
+// return false;
+// }
+// }
+// if (physical instanceof Class && dataType.physical instanceof Class) {
+// Class<?> physicalClass = (Class<?>) physical;
+// Class<?> physicalTargetClass = (Class<?>) dataType.physical;
+// if (dataBinding != null
+// && dataType.dataBinding != null
+// && dataBinding.equals(physicalClass.getName())
+// && dataType.dataBinding.equals(physicalTargetClass.getName())) {
+// return physicalClass.isAssignableFrom(physicalTargetClass);
+// }
+// if (!physicalClass.isAssignableFrom(physicalTargetClass)) {
+// return false;
+// }
+// return !(dataBinding != null ? !dataBinding.equals(dataType.dataBinding) : dataType.dataBinding != null);
+//
+//
+// }
+//
+// if (dataBinding != null ? !dataBinding.equals(dataType.dataBinding) : dataType.dataBinding != null) {
+// return false;
+// }
+//
+// return !(physical != null ? !physical.equals(dataType.physical) : dataType.physical != null);
+// }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(physical).append(" ").append(dataBinding).append(" ").append(logical);
+ return sb.toString();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java
new file mode 100644
index 0000000000..8520ab49e8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * Represents a component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class Implementation<T extends ComponentType> extends ModelObject {
+ private T componentType;
+
+ protected Implementation() {
+ }
+
+ protected Implementation(T componentType) {
+ this.componentType = componentType;
+ }
+
+ public T getComponentType() {
+ return componentType;
+ }
+
+ public void setComponentType(T componentType) {
+ this.componentType = componentType;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java
new file mode 100644
index 0000000000..ac320a2b5c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URL;
+
+/**
+ * Model object that represents the include of a composite by value.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Include extends ModelObject {
+ private String name;
+ private URL scdlLocation;
+ private CompositeComponentType included;
+
+ /**
+ * Returns the name of the composite that is being included.
+ * @return the name of the composite that is being included
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the composite that is being included.
+ * @param name the name of the composite that is being included
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the location of the SCDL for composite being included.
+ * @return the location of the SCDL for composite being included
+ */
+ public URL getScdlLocation() {
+ return scdlLocation;
+ }
+
+ /**
+ * Sets the location of the SCDL for composite being included.
+ * @param scdlLocation the location of the SCDL for composite being included
+ */
+ public void setScdlLocation(URL scdlLocation) {
+ this.scdlLocation = scdlLocation;
+ }
+
+ /**
+ * Returns the composite that was included.
+ * @return the composite that was included
+ */
+ public CompositeComponentType getIncluded() {
+ return included;
+ }
+
+ /**
+ * Sets the composite that was included.
+ * @param included the composite that was included
+ */
+ public void setIncluded(CompositeComponentType included) {
+ this.included = included;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java
new file mode 100644
index 0000000000..4e15e353c6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * Represents the interaction scope specifed for a service
+ *
+ * @version $Rev$ $Date$
+ */
+public enum InteractionScope {
+ CONVERSATIONAL,
+ NONCONVERSATIONAL
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java
new file mode 100644
index 0000000000..2d5a0802e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The base class for assembly model subtypes
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ModelObject {
+ private final Map<Object, Object> extensions = new HashMap<Object, Object>();
+
+ protected ModelObject() {
+ }
+
+ public Map<Object, Object> getExtensions() {
+ return extensions;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java
new file mode 100644
index 0000000000..f7ec8759f8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * Enumeration for multiplicity.
+ */
+public enum Multiplicity {
+ /**
+ * Indicates a relationship that is optionally connected to the requestor and which, if supplied, must be connected
+ * to exactly one provider.
+ */
+ ZERO_ONE,
+
+ /**
+ * Indicates a relationship that must be connected between exactly one requestor and exactly one provider.
+ */
+ ONE_ONE,
+
+ /**
+ * Indicates a relationship that is optionally connects the requestor to zero to unbounded providers.
+ */
+ ZERO_N,
+
+ /**
+ * Indicates a relationship that must be connected at the requestor and which connects it to zero to unbounded
+ * providers.
+ */
+ ONE_N
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
new file mode 100644
index 0000000000..b461f0e730
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
@@ -0,0 +1,351 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.idl.WrapperInfo;
+
+/**
+ * Represents an operation that is part of a service contract. The type paramter of this operation identifies the
+ * logical type system for all data types.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Operation<T> {
+ private static final String NAME = Operation.class.getName();
+
+ protected Map<String, Object> metaData;
+
+ private final String name;
+
+ private final DataType<T> outputType;
+
+ private final DataType<List<DataType<T>>> inputType;
+
+ private final List<DataType<T>> faultTypes;
+
+ private boolean nonBlocking;
+
+ private ServiceContract<T> contract;
+
+ private boolean callback;
+
+ private String dataBinding;
+
+ private boolean wrapperStyle;
+ private WrapperInfo wrapper;
+
+ /**
+ * Construct a minimally-specified operation
+ *
+ * @param name the name of the operation
+ * @param inputType the data types of parameters passed to the operation
+ * @param outputType the data type returned by the operation
+ * @param faultTypes the data type of faults raised by the operation
+ */
+ public Operation(String name,
+ DataType<List<DataType<T>>> inputType,
+ DataType<T> outputType,
+ List<DataType<T>> faultTypes) {
+ this(name, inputType, outputType, faultTypes, false, null);
+ }
+
+ /**
+ * Construct an operation
+ *
+ * @param name the name of the operation
+ * @param inputType the data types of parameters passed to the operation
+ * @param outputType the data type returned by the operation
+ * @param faultTypes the data type of faults raised by the operation
+ * @param nonBlocking if the operation is non-blocking
+ * @param dataBinding the data-binding type required by the operation
+ */
+ public Operation(final String name,
+ final DataType<List<DataType<T>>> inputType,
+ final DataType<T> outputType,
+ final List<DataType<T>> faultTypes,
+ boolean nonBlocking,
+ String dataBinding) {
+ super();
+ this.name = name;
+ List<DataType<T>> types = Collections.emptyList();
+ this.inputType = (inputType != null) ? inputType : new DataType<List<DataType<T>>>(Object[].class, types);
+ this.outputType = (outputType != null) ? outputType : new DataType<T>(void.class, null);
+ this.faultTypes = (faultTypes == null) ? types : faultTypes;
+ this.nonBlocking = nonBlocking;
+ this.dataBinding = dataBinding;
+ // Register the operation with the types
+ for (DataType<?> d : this.inputType.getLogical()) {
+ d.setMetadata(NAME, this);
+ }
+ this.outputType.setMetadata(NAME, this);
+ for (DataType<?> d : this.faultTypes) {
+ d.setMetadata(NAME, this);
+ }
+ }
+
+ /**
+ * Returns the service contract the operation is part of.
+ *
+ * @return the service contract the operation is part of.
+ */
+ public ServiceContract<T> getServiceContract() {
+ return contract;
+ }
+
+ /**
+ * Sets the service contract the operation is part of.
+ *
+ * @param contract the service contract the operation is part of.
+ */
+ public void setServiceContract(ServiceContract<T> contract) {
+ this.contract = contract;
+ }
+
+ /**
+ * Returns true if the operation is part of the callback contract.
+ *
+ * @return true if the operation is part of the callback contract.
+ */
+ public boolean isCallback() {
+ return callback;
+ }
+
+ /**
+ * Sets whether the operation is part of the callback contract.
+ *
+ * @param callback whether the operation is part of the callback contract.
+ */
+ public void setCallback(boolean callback) {
+ this.callback = callback;
+ }
+
+ /**
+ * Returns the name of the operation.
+ *
+ * @return the name of the operation
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the data type returned by the operation.
+ *
+ * @return the data type returned by the operation
+ */
+ public DataType<T> getOutputType() {
+ return outputType;
+ }
+
+ /**
+ * Returns the data types of the parameters passed to the operation.
+ * <p/>
+ * The inputType's logical type is a list of DataTypes which describes the parameter types
+ *
+ * @return the data types of the parameters passed to the operation
+ */
+ public DataType<List<DataType<T>>> getInputType() {
+ return inputType;
+ }
+
+ /**
+ * Returns the data types of the faults raised by the operation.
+ *
+ * @return the data types of the faults raised by the operation
+ */
+ public List<DataType<T>> getFaultTypes() {
+ if (faultTypes == null) {
+ return Collections.emptyList();
+ }
+ return faultTypes;
+ }
+
+ /**
+ * Returns true if the operation is non-blocking. A non-blocking operation may not have completed execution at the
+ * time an invocation of the operation returns.
+ *
+ * @return true if the operation is non-blocking
+ */
+ public boolean isNonBlocking() {
+ return nonBlocking;
+ }
+
+ /**
+ * Returns the data binding type specified for the operation or null.
+ *
+ * @return the data binding type specified for the operation or null.
+ */
+ public String getDataBinding() {
+ return (dataBinding == null && contract != null) ? contract.getDataBinding() : dataBinding;
+ }
+
+ /**
+ * Set the databinding for this operation
+ *
+ * @param dataBinding The databinding
+ */
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ /**
+ * Returns a map of metadata key to value mappings for the operation.
+ *
+ * @return a map of metadata key to value mappings for the operation.
+ */
+ public Map<String, Object> getMetaData() {
+ if (metaData == null) {
+ return Collections.emptyMap();
+ }
+ return metaData;
+ }
+
+ /**
+ * Adds metadata associated with the operation.
+ *
+ * @param key the metadata key
+ * @param val the metadata value
+ */
+ public void setMetaData(String key, Object val) {
+ if (metaData == null) {
+ metaData = new HashMap<String, Object>();
+ }
+ metaData.put(key, val);
+ }
+
+ /**
+ * Sets if the operation is non-blocking
+ */
+ public void setNonBlocking(boolean nonBlocking) {
+ this.nonBlocking = nonBlocking;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final Operation operation = (Operation) o;
+
+ if (name != null ? !name.equals(operation.name) : operation.name != null) {
+ return false;
+ }
+
+ // HACK: If the operation is mappable, then the equality test is relaxed
+ if (isMappable()) {
+ return true;
+ }
+
+ if (faultTypes == null && operation.faultTypes != null) {
+ return false;
+ } else if (faultTypes != null
+ && operation.faultTypes != null
+ && faultTypes.size() != 0
+ && operation.faultTypes.size() != 0) {
+ if (faultTypes.size() < operation.faultTypes.size()) {
+ return false;
+ } else {
+ for (int i = 0; i < operation.faultTypes.size(); i++) {
+ if (!faultTypes.get(i).equals(operation.faultTypes.get(i))) {
+ return false;
+ }
+ }
+ }
+ }
+
+ if (inputType != null ? !inputType.equals(operation.inputType) : operation.inputType != null) {
+ return false;
+ }
+ return !(outputType != null ? !outputType.equals(operation.outputType) : operation.outputType != null);
+ }
+
+ public int hashCode() {
+ int result;
+ result = name != null ? name.hashCode() : 0;
+ // HACK:
+ if (isMappable()) {
+ return result;
+ }
+ result = 29 * result + (outputType != null ? outputType.hashCode() : 0);
+ result = 29 * result + (inputType != null ? inputType.hashCode() : 0);
+ result = 29 * result + (faultTypes != null ? faultTypes.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Returns true if the operation may be mapped to another target operation through an mediation
+ */
+ private boolean isMappable() {
+ if (contract != null) {
+ return contract.isRemotable();
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns true if the operation is wrapper style
+ *
+ * @return the wrapperStyle
+ */
+ public boolean isWrapperStyle() {
+ return wrapperStyle;
+ }
+
+ /**
+ * Return the Wrapper information for this operation is it's wrapper style
+ *
+ * @return The Wrapper
+ */
+ public WrapperInfo getWrapper() {
+ if (!isWrapperStyle()) {
+ throw new IllegalStateException("The operation is not wrapper style.");
+ } else {
+ return wrapper;
+ }
+ }
+
+ /**
+ * @param wrapper the wrapper to set
+ */
+ public void setWrapper(WrapperInfo wrapper) {
+ this.wrapper = wrapper;
+ }
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ public void setWrapperStyle(boolean wrapperStyle) {
+ this.wrapperStyle = wrapperStyle;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java
new file mode 100644
index 0000000000..cc86b2670a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.model;
+
+/**
+ * <ul>
+ * <li>no – the value may not be overridden by the higher composite. In this
+ * case, a value must be provided for the reference or property as part of its
+ * declaration.
+ * <li>may – the value may be overridden by the composite. This is the default
+ * for references.
+ * <li>must – no value is specified and the using composite must specify one.
+ * </ul>
+ */
+public enum OverrideOptions {
+ NO, MAY, MUST
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java
new file mode 100644
index 0000000000..700b099da7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * A component property
+ *
+ * @version $Rev$ $Date$
+ */
+public class Property<T> extends ModelObject {
+ private String name;
+ private ObjectFactory<T> defaultValueFactory;
+ private QName xmlType;
+ private Class<T> javaType;
+ private boolean many;
+ private OverrideOptions override;
+ private Document defaultValue;
+
+ public Property() {
+ }
+
+ public Property(String name, QName xmlType, Class<T> javaType) {
+ this.name = name;
+ this.xmlType = xmlType;
+ this.javaType = javaType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ObjectFactory<T> getDefaultValueFactory() {
+ return defaultValueFactory;
+ }
+
+ public void setDefaultValueFactory(ObjectFactory<T> factory) {
+ this.defaultValueFactory = factory;
+ }
+
+ public QName getXmlType() {
+ return xmlType;
+ }
+
+ public void setXmlType(QName xmlType) {
+ this.xmlType = xmlType;
+ }
+
+ public Class<T> getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(Class<T> javaType) {
+ this.javaType = javaType;
+ }
+
+ public boolean isMany() {
+ return many;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ public OverrideOptions getOverride() {
+ return override;
+ }
+
+ public void setOverride(OverrideOptions override) {
+ this.override = override;
+ }
+
+ public Document getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(Document defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java
new file mode 100644
index 0000000000..93eaa74f52
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.w3c.dom.Document;
+
+/**
+ * Represents a configured component property
+ *
+ * @version $Rev$ $Date$
+ */
+public class PropertyValue<T> extends ModelObject {
+ private String name;
+ private String source;
+ private String file;
+ private Document value;
+ private ObjectFactory<T> valueFactory;
+
+ public PropertyValue() {
+ }
+
+ /**
+ * Constructor specifying the name of a property and the XPath source expression.
+ *
+ * @param name the name of the property which this value is for
+ * @param source an XPath expression whose result will be the actual value
+ * @param file A URI that the property value can be loaded from
+ */
+ public PropertyValue(String name, String source, String file) {
+ this.name = name;
+ this.source = source;
+ this.file = file;
+ }
+
+ /**
+ * @param name
+ * @param value
+ */
+ public PropertyValue(String name, Document value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public PropertyValue(String name, ObjectFactory<T> valueFactory) {
+ this.name = name;
+ this.valueFactory = valueFactory;
+ }
+
+ /**
+ * Returns the name of the property that this value is for.
+ * @return the name of the property that this value is for
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the property that this value is for.
+ * @param name the name of the property that this value is for
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns an XPath expression that should be evaluated to get the actual property value.
+ *
+ * @return an XPath expression that should be evaluated to get the actual property value
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * Sets an XPath expression that should be evaluated to get the actual property value.
+ * @param source an XPath expression that should be evaluated to get the actual property value
+ */
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public ObjectFactory<T> getValueFactory() {
+ return valueFactory;
+ }
+
+ public void setValueFactory(ObjectFactory<T> valueFactory) {
+ this.valueFactory = valueFactory;
+ }
+
+ public Document getValue() {
+ return value;
+ }
+
+ public void setValue(Document value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the file
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * @param file the file to set
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java
new file mode 100644
index 0000000000..f167272705
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * Represents a component reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceDefinition extends ModelObject {
+ private String name;
+ private ServiceContract serviceContract;
+ private Multiplicity multiplicity;
+ private boolean autowire;
+ private boolean required;
+
+ public ReferenceDefinition() {
+ }
+
+ public ReferenceDefinition(String name, ServiceContract serviceContract) {
+ this.name = name;
+ this.serviceContract = serviceContract;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ServiceContract<?> getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ public void setMultiplicity(Multiplicity multiplicity) {
+ this.multiplicity = multiplicity;
+ }
+
+ public boolean isAutowire() {
+ return autowire;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java
new file mode 100644
index 0000000000..db0bdb2b22
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents the set of targets configured on a reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTarget extends ModelObject {
+ private String referenceName;
+ private List<URI> targets = new ArrayList<URI>();
+
+ public String getReferenceName() {
+ return referenceName;
+ }
+
+ public void setReferenceName(String referenceName) {
+ this.referenceName = referenceName;
+ }
+
+ public List<URI> getTargets() {
+ return targets;
+ }
+
+ public void addTarget(URI target) {
+ targets.add(target);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
new file mode 100644
index 0000000000..9995cd4ec5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * The default implementation scopes supported by assemblies.
+ */
+public class Scope {
+ public static final Scope STATELESS = new Scope("STATELESS");
+ public static final Scope REQUEST = new Scope("REQUEST");
+ public static final Scope SESSION = new Scope("SESSION");
+ public static final Scope MODULE = new Scope("MODULE");
+ public static final Scope COMPOSITE = new Scope("COMPOSITE");
+ public static final Scope UNDEFINED = new Scope("UNDEFINED");
+
+ private String scope;
+
+ public Scope(String scope) {
+ this.scope = scope.toUpperCase().intern();
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final Scope scope1 = (Scope) o;
+ return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null);
+ }
+
+ public int hashCode() {
+ return scope != null ? scope.hashCode() : 0;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
new file mode 100644
index 0000000000..91d5611689
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Base class representing service contract information
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ServiceContract<T> extends ModelObject {
+ protected InteractionScope interactionScope;
+ protected boolean remotable;
+ protected Class<?> interfaceClass;
+ protected String interfaceName;
+ protected String callbackName;
+ protected Class<?> callbackClass;
+ protected Map<String, Operation<T>> operations;
+ protected Map<String, Operation<T>> callbackOperations;
+ protected String dataBinding;
+ protected Map<String, Object> metaData;
+
+ protected ServiceContract() {
+ }
+
+ protected ServiceContract(Class<?> interfaceClass) {
+ this.interfaceClass = interfaceClass;
+ }
+
+ protected ServiceContract(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ /**
+ * Returns the interface name for the contract
+ *
+ * @return the interface name for the contract
+ */
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ /**
+ * Sets the interface name for the contract
+ */
+ public void setInterfaceName(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ /**
+ * Returns the class used to represent the service contract
+ */
+ public Class<?> getInterfaceClass() {
+ return interfaceClass;
+ }
+
+ /**
+ * Sets the class used to represent the service contract
+ */
+ public void setInterfaceClass(Class<?> interfaceClass) {
+ this.interfaceClass = interfaceClass;
+ }
+
+ /**
+ * Returns the service interaction scope
+ */
+ public InteractionScope getInteractionScope() {
+ return interactionScope;
+ }
+
+ /**
+ * Sets the service interaction scope
+ */
+ public void setInteractionScope(InteractionScope interactionScope) {
+ this.interactionScope = interactionScope;
+ }
+
+ /**
+ * @return the remotable
+ */
+ public boolean isRemotable() {
+ return remotable;
+ }
+
+ /**
+ * @param remotable the remotable to set
+ */
+ public void setRemotable(boolean remotable) {
+ this.remotable = remotable;
+ }
+
+ /**
+ * Returns the name of the callback or null if the contract is unidirectional
+ */
+ public String getCallbackName() {
+ return callbackName;
+ }
+
+ /**
+ * Sets the name of the callback service
+ */
+ public void setCallbackName(String callbackName) {
+ this.callbackName = callbackName;
+ }
+
+ /**
+ * Returns the name of the callback service
+ */
+ public Class<?> getCallbackClass() {
+ return callbackClass;
+ }
+
+ public void setCallbackClass(Class<?> callbackClass) {
+ this.callbackClass = callbackClass;
+ }
+
+ public Map<String, Operation<T>> getOperations() {
+ if (operations == null) {
+ return Collections.emptyMap();
+ }
+ return Collections.unmodifiableMap(operations);
+ }
+
+ public void setOperations(Map<String, Operation<T>> operations) {
+ for (Operation<T> operation : operations.values()) {
+ operation.setServiceContract(this);
+ }
+ this.operations = operations;
+ }
+
+ public Map<String, Operation<T>> getCallbackOperations() {
+ if (callbackOperations == null) {
+ return Collections.emptyMap();
+ }
+ return Collections.unmodifiableMap(callbackOperations);
+ }
+
+ public void setCallbackOperations(Map<String, Operation<T>> callbacksOperations) {
+ for (Operation<T> operation : callbacksOperations.values()) {
+ operation.setServiceContract(this);
+ operation.setCallback(true);
+ }
+ this.callbackOperations = callbacksOperations;
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+ /**
+ * Returns a map of metadata key to value mappings for the operation.
+ *
+ * @return a map of metadata key to value mappings for the operation.
+ */
+ public Map<String, Object> getMetaData() {
+ if (metaData == null) {
+ return Collections.emptyMap();
+ }
+ return metaData;
+ }
+
+ /**
+ * Adds metadata associated with the operation.
+ *
+ * @param key the metadata key
+ * @param val the metadata value
+ */
+ public void setMetaData(String key, Object val) {
+ if (metaData == null) {
+ metaData = new HashMap<String, Object>();
+ }
+ metaData.put(key, val);
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final ServiceContract that = (ServiceContract) o;
+
+ if (callbackName != null ? !callbackName.equals(that.callbackName) : that.callbackName != null) {
+ return false;
+ }
+ if (callbackOperations != null ? !callbackOperations.equals(that.callbackOperations)
+ : that.callbackOperations != null) {
+ return false;
+ }
+ if (interfaceClass != null ? !interfaceClass.equals(that.interfaceClass) : that.interfaceClass != null) {
+ return false;
+ }
+ if (interfaceName != null ? !interfaceName.equals(that.interfaceName) : that.interfaceName != null) {
+ return false;
+ }
+ return !(operations != null ? !operations.equals(that.operations) : that.operations != null);
+
+ }
+
+ public int hashCode() {
+ int result;
+ result = interfaceClass != null ? interfaceClass.hashCode() : 0;
+ result = 29 * result + (interfaceName != null ? interfaceName.hashCode() : 0);
+ result = 29 * result + (callbackName != null ? callbackName.hashCode() : 0);
+ result = 29 * result + (operations != null ? operations.hashCode() : 0);
+ result = 29 * result + (callbackOperations != null ? callbackOperations.hashCode() : 0);
+ return result;
+ }
+
+ public String toString() {
+ if (interfaceName != null) {
+ return new StringBuilder().append("ServiceContract[").append(interfaceName).append("]").toString();
+ } else if (interfaceClass != null) {
+ return new StringBuilder().append("ServiceContract[").append(interfaceClass.getName()).append("]")
+ .toString();
+ } else {
+ return super.toString();
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java
new file mode 100644
index 0000000000..1667ff9272
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+/**
+ * Represents a service offered by a component
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceDefinition extends ModelObject {
+ private String name;
+ private ServiceContract serviceContract;
+ private boolean remotable;
+ private String callbackRefName;
+
+ public ServiceDefinition() {
+ }
+
+ public ServiceDefinition(String name, ServiceContract serviceContract, boolean remotable) {
+ this.name = name;
+ this.serviceContract = serviceContract;
+ this.remotable = remotable;
+ }
+
+ public ServiceDefinition(String name, ServiceContract serviceContract, boolean remotable, String callbackRefName) {
+ this.name = name;
+ this.serviceContract = serviceContract;
+ this.remotable = remotable;
+ this.callbackRefName = callbackRefName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ServiceContract<?> getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public boolean isRemotable() {
+ return remotable;
+ }
+
+ public void setRemotable(boolean remotable) {
+ this.remotable = remotable;
+ }
+
+ /**
+ * Returns the callback name.
+ */
+ public String getCallbackReferenceName() {
+ return callbackRefName;
+ }
+
+ public void setCallbackReferenceName(String callbackRefName) {
+ this.callbackRefName = callbackRefName;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java
new file mode 100644
index 0000000000..7ae91811b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URI;
+
+/**
+ * Represents a wire specified in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireDefinition extends ModelObject {
+ private URI source;
+ private URI target;
+
+ public URI getSource() {
+ return source;
+ }
+
+ public void setSource(URI source) {
+ this.source = source;
+ }
+
+ public URI getTarget() {
+ return target;
+ }
+
+ public void setTarget(URI target) {
+ this.target = target;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java
new file mode 100644
index 0000000000..2c85f846ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.policy;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * A registry for policy builders that dispatches to the appropriate builder when converting an assembly to runtime
+ * artifacts. Policy builders operate on either a source- or target-side wires.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyBuilderRegistry {
+
+ int INITIAL = 0;
+ int EXTENSION = 1;
+ int FINAL = 2;
+
+ /**
+ * Registers a target-side policy builder. Called by extensions to register their builders.
+ *
+ * @param phase the phase hwne the builder must be run
+ * @param builder the builder to register
+ */
+ void registerTargetBuilder(int phase, TargetPolicyBuilder builder);
+
+ /**
+ * Registers a source-side policy builder. Called by extensions to register their builders.
+ *
+ * @param phase the phase hwne the builder must be run
+ * @param builder the builder to register
+ */
+ void registerSourceBuilder(int phase, SourcePolicyBuilder builder);
+
+ /**
+ * Evaluates source-side policy metadata for referenceDefinition and updates the curresponding collection of wire
+ * configurations
+ *
+ * @throws BuilderException
+ */
+ void buildSource(ReferenceDefinition referenceDefinition, OutboundWire wire) throws BuilderException;
+
+ /**
+ * Evaluates target-side policy metadata for configured reference and updates the curresponding collection of wire
+ * configurations
+ *
+ * @throws BuilderException
+ */
+ void buildTarget(ServiceDefinition serviceDefinition, InboundWire wire) throws BuilderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java
new file mode 100644
index 0000000000..66a7dd0e20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.policy;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Implementations contribute {@link org.apache.tuscany.spi.wire.Interceptor}s or {@link
+ * org.apache.tuscany.spi.wire.MessageHandler}s that handle source-side policy on a wire.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface SourcePolicyBuilder {
+
+ /**
+ * @param referenceDefinition
+ * @param wire
+ * @throws BuilderException
+ */
+ void build(ReferenceDefinition referenceDefinition, OutboundWire wire) throws BuilderException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java
new file mode 100644
index 0000000000..79f40e6558
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.policy;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+/**
+ * Implementations contribute {@link org.apache.tuscany.spi.wire.Interceptor}s or {@link
+ * org.apache.tuscany.spi.wire.MessageHandler}s that handle target-side policy on a wire.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface TargetPolicyBuilder {
+
+ /**
+ * @param serviceDefinition
+ * @param wire
+ * @throws BuilderException
+ */
+ void build(ServiceDefinition serviceDefinition, InboundWire wire) throws BuilderException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java
new file mode 100644
index 0000000000..777cfbd3e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.services;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Empty interface for a service component that has no operations.
+ * This can be used as a default service interface by components that
+ * do not wish the base class to be used as the interface as specified
+ * by the defaulting rules.
+ *
+ * @version $Rev$ $Date$
+ */
+@Service
+public interface VoidService {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java
new file mode 100644
index 0000000000..4da522d196
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.services.artifact;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Description of some packaged artifact such as a JAR file or a Composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Artifact {
+
+ /* Artifact group */
+ private String group;
+
+ /* Artifact name */
+ private String name;
+
+ /* Artifact version */
+ private String version;
+
+ /* Artifact classifier */
+ private String classifier;
+
+ /* Artifact type */
+ private String type;
+
+ /* Artifact url */
+ private URL url;
+
+ /* Transitive dependencies */
+ private Set<Artifact> dependencies = new HashSet<Artifact>();
+
+ /**
+ * Adds a transitive dependency to the artifact.
+ *
+ * @param artifact Dependency to be added.
+ */
+ public void addDependency(Artifact artifact) {
+ dependencies.add(artifact);
+ }
+
+ /**
+ * Gets the URLs for all the transitive dependencies.
+ *
+ * @return Sets of URLs for all the transitive dependencies.
+ */
+ public Set<URL> getUrls() {
+
+ Set<URL> urls = new HashSet<URL>();
+
+ for (Artifact artifact : dependencies) {
+ urls.add(artifact.getUrl());
+ }
+ urls.add(getUrl());
+
+ return urls;
+
+ }
+
+ /**
+ * Returns the name of a logical grouping to which this artifact belongs. For example, this might represent the
+ * original publisher of the artifact.
+ *
+ * @return the name of a logical grouping to which this artifact belongs
+ */
+ public String getGroup() {
+ return group;
+ }
+
+ /**
+ * Sets the name of a logical grouping to which this artifact belongs.
+ *
+ * @param group the name of a logical grouping to which this artifact belongs
+ */
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+ /**
+ * Returns the name of an artifact.
+ *
+ * @return the name of an artifact
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of an artifact.
+ *
+ * @param name the name of an artifact
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the version of an artifact.
+ *
+ * @return the version of an artifact
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the version of an artifact.
+ *
+ * @param version the version of an artifact
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Returns a way of classifying an artifact. This can be used to distinguish variants of an artifact that provide
+ * the same function but which may have platform specific requirements. For example, it may contain the name of a
+ * hardware platform for artifacts that contain native code.
+ *
+ * @return a way of classifying an artifact
+ */
+ public String getClassifier() {
+ return classifier;
+ }
+
+ /**
+ * Sets a way of classifying an artifact
+ *
+ * @param classifier a way of classifying an artifact
+ */
+ public void setClassifier(String classifier) {
+ this.classifier = classifier;
+ }
+
+ /**
+ * Returns the type of artifact.
+ *
+ * @return the type of artifact
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the type of artifact.
+ *
+ * @param type the type of artifact
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns a URL from which the artifact can be obtained.
+ *
+ * @return a URL from which the artifact can be obtained
+ */
+ public URL getUrl() {
+ return url;
+ }
+
+ /**
+ * Sets a URL from which the artifact can be obtained.
+ *
+ * @param url a URL from which the artifact can be obtained
+ */
+ public void setUrl(URL url) {
+ this.url = url;
+ }
+
+
+ public String toString() {
+ StringBuilder buf = new StringBuilder();
+ buf.append(group).append(':').append(name).append(':').append(version).append(':').append(type);
+ return buf.toString();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java
new file mode 100644
index 0000000000..b0f590e163
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.services.artifact;
+
+import java.util.Collection;
+
+/**
+ * Abstraction for a repository of SCA and other artifacts.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ArtifactRepository {
+ /**
+ * Resolve an artifact.
+ * This ensures that the information associated with an artifact is fully populated;
+ * Specifically, after this operation the URL should contain a location where the artifact can be obtained.
+ *
+ * @param artifact the artifact to be resolved
+ */
+ void resolve(Artifact artifact);
+
+ /**
+ * Resolve a collection of Artifacts.
+ *
+ * @param artifacts a collection of artifacts to be resolved
+ * @see #resolve(Artifact)
+ */
+ void resolve(Collection<? extends Artifact> artifacts);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java
new file mode 100644
index 0000000000..9675cdce53
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.services.work;
+
+/**
+ * A callback inyterface that can be optionally used for registering
+ * interest in status of asynchronously scheduled unit of work.
+ *
+ */
+public interface NotificationListener<T extends Runnable> {
+
+ /**
+ * Callback method when the unit of work is accepted.
+ *
+ * @param work Work that was accepted.
+ */
+ void workAccepted(T work);
+
+ /**
+ * Callback method when the unit of work is successfully completed.
+ *
+ * @param work Work that was succesfully completed.
+ */
+ void workCompleted(T work);
+
+ /**
+ * Callback when the unit of work is started.
+ *
+ * @param work Unit of work that was started.
+ */
+ void workStarted(T work);
+
+ /**
+ * Callback when the unit of work is rejected.
+ *
+ * @param work Unit of work that was rejected.
+ */
+ void workRejected(T work);
+
+ /**
+ * Callnack when the unit of work fails to complete.
+ *
+ * @param work Unit of work that failed to complete.
+ * @param error Error that caused the unit of work to fail.
+ */
+ void workFailed(T work, Throwable error);
+
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java
new file mode 100644
index 0000000000..0824990c93
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.services.work;
+
+/**
+ * Defines the contract for scheduling asychronous units of work.
+ *
+ * <p>
+ * Units of work can be scheduled with an optional <code>NotificationListener</code>.
+ * If a notification listener is specified, the caller will be notified regarding the
+ * status of the work. The unit of work can either be completed, rejected or completed
+ * with an error. If the work completed with an error, the caller is notfied with the
+ * error details.
+ * </p>
+ *
+ */
+public interface WorkScheduler {
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener
+ * is used to register interest in callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ * @param listener Notification listener for callbacks.
+ */
+ <T extends Runnable>void scheduleWork(T work, NotificationListener<T> listener);
+
+ /**
+ * Schedules a unit of work for future execution. The notification listener
+ * is used to register interest in callbacks regarding the status of the work.
+ *
+ * @param work The unit of work that needs to be asynchronously executed.
+ */
+ <T extends Runnable>void scheduleWork(T work);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java
new file mode 100644
index 0000000000..72dc8ee5d2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.services.work;
+
+/**
+ * Exception thrown by the work scheduler in case of unexpected exceptions.
+ *
+ */
+public class WorkSchedulerException extends RuntimeException {
+
+ /**
+ * Wraps the root cause.
+ *
+ * @param cause Root cause for the exception.
+ */
+ public WorkSchedulerException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java
new file mode 100644
index 0000000000..6177810b0f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.InvocationTargetException;
+
+
+/**
+ * Base class for dispatching an invocation through an {@link InboundInvocationChain}
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractInboundInvocationHandler {
+
+ /**
+ * Dispatches a client request made on a proxy
+ */
+ public Object invoke(InboundInvocationChain chain, TargetInvoker invoker, Object[] args) throws Throwable {
+ Interceptor headInterceptor = chain.getHeadInterceptor();
+ if (headInterceptor == null) {
+ try {
+ // short-circuit the dispatch and invoke the target directly
+ if (chain.getTargetInvoker() == null) {
+ throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
+ }
+ return chain.getTargetInvoker().invokeTarget(args);
+ } catch (InvocationTargetException e) {
+ // the cause was thrown by the target so throw it
+ throw e.getCause();
+ }
+ } else {
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(invoker);
+ Object messageId = getMessageId();
+ if (messageId == null) {
+ messageId = new MessageId();
+ }
+ msg.setMessageId(messageId);
+ Object corrId = getCorrelationId();
+ msg.setCorrelationId(corrId);
+ msg.setBody(args);
+ Message resp;
+ // dispatch the wire down the chain and get the response
+ resp = headInterceptor.invoke(msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw (Throwable) body;
+ }
+ return body;
+ }
+ }
+
+ protected abstract Object getMessageId();
+
+ protected abstract Object getCorrelationId();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java
new file mode 100644
index 0000000000..2e66534f30
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.InvocationTargetException;
+
+
+/**
+ * Base class for performing invocations on an outbound chain. Subclasses are responsible for retrieving and supplying
+ * the appropriate chain, target invoker and invocation arguments.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractOutboundInvocationHandler {
+
+ protected Object invoke(OutboundInvocationChain chain, TargetInvoker invoker, Object[] args) throws Throwable {
+ Interceptor headInterceptor = chain.getHeadInterceptor();
+ if (headInterceptor == null) {
+ try {
+ // short-circuit the dispatch and invoke the target directly
+ TargetInvoker targetInvoker = chain.getTargetInvoker();
+ if (targetInvoker == null) {
+ String name = chain.getOperation().getName();
+ throw new AssertionError("No target invoker [" + name + "]");
+ }
+ return targetInvoker.invokeTarget(args);
+ } catch (InvocationTargetException e) {
+ // the cause was thrown by the target so throw it
+ throw e.getCause();
+ }
+ } else {
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(invoker);
+ msg.setFromAddress(getFromAddress());
+ Object messageId = getMessageId();
+ if (messageId == null) {
+ messageId = new MessageId();
+ }
+ msg.setMessageId(messageId);
+ Object corrId = getCorrelationId();
+ msg.setCorrelationId(corrId);
+ msg.setBody(args);
+ // dispatch the wire down the chain and get the response
+ Message resp = headInterceptor.invoke(msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw (Throwable) body;
+ }
+ return body;
+ }
+ }
+
+ protected abstract Object getFromAddress();
+
+ protected abstract Object getMessageId();
+
+ protected abstract Object getCorrelationId();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java
new file mode 100644
index 0000000000..22522286a7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+/**
+ * A set of interceptors and handlers (contained in request and response message channels) associated with the inbound
+ * side of a wire for an operation. Inbound chains may start with request {@link MessageHandler}s and contain at least
+ * one {@link Interceptor} processed after the handlers prior to dipatching to the target instance. Inbound invocation
+ * chains may also contain a set of response <code>MessageHandler</code>s which are processed after dispatching to the
+ * target instance.
+ * <p/>
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface InboundInvocationChain extends InvocationChain {
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java
new file mode 100644
index 0000000000..ca9ab65f20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * Implementations are responsible for managing the inbound side of a wire, including the invocation chains associated
+ * with each service operation.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface InboundWire extends RuntimeWire {
+
+ /**
+ * Returns the name of the target service of the wire
+ */
+ String getServiceName();
+
+ /**
+ * Sets the name of the target service of the wire
+ */
+ void setServiceName(String name);
+
+ /**
+ * Returns the invocation chain for each operation on a service specified by a reference or a target
+ * service.
+ */
+ Map<Operation<?>, InboundInvocationChain> getInvocationChains();
+
+ /**
+ * Adds the collection of invocation chains keyed by operation
+ */
+ void addInvocationChains(Map<Operation<?>, InboundInvocationChain> chains);
+
+ /**
+ * Adds the invocation chain associated with the given operation
+ */
+ void addInvocationChain(Operation<?> operation, InboundInvocationChain chain);
+
+ /**
+ * Returns the callback invocation configuration for each operation on a service specified by a reference or a
+ * target service.
+ */
+ Map<Operation<?>, OutboundInvocationChain> getSourceCallbackInvocationChains(Object targetAddr);
+
+ /**
+ * Adds the collection of callback invocation chains keyed by operation for a given target addr
+ */
+ void addSourceCallbackInvocationChains(Object targetAddr, Map<Operation<?>, OutboundInvocationChain> chains);
+
+ /**
+ * Adds the callback invocation chain associated with the given operation for a given target addr
+ */
+ void addSourceCallbackInvocationChain(Object targetAddr, Operation<?> operation, OutboundInvocationChain chain);
+
+ /**
+ * Returns the name of the callback associated with the service of the wire
+ */
+ String getCallbackReferenceName();
+
+ /**
+ * Sets the name of the callback associated with the service of the wire
+ */
+ void setCallbackReferenceName(String callbackReferenceName);
+
+ /**
+ * Set when a wire can be optimized; that is when no handlers or interceptors exist on either end
+ */
+ void setTargetWire(OutboundWire wire);
+
+ /**
+ * Creates an association between a message id and the address of the SCAObject that the corresponding message
+ * originates from
+ */
+ void addMapping(Object messageId, Object fromAddress);
+
+ /**
+ * Retrieves the SCAObject address that is associated with a message id
+ */
+ Object retrieveMapping(Object messageId);
+
+ /**
+ * Removes an association between a message id and the address of the SCAObject that the corresponding message
+ * originates from
+ */
+ void removeMapping(Object messageId);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java
new file mode 100644
index 0000000000..383114f076
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.wire;
+
+/**
+ * Denotes imcompatible service contracts for a wire
+ */
+public class IncompatibleServiceContractException extends WireException {
+
+ private static final long serialVersionUID = 5127478601823295587L;
+
+ public IncompatibleServiceContractException() {
+ }
+
+ /**
+ * @param message
+ */
+ public IncompatibleServiceContractException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public IncompatibleServiceContractException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public IncompatibleServiceContractException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java
new file mode 100644
index 0000000000..ad38ed1cf1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+/**
+ * Synchronous, around-style mediation associated with a client- or target- side wire.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Interceptor {
+
+ /**
+ * Process a synchronous wire
+ *
+ * @param msg the request Message for the wire
+ * @return the response Message from the wire
+ */
+ Message invoke(Message msg);
+
+ /**
+ * Sets the next interceptor
+ */
+ void setNext(Interceptor next);
+
+ /**
+ * Returns the next interceptor or null
+ */
+ Interceptor getNext();
+
+ /**
+ * Returns true if the interceptor can be optimized away from a wire
+ */
+ boolean isOptimizable();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java
new file mode 100644
index 0000000000..82e1a52adf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * An inbound or outbound invocation pipeline for a service operation. Wires consist of 1..n invocation chains
+ * associated with the operations of the service contract the wire represents. Invocation chains are associated with the
+ * outbound or inbound side of a wire are bridged or "connected" when an assembly is processed. Outbound chains are only
+ * connected to inbound chains and vice versa.
+ * <p/>
+ * Invocation chains contain at least one {@link Interceptor} that process invocations in an around-style manner. In
+ * some scenarios, a service proxy may only contain inbound invocation chains, for example, when a service is resolved
+ * through a locate operation by a non-component client. In this case, there will be no outbound invocation chains and
+ * the target invoker will be held by the target-side and passed down the pipeline.
+ * <p/>
+ * A {@link Message} is used to pass data associated with an invocation through the chain. <code>Message</code>s contain
+ * a {@link TargetInvoker} responsible for dispatching to a target instance and may be cached on the source-side.
+ * Caching allows various optimizations such as avoiding target instance resolution when the client-side lifecycle scope
+ * is a shorter duration than the target.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InvocationChain {
+ /**
+ * Returns the target operation for this invocation chain
+ */
+ Operation getOperation();
+
+ /**
+ * Sets the target invoker to pass down the chain
+ */
+ void setTargetInvoker(TargetInvoker invoker);
+
+ /**
+ * Returns the target invoker that is passed down the chain
+ */
+ TargetInvoker getTargetInvoker();
+
+ /**
+ * Adds an interceptor to the chain
+ */
+ void addInterceptor(Interceptor interceptor);
+
+ /**
+ * Adds an interceptor at the given position in the interceptor stack
+ *
+ * @param index the position in the interceptor stack to add the interceptor
+ * @param interceptor the interceptor to add
+ */
+ void addInterceptor(int index, Interceptor interceptor);
+
+ /**
+ * Returns the first interceptor in the chain
+ */
+ Interceptor getHeadInterceptor();
+
+ /**
+ * Returns the last interceptor in the chain
+ */
+ Interceptor getTailInterceptor();
+
+ /**
+ * Sets the head interceptor of the bridged target-side chain
+ */
+ void setTargetInterceptor(Interceptor interceptor);
+
+ /**
+ * Returns the head interceptor of the birdged target-side chain
+ */
+ Interceptor getTargetInterceptor();
+
+ /**
+ * Signals to the chain that its configuration is complete. Implementations may use this callback to prepare their
+ * invocation chains.
+ */
+ void prepare();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java
new file mode 100644
index 0000000000..c2ba19c48a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Denotes a runtime exception thrown during an invocation over a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationRuntimeException extends ServiceRuntimeException {
+
+ public InvocationRuntimeException() {
+ super();
+ }
+
+ public InvocationRuntimeException(String message) {
+ super(message);
+ }
+
+ public InvocationRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvocationRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java
new file mode 100644
index 0000000000..dd89445a78
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+/**
+ * Represents a request, response, or exception flowing through a wire
+ *
+ * @version $Rev $Date
+ */
+public interface Message {
+
+ /**
+ * Returns the body of the message, which will be the payload or parameters associated with the wire
+ */
+ Object getBody();
+
+ /**
+ * Sets the body of the message.
+ */
+ void setBody(Object body);
+ /**
+ * Sets the target invoker to dispatch to when the message passes through the request side of the invocation chain
+ */
+ void setTargetInvoker(TargetInvoker invoker);
+
+ /**
+ * Sets the target invoker to dispatch to when the message passes through the request side of the invocation chain
+ */
+ TargetInvoker getTargetInvoker();
+
+ /**
+ * Returns the 'address' of the SCAObject where this message originates
+ */
+ Object getFromAddress();
+
+ /**
+ * Sets the 'address' of the SCAObject where this message originates
+ */
+ void setFromAddress(Object fromAddress);
+
+ /**
+ * Returns the id of the message
+ */
+ Object getMessageId();
+
+ /**
+ * Sets the id of the message
+ */
+ void setMessageId(Object messageId);
+
+ /**
+ * Returns the correlation id of the message
+ */
+ Object getCorrelationId();
+
+ /**
+ * Sets the correlation id of the message
+ */
+ void setCorrelationId(Object correlationId);
+
+ /**
+ * Test if the message represents a fault/exception
+ * @return true if the message body is a fault object, false is the body is a normal payload
+ */
+ boolean isFault();
+
+ /**
+ * Set the message body with a fault object. After this method is called, isFault() returns true.
+ * @param fault The fault object represents an exception
+ */
+ void setBodyWithFault(Object fault);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java
new file mode 100644
index 0000000000..b1011e4f29
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+/**
+ * A unique identifier for a message flowing on a wire, potentially end-to-end (ie, through more than one SCAObject to
+ * SCAObject hop).
+ */
+public class MessageId {
+
+ private long timestamp;
+
+ public MessageId() {
+ this.timestamp = System.currentTimeMillis();
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public String toString() {
+ return "MsgId[" + timestamp + "]";
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java
new file mode 100644
index 0000000000..3e44db4690
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+/**
+ * The default implementation of a message flowed through a wire during an invocation
+ *
+ * @version $Rev $Date
+ */
+public class MessageImpl implements Message {
+
+ private Object body;
+ private TargetInvoker invoker;
+ private Object fromAddress;
+ private Object messageId;
+ private Object correlationId;
+ private boolean isFault;
+
+ public MessageImpl() {
+ }
+
+ public Object getBody() {
+ return body;
+ }
+
+ public void setBody(Object body) {
+ this.isFault = false;
+ this.body = body;
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ this.invoker = invoker;
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return invoker;
+ }
+
+ public Object getFromAddress() {
+ return fromAddress;
+ }
+
+ public void setFromAddress(Object fromAddress) {
+ this.fromAddress = fromAddress;
+ }
+
+ public Object getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(Object messageId) {
+ this.messageId = messageId;
+ }
+
+ public Object getCorrelationId() {
+ return correlationId;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ this.correlationId = correlationId;
+ }
+
+ public boolean isFault() {
+ return isFault;
+ }
+
+ public void setBodyWithFault(Object fault) {
+ this.isFault = true;
+ this.body = fault;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java
new file mode 100644
index 0000000000..b15678a4a8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+/**
+ * Responsible for flowing a request to a target service and invoking an operation.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OutboundInvocationChain extends InvocationChain {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java
new file mode 100644
index 0000000000..0d58d6a3e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * Implementations are responsible for managing the reference side of a wire, including the invocation chains associated
+ * with each service operation. An <code>OutboundWire</code> is connected to an {@link InboundWire} through their
+ * invocation chains.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OutboundWire extends RuntimeWire {
+
+ /**
+ * Returns the name of the source reference
+ */
+ String getReferenceName();
+
+ /**
+ * Sets the name of the source reference
+ */
+ void setReferenceName(String name);
+
+ /**
+ * Returns the name of the target
+ */
+ QualifiedName getTargetName();
+
+ /**
+ * Sets the name of the target
+ */
+ void setTargetName(QualifiedName name);
+
+ /**
+ * Sets the callback interface type generated proxies implement
+ */
+ void setCallbackInterface(Class<?> interfaze);
+
+ /**
+ * Returns the callback interface type implemented by generated proxies
+ */
+ Class<?> getCallbackInterface();
+
+ /**
+ * Returns the invocation configuration for each operation on a service specified by a reference or a target
+ * service.
+ */
+ Map<Operation<?>, OutboundInvocationChain> getInvocationChains();
+
+ /**
+ * Adds the collection of invocation chains keyed by operation
+ */
+ void addInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains);
+
+ /**
+ * Adds the invocation chain associated with the given operation
+ */
+ void addInvocationChain(Operation<?> operation, OutboundInvocationChain chain);
+
+ /**
+ * Returns the callback invocation configuration for each operation on a service specified by a reference or a
+ * target service.
+ */
+ Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains();
+
+ /**
+ * Adds the collection of callback invocation chains keyed by operation
+ */
+ void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains);
+
+ /**
+ * Adds the callback invocation chain associated with the given operation
+ */
+ void addTargetCallbackInvocationChain(Operation<?> operation, InboundInvocationChain chain);
+
+ /**
+ * Set when a wire can be optimized; that is when no handlers or interceptors exist on either end
+ */
+ void setTargetWire(InboundWire wire);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java
new file mode 100644
index 0000000000..0f213c9871
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Denotes an error creating a proxy
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ProxyCreationException extends TuscanyRuntimeException {
+ public ProxyCreationException() {
+ }
+
+ public ProxyCreationException(String message) {
+ super(message);
+ }
+
+ public ProxyCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProxyCreationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/RuntimeWire.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/RuntimeWire.java
new file mode 100644
index 0000000000..0c39b50d6a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/RuntimeWire.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.component.SCAObject;
+
+/**
+ * The base wire type used to connect references and services
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface RuntimeWire {
+
+ /**
+ * Returns the non-proxied target instance for this wire
+ */
+ Object getTargetService() throws TargetException;
+
+ /**
+ * Returns the service contract associated with the wire
+ *
+ * @return the service contract associated with the wire
+ */
+ ServiceContract getServiceContract();
+
+ /**
+ * Sets the contract associated with the wire
+ *
+ * @param contract the contract associated with the wire
+ */
+ void setServiceContract(ServiceContract contract);
+
+ /**
+ * Adds an interface type generated proxies implement
+ */
+ void addInterface(Class<?> claz);
+
+ /**
+ * Returns true if the wire and all of its interceptors and handlers can be optimized
+ */
+ boolean isOptimizable();
+
+ /**
+ * Returns the SCAObject that contains this wire
+ */
+ SCAObject getContainer();
+
+ /**
+ * Sets the name of the SCAObject that contains this wire
+ */
+ void setContainer(SCAObject container);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java
new file mode 100644
index 0000000000..5edcd29286
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Implementations are responsible for resolving a target and performing the actual invocation on it, for example, a
+ * component implementation instance or a service client.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TargetInvoker extends Cloneable {
+
+ /**
+ * Invokes an operation on a target with the given payload. Used in optmized cases where messages do not need to be
+ * flowed such as in non-proxied wires.
+ *
+ * @throws InvocationTargetException
+ */
+ Object invokeTarget(final Object payload) throws InvocationTargetException;
+
+ /**
+ * Invokes an operation on a target with the given message
+ *
+ * @throws InvocationRuntimeException
+ */
+ Message invoke(Message msg) throws InvocationRuntimeException;
+
+ /**
+ * Determines whether the proxy can be cached on the client/source side
+ */
+ boolean isCacheable();
+
+ /**
+ * Sets whether the target service instance may be cached by the invoker. This is a possible optimization when a
+ * wire is configured for a "down-scope" reference, i.e. a reference from a source of a shorter lifetime to a source
+ * of greater lifetime.
+ */
+ void setCacheable(boolean cacheable);
+
+ /**
+ * Determines if the target invoker can be discarded during wire optimization
+ */
+ boolean isOptimizable();
+
+ /**
+ * Implementations must support deep cloning
+ */
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireException.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireException.java
new file mode 100644
index 0000000000..2574bede2c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Denotes a top-level exception dealing with a wire
+ */
+public abstract class WireException extends TuscanyException {
+
+ public WireException() {
+ super();
+ }
+
+ public WireException(String message) {
+ super(message);
+ }
+
+ public WireException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public WireException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java
new file mode 100644
index 0000000000..325f26ba91
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.Method;
+
+/**
+ * Implementations are responsible for dispatching an operation down an invocation chain
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface WireInvocationHandler {
+
+ Object invoke(Method method, Object[] args) throws Throwable;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
new file mode 100644
index 0000000000..6e97916b95
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Creates proxies that implement Java interfaces and invocation handlers for fronting wires
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public interface WireService {
+
+ /**
+ * Creates a Java proxy for the given wire
+ *
+ * @param wire the wire to proxy
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ Object createProxy(RuntimeWire wire) throws ProxyCreationException;
+
+ /**
+ * Creates a Java proxy for the service contract callback
+ *
+ * @param contract the service contract
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ Object createCallbackProxy(ServiceContract<?> contract, InboundWire wire) throws ProxyCreationException;
+
+
+ /**
+ * Creates an {@link WireInvocationHandler} for the given wire
+ *
+ * @param wire the wire to create the invocation handler for
+ * @return the invocation handler
+ */
+ WireInvocationHandler createHandler(RuntimeWire wire);
+
+ /**
+ * Creates a wire invocation handler for flowing invocations through a callback
+ *
+ * @return the invocation handler for flowing invocations through a callback
+ */
+ WireInvocationHandler createCallbackHandler(InboundWire wire);
+
+ /**
+ * Creates an outbound invocation chain for a given operation
+ *
+ * @param operation the operation to create the chain for
+ * @return the outbound invocation chain for a given operation
+ */
+ OutboundInvocationChain createOutboundChain(Operation<?> operation);
+
+ /**
+ * Creates an inbound invocation chain for a given operation
+ *
+ * @param operation the operation to create the chain for
+ * @return the inbound invocation chain for a given operation
+ */
+ InboundInvocationChain createInboundChain(Operation<?> operation);
+
+ /**
+ * Creates a wire for flowing inbound invocations to a service
+ *
+ * @param service the model representation of the service
+ * @return the wire for flowing inbound invocations to a service
+ */
+ InboundWire createWire(ServiceDefinition service);
+
+ /**
+ * Creates a wire for flowing outbound invocations to a reference
+ *
+ * @param reference the model artifact representing the reference on the source side
+ * @param def the model artifact representing the target reference
+ * @return the wire for flowing outbound invocations to a reference
+ */
+ OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def);
+
+ /**
+ * Creates wires for a component and injects them on the component
+ *
+ * @param component the component
+ * @param definition the model artifact representing the component
+ */
+ void createWires(Component component, ComponentDefinition<?> definition);
+
+ /**
+ * Creates wires for a reference and injects them on the reference
+ *
+ * @param reference the reference
+ * @param contract the model artifact representing the service contract for the reference
+ */
+ void createWires(Reference reference, ServiceContract<?> contract);
+
+ /**
+ * Creates wires for a service and injects them on the service
+ *
+ * @param service the service
+ * @param targetName the target nane
+ * @param contract the service contract
+ */
+ void createWires(Service service, String targetName, ServiceContract<?> contract);
+
+ /**
+ * Check the compatiblity of the source and the target service contracts.<p> A wire may only connect a source to a
+ * target if the target implements an interface that is compatible with the interface required by the source. The
+ * source and the target are compatible if:
+ * <p/>
+ * <ol> <li>the source interface and the target interface MUST either both be remotable or they are both local
+ * <li>the methods on the target interface MUST be the same as or be a superset of the methods in the interface
+ * specified on the source <li>compatibility for the individual method is defined as compatibility of the signature,
+ * that is method name, input types, and output types MUST BE the same. <li>the order of the input and output types
+ * also MUST BE the same. <li>the set of Faults and Exceptions expected by the source MUST BE the same or be a
+ * superset of those specified by the service. <li>other specified attributes of the two interfaces MUST match,
+ * including Scope and Callback interface </ol>
+ * <p/>
+ * <p>Please note this test is not symetric: the success of checkCompatibility(A, B) does NOT imply that
+ * checkCompatibility(B, A)
+ *
+ * @param source The source service contract
+ * @param target The target service contract
+ * @param ignoreCallback Indicate the callback should be checked
+ * @throws IncompatibleServiceContractException
+ * If the source service contract is not compatible with the target one
+ */
+ void checkCompatibility(ServiceContract<?> source, ServiceContract<?> target, boolean ignoreCallback)
+ throws IncompatibleServiceContractException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireServiceExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireServiceExtension.java
new file mode 100644
index 0000000000..1baa4b3029
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireServiceExtension.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.policy.PolicyBuilderRegistry;
+
+/**
+ * Base class for wire service extensions
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class WireServiceExtension implements WireService {
+
+ protected PolicyBuilderRegistry policyRegistry;
+ protected WorkContext context;
+
+ protected WireServiceExtension(WorkContext context, PolicyBuilderRegistry policyRegistry) {
+ this.policyRegistry = policyRegistry;
+ this.context = context;
+ }
+
+ /**
+ * Compares two operations for wiring compatibility as defined by the SCA assembly specification, namely: <p/> <ol>
+ * <li>compatibility for the individual method is defined as compatibility of the signature, that is method name,
+ * input types, and output types MUST BE the same. <li>the order of the input and output types also MUST BE the
+ * same. <li>the set of Faults and Exceptions expected by the source MUST BE the same or be a superset of those
+ * specified by the service. </ol>
+ *
+ * @param source the source contract to compare
+ * @param target the target contract to compare
+ * @throws IncompatibleServiceContractException
+ * if the two contracts don't match
+ */
+ public void checkCompatibility(ServiceContract<?> source, ServiceContract<?> target, boolean ignoreCallback)
+ throws IncompatibleServiceContractException {
+ if (source == target) {
+ // Shortcut for performance
+ return;
+ }
+ if (source.isRemotable() != target.isRemotable()) {
+ IncompatibleServiceContractException ex =
+ new IncompatibleServiceContractException("The remotable settings don't match");
+ ex.setIdentifier(source.toString() + "," + target.toString());
+ throw ex;
+ }
+ if (source.getInteractionScope() != target.getInteractionScope()) {
+ IncompatibleServiceContractException ex =
+ new IncompatibleServiceContractException("The interaction scopes don't match");
+ ex.setIdentifier(source.toString() + "," + target.toString());
+ throw ex;
+ }
+
+ for (Operation<?> operation : source.getOperations().values()) {
+ Operation<?> targetOperation = target.getOperations().get(operation.getName());
+ if (targetOperation == null) {
+ IncompatibleServiceContractException ex =
+ new IncompatibleServiceContractException("Operation not found on target");
+ ex.setIdentifier(operation.getName());
+ throw ex;
+ }
+ if (!operation.equals(targetOperation)) {
+ IncompatibleServiceContractException ex =
+ new IncompatibleServiceContractException("Target operation is not compatible");
+ ex.setIdentifier(operation.getServiceContract().toString() + ":" + operation.getName());
+ throw ex;
+ }
+ }
+
+ if (ignoreCallback) {
+ return;
+ }
+
+ for (Operation<?> operation : source.getCallbackOperations().values()) {
+ Operation<?> targetOperation = target.getCallbackOperations().get(operation.getName());
+ if (targetOperation == null) {
+ IncompatibleServiceContractException ex =
+ new IncompatibleServiceContractException("Callback operation not found on target");
+ ex.setIdentifier(operation.getName());
+ throw ex;
+ }
+ if (!operation.equals(targetOperation)) {
+ IncompatibleServiceContractException ex =
+ new IncompatibleServiceContractException("Target callback operation is not compatible");
+ ex.setIdentifier(operation.getName());
+ throw ex;
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java
new file mode 100644
index 0000000000..72739d56c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AssertionTestCase extends TestCase {
+ /**
+ * test case that confirms that JRE assertions are enabled
+ */
+ public void testAssertionsAreEnabled() {
+ try {
+ assert false;
+ fail("assertions are not enabled");
+ } catch (AssertionError e) {
+ // ok
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java
new file mode 100644
index 0000000000..1f5faa5f9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests parsing of naming patters
+ *
+ * @version $Rev$ $Date$
+ */
+public class QualifiedNameTestCase extends TestCase {
+
+ public void testSimpleName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo");
+ assertEquals("Foo", name.getPartName());
+ assertEquals(null, name.getPortName());
+ }
+
+ public void testCompoundName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo", name.getPartName());
+ assertEquals("Bar", name.getPortName());
+ }
+
+ public void testCompoundMultiName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar/Baz");
+ assertEquals("Foo", name.getPartName());
+ assertEquals("Bar/Baz", name.getPortName());
+ }
+
+ public void testInvalidName() throws Exception {
+ try {
+ new QualifiedName("/Foo/Bar");
+ fail("Invalid name exception not thrown");
+ } catch (InvalidNameException e) {
+ //expected
+ }
+ }
+
+ public void testQualifiedName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo/Bar", name.getQualifiedName());
+ }
+
+ public void testToString() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo/Bar", name.toString());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java
new file mode 100644
index 0000000000..6d431a5dcf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyExceptionTestCase extends TestCase {
+
+ public void testIdentifier() throws Exception {
+ TuscanyException e = new TestException();
+ e.setIdentifier("foo");
+ assertEquals("foo", e.getIdentifier());
+ }
+
+ public void testAddContext() throws Exception {
+ TuscanyException e = new TestException();
+ e.addContextName("foo");
+ e.addContextName("bar");
+ assertEquals("foo", e.returnContextNames().get(0));
+ assertEquals("bar", e.returnContextNames().get(1));
+ }
+
+ public void testEmptyContext() throws Exception {
+ TuscanyException e = new TestException();
+ assertEquals(0, e.returnContextNames().size());
+ }
+
+ public void testGetMessage() throws Exception {
+ TuscanyException e = new TestException();
+ e.getMessage();
+ }
+
+ public void testFullMessage() throws Exception {
+ TuscanyException e = new TestException();
+ e.setIdentifier("foo");
+ e.addContextName("foo");
+ e.getMessage();
+ }
+
+
+ private class TestException extends TuscanyException {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java
new file mode 100644
index 0000000000..3a04391cfd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyRuntimeExceptionTestCase extends TestCase {
+
+ public void testIdentifier() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.setIdentifier("foo");
+ assertEquals("foo", e.getIdentifier());
+ }
+
+ public void testAddContext() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.addContextName("foo");
+ e.addContextName("bar");
+ assertEquals("foo", e.returnContextNames().get(0));
+ assertEquals("bar", e.returnContextNames().get(1));
+ }
+
+ public void testEmptyContext() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ assertEquals(0, e.returnContextNames().size());
+ }
+
+ public void testEmptyGetMessage() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.getMessage();
+ }
+
+ public void testFullMessage() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.setIdentifier("foo");
+ e.addContextName("foo");
+ e.getMessage();
+ }
+
+
+ private class TestException extends TuscanyRuntimeException {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
new file mode 100644
index 0000000000..affd52df42
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.annotation;
+
+import java.util.Arrays;
+
+import org.osoa.sca.annotations.Constructor;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorAnnotationTest extends TestCase {
+ public void testSingleName() throws NoSuchMethodException {
+ Constructor ann = Foo1.class.getConstructor(String.class).getAnnotation(Constructor.class);
+ assertNotNull(ann);
+ String[] names = ann.value();
+ assertTrue(Arrays.equals(new String[]{"prop"}, names));
+ }
+
+ public void testMultipleNames() throws NoSuchMethodException {
+ Constructor ann = Foo1.class.getConstructor(String.class, String.class).getAnnotation(Constructor.class);
+ assertNotNull(ann);
+ String[] names = ann.value();
+ assertTrue(Arrays.equals(new String[]{"prop", "ref"}, names));
+ }
+
+ public static class Foo1 {
+ @Constructor({"prop", "ref"})
+ public Foo1(String prop, String ref) {
+ }
+
+ @Constructor("prop")
+ public Foo1(String prop) {
+ }
+ }
+
+ public static class Foo2 {
+ public Foo2(@Autowire String prop,
+ @Autowire String ref) {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
new file mode 100644
index 0000000000..a5e035026b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.TrueFilter;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractSCAObjectTestCase extends TestCase {
+
+ public void testFireListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ listener.onEvent(EasyMock.same(event));
+ EasyMock.expectLastCall();
+ EasyMock.replay(listener);
+ object.addListener(listener);
+ object.publish(event);
+ }
+
+ public void testRemoveListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ EasyMock.replay(listener);
+ object.addListener(listener);
+ object.removeListener(listener);
+ object.publish(event);
+ }
+
+ public void testFalseFilterListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ EasyMock.replay(listener);
+ object.addListener(new FalseFilter(), listener);
+ object.publish(event);
+ }
+
+ public void testTrueFilterListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ listener.onEvent(EasyMock.same(event));
+ EasyMock.expectLastCall();
+ EasyMock.replay(listener);
+ object.addListener(new TrueFilter(), listener);
+ object.publish(event);
+ }
+
+ public void testToString() {
+ SCAObject object = new TestSCAObject("foo", null);
+ assertNotNull(object.toString());
+ }
+
+ public void testGetName() {
+ SCAObject object = new TestSCAObject("foo", null);
+ assertEquals("foo", object.getName());
+ }
+
+
+ public void testToPrepare() {
+ SCAObject object = new TestSCAObject("foo", null);
+ object.prepare();
+ }
+
+
+ private class TestSCAObject extends AbstractSCAObject {
+ public TestSCAObject(String name, CompositeComponent parent) {
+ super(name, parent);
+ }
+
+ public Scope getScope() {
+ return null;
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return null;
+ }
+ }
+
+ private class TestEvent implements Event {
+ public Object getSource() {
+ return null;
+ }
+ }
+
+ private class FalseFilter implements EventFilter {
+
+ public boolean match(Event event) {
+ return false;
+ }
+ }
+
+
+}
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java
new file mode 100644
index 0000000000..40843dea94
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class DOMHelperTestCase extends TestCase {
+ private static final QName FOO_NAME = new QName("http://foo", "foo");
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testDOM() throws Exception {
+ DocumentBuilder builder = DOMHelper.newDocumentBuilder();
+ assertNotNull(builder);
+ Document document = DOMHelper.newDocument();
+ assertNotNull(document);
+ Element element = DOMHelper.createElement(document, FOO_NAME);
+ document.appendChild(element);
+ QName name = DOMHelper.getQName(element);
+ assertEquals(FOO_NAME, name);
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java
new file mode 100644
index 0000000000..b4b5f6a39a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.easymock.EasyMock;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ */
+public class DataBindingExtensionTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testExtension() {
+ DataBinding1 binding1 = new DataBinding1(Node.class);
+ assertEquals(Node.class.getName(), binding1.getName());
+ assertNotNull(binding1.introspect(Element.class));
+ assertNull(binding1.introspect(String.class));
+ assertNull(binding1.getWrapperHandler());
+
+ DataBindingRegistry registry = EasyMock.createMock(DataBindingRegistry.class);
+ registry.register(binding1);
+ EasyMock.expect(registry.getDataBinding(Node.class.getName())).andReturn(binding1);
+ EasyMock.replay(registry);
+
+ binding1.setDataBindingRegistry(registry);
+ binding1.init();
+ assertNotNull(registry.getDataBinding(Node.class.getName()));
+
+ DataBinding1 binding2 = new DataBinding1("dom", Node.class);
+ assertEquals("dom", binding2.getName());
+ }
+
+ private static class DataBinding1 extends DataBindingExtension {
+
+ /**
+ * @param baseType
+ */
+ public DataBinding1(Class<?> baseType) {
+ super(baseType);
+ }
+
+ /**
+ * @param name
+ * @param baseType
+ */
+ public DataBinding1(String name, Class<?> baseType) {
+ super(name, baseType);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java
new file mode 100644
index 0000000000..c955352812
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.easymock.EasyMock;
+
+/**
+ *
+ */
+public class SimpleTypeMapperExtensionTestCase extends TestCase {
+
+ private static final Map<String, Object> SAMPLE_VALUES = new HashMap<String, Object>();
+
+ static {
+ SAMPLE_VALUES.put("anyURI", "http://www.w3.com");
+ SAMPLE_VALUES.put("boolean", new String[] {"true", "false", "1", "0"});
+ SAMPLE_VALUES.put("byte", new String[] {"-128", "127"});
+ SAMPLE_VALUES.put("date", new String[] {"2004-03-15", "2002-09-24-06:00"});
+ SAMPLE_VALUES.put("dateTime", "2003-12-25T08:30:00");
+ SAMPLE_VALUES.put("decimal", "3.1415292");
+ SAMPLE_VALUES.put("double", new String[] {"3.1415292", "INF", "NaN"});
+ SAMPLE_VALUES.put("duration", new String[] {"P8M3DT7H33M2S", "P5Y2M10DT15H"});
+ SAMPLE_VALUES.put("float", new String[] {"3.1415292", "INF", "NaN"});
+ SAMPLE_VALUES.put("gDay", "---11");
+ SAMPLE_VALUES.put("gMonth", "--02--");
+ SAMPLE_VALUES.put("gMonthDay", "--02-14");
+ SAMPLE_VALUES.put("gYear", "1999");
+ SAMPLE_VALUES.put("gYearMonth", "1972-08");
+ SAMPLE_VALUES.put("ID", "id-102");
+ SAMPLE_VALUES.put("IDREF", "id-102");
+ SAMPLE_VALUES.put("IDREFS", "id-102 id-103 id-100");
+ SAMPLE_VALUES.put("int", "77");
+ SAMPLE_VALUES.put("integer", "77");
+ SAMPLE_VALUES.put("long", "214");
+ SAMPLE_VALUES.put("negativeInteger", "-123");
+ SAMPLE_VALUES.put("nonNegativeInteger", "2");
+ SAMPLE_VALUES.put("nonPositiveInteger", "0");
+ SAMPLE_VALUES.put("positiveInteger", "500");
+ SAMPLE_VALUES.put("short", "476");
+ SAMPLE_VALUES.put("string", "Joeseph");
+ SAMPLE_VALUES.put("time", "13:02:00");
+ SAMPLE_VALUES.put("base64Binary", "TWFu");
+ SAMPLE_VALUES.put("hexBinary", "2CDB5F");
+ SAMPLE_VALUES.put("QName", "f:foo");
+ SAMPLE_VALUES.put("NOTATION", "f:bar");
+ }
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testMap() throws Exception {
+ SimpleTypeMapperExtension extension = new SimpleTypeMapperExtension();
+ TransformationContext context = EasyMock.createMock(TransformationContext.class);
+ Map<Class<?>, Object> metaData = new HashMap<Class<?>, Object>();
+ EasyMock.expect(context.getMetadata()).andReturn(metaData).anyTimes();
+ EasyMock.replay(context);
+
+ NamespaceContext namespaceContext = EasyMock.createMock(NamespaceContext.class);
+ EasyMock.expect(namespaceContext.getNamespaceURI(EasyMock.eq("f"))).andReturn("http://foo")
+ .anyTimes();
+ EasyMock.expect(namespaceContext.getPrefix(EasyMock.eq("http://foo"))).andReturn("f").anyTimes();
+ EasyMock.replay(namespaceContext);
+ context.getMetadata().put(NamespaceContext.class, namespaceContext);
+ for (TypeInfo simpleType : SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.values()) {
+ String name = simpleType.getQName().getLocalPart();
+ Object value = SAMPLE_VALUES.get(name);
+ if (value instanceof String[]) {
+ for (String s : (String[])value) {
+ Object obj = extension.toJavaObject(simpleType, s, context);
+ String str = extension.toXMLLiteral(simpleType, obj, context);
+ assertNotNull(str);
+ // assertTrue("[" + name + "] " + s + " " + str,
+ // str.contains((String) s));
+ }
+ } else if (value instanceof String) {
+ Object obj = extension.toJavaObject(simpleType, (String)value, context);
+ String str = extension.toXMLLiteral(simpleType, obj, context);
+ assertNotNull(str);
+ // assertTrue("[" + name + "] " + value + " " + str,
+ // str.contains((String) value));
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java
new file mode 100644
index 0000000000..6f5dfc90e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.easymock.EasyMock;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for TransformerExtension
+ */
+public class TransformerExtensionTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testExtension() {
+ MyTransformer transformer = new MyTransformer();
+ assertEquals(Node.class.getName(), transformer.getSourceDataBinding());
+ assertEquals(XMLStreamReader.class.getName(), transformer.getTargetDataBinding());
+ assertEquals(50, transformer.getWeight());
+ TransformerRegistry registry = EasyMock.createMock(TransformerRegistry.class);
+ registry.registerTransformer(EasyMock.isA(Transformer.class));
+ EasyMock
+ .expect(registry.getTransformer(transformer.getSourceDataBinding(), transformer.getTargetDataBinding()))
+ .andReturn(transformer);
+ EasyMock.replay(registry);
+ transformer.setTransformerRegistry(registry);
+ transformer.init();
+ assertSame(transformer, registry.getTransformer(transformer.getSourceDataBinding(), transformer
+ .getTargetDataBinding()));
+ }
+
+ private static class MyTransformer extends TransformerExtension<Node, XMLStreamReader> {
+
+ @Override
+ protected Class getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java
new file mode 100644
index 0000000000..4693025c11
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class XSDDataTypeConverterTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testConvert() throws Exception {
+ XSDDataTypeConverter c = new XSDDataTypeConverter();
+ assertEquals("123", c.parseAnySimpleType(c.printAnySimpleType("123")));
+ assertEquals(true, c.parseBoolean(c.printBoolean(true)));
+ assertEquals(false, c.parseBoolean(c.printBoolean(false)));
+ assertEquals(123.0, c.parseDouble(c.printDouble(123.0)));
+ assertEquals(123.0f, c.parseFloat(c.printFloat(123.0f)));
+ assertEquals(64, c.parseByte(c.printByte((byte)64)));
+ assertEquals(123, c.parseInt(c.printInt(123)));
+ assertEquals(new BigInteger("123456"), c.parseInteger(c.printInteger(new BigInteger("123456"))));
+ assertEquals(123456L, c.parseLong(c.printLong(123456L)));
+ assertEquals((short)123, c.parseShort(c.printShort((short)123)));
+
+ Calendar calendar = new GregorianCalendar();
+ String s = c.printDate(calendar);
+ calendar = (GregorianCalendar)c.parseDate(s);
+ assertEquals(s, c.printDate(calendar));
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
new file mode 100644
index 0000000000..2c3d953c73
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AtomicComponentExtensionTestCase extends TestCase {
+
+ public void testIsEagerInit() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.isEagerInit();
+ }
+
+ public void testPrepare() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.prepare();
+ }
+
+ public void testInit() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.init(null);
+ }
+
+ public void testDestroy() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.destroy(null);
+ }
+
+ public void testInboundWire() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.getInboundWire(null);
+ }
+
+ private class TestExtension extends AtomicComponentExtension {
+ public TestExtension() {
+ super(null, null, null, null, null, null, 0);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return null;
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ return null;
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ return null;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return null;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return null;
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java
new file mode 100644
index 0000000000..54229633eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Implementation;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeLoaderExtensionTestCase extends TestCase {
+
+ public void testRegistrationDeregistration() throws Exception {
+ Extension loader = new Extension();
+ LoaderRegistry registry = createMock(LoaderRegistry.class);
+ registry.registerLoader(eq(Implementation.class), eq(loader));
+ registry.unregisterLoader(eq(Implementation.class));
+ EasyMock.replay(registry);
+ loader.setLoaderRegistry(registry);
+ loader.start();
+ loader.stop();
+ }
+
+
+ private class Extension extends ComponentTypeLoaderExtension<Implementation> {
+
+ protected Class<Implementation> getImplementationClass() {
+ return Implementation.class;
+ }
+
+ public void load(CompositeComponent parent, Implementation implementation,
+ DeploymentContext deploymentContext) throws LoaderException {
+
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java
new file mode 100644
index 0000000000..d05aad05ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ModelObject;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LoaderExtensionTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testRegistrationDeregistration() throws Exception {
+ LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class);
+ registry.registerLoader(isA(QName.class), isA(Extension.class));
+ expectLastCall();
+ registry.unregisterLoader(isA(QName.class), isA(Extension.class));
+ expectLastCall();
+ EasyMock.replay(registry);
+ Extension loader = new Extension(registry);
+ loader.start();
+ loader.stop();
+ }
+
+
+ private static class Extension extends LoaderExtension {
+
+ public Extension(LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return new QName("");
+ }
+
+ public ModelObject load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ throw new AssertionError();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
new file mode 100644
index 0000000000..81693a088d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTestCase extends TestCase {
+
+ public void testScope() throws Exception {
+ TestReference ref = new TestReference<Object>(Object.class);
+ assertEquals(Scope.COMPOSITE, ref.getScope());
+ }
+
+ public void testSetGetInterface() throws Exception {
+ TestReference<TestReference> ref = new TestReference<TestReference>(TestReference.class);
+ assertEquals(TestReference.class, ref.getInterface());
+
+ }
+
+ public void testPrepare() throws Exception {
+ InboundInvocationChain chain = createMock(InboundInvocationChain.class);
+ Operation<Type> operation = new Operation<Type>("test", null, null, null, false, null);
+ chain.setTargetInvoker(null);
+ expectLastCall();
+ chain.getOperation();
+ expectLastCall().andReturn(operation);
+ chain.prepare();
+ expectLastCall();
+ InboundWire wire = createMock(InboundWire.class);
+ wire.getInvocationChains();
+ Map<Operation, InvocationChain> chains = new HashMap<Operation, InvocationChain>();
+ chains.put(operation, chain);
+ expectLastCall().andReturn(chains);
+ OutboundWire outboundWire = createMock(OutboundWire.class);
+ outboundWire.getTargetName();
+ expectLastCall().andReturn(new QualifiedName("foo/bar"));
+ replay(chain);
+ replay(wire);
+ replay(outboundWire);
+ TestReference<Object> ref = new TestReference<Object>(Object.class);
+ ref.setInboundWire(wire);
+ ref.setOutboundWire(outboundWire);
+ ref.prepare();
+ }
+
+ private class TestReference<T> extends ReferenceExtension {
+ public TestReference(Class<T> clazz) {
+ super(null, clazz, null, null);
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return null;
+ }
+
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
new file mode 100644
index 0000000000..29a8fc4c6c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceExtensionTestCase extends TestCase {
+
+ public void testScope() throws Exception {
+ ServiceExtension service = new ServiceExtension(null, null, null, null);
+ assertEquals(Scope.COMPOSITE, service.getScope());
+ }
+
+ public void testSetGetInterface() throws Exception {
+ InboundWire wire = createMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(getClass());
+ expect(wire.getServiceContract()).andReturn(contract);
+ replay(wire);
+ ServiceExtension service = new ServiceExtension(null, null, null, null);
+ service.setInboundWire(wire);
+ service.getInterface();
+ }
+
+
+ public void testPrepare() throws Exception {
+ ServiceExtension service = new ServiceExtension(null, null, null, null);
+ service.prepare();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
new file mode 100644
index 0000000000..29994b8cba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaIDLUtilsTestCase extends TestCase {
+ private Method[] methods;
+ private List<Operation<?>> operations;
+
+ public void testNoParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertEquals("foo", method.getName());
+ assertEquals(0, method.getParameterTypes().length);
+ }
+
+ public void testNoParamsFindOperation() throws Exception {
+ Method method = Foo.class.getMethod("foo");
+ Operation ret = findOperation(method, operations);
+ assertEquals("foo", ret.getName());
+ assertEquals(0, method.getParameterTypes().length);
+ }
+
+ public void testParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertEquals("foo", method.getName());
+ assertEquals(String.class, method.getParameterTypes()[0]);
+ }
+
+ public void testParamsFindOperation() throws Exception {
+ Method method = Foo.class.getMethod("foo", String.class);
+ Operation ret = findOperation(method, operations);
+ assertEquals("foo", ret.getName());
+ assertEquals(String.class, method.getParameterTypes()[0]);
+ }
+
+
+ public void testTooManyParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(String.class, Object.class);
+ DataType<Type> type2 = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ types.add(type2);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertNull(method);
+ }
+
+ public void testDifferentParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(Integer.class, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertNull(method);
+ }
+
+ public void testPrimitiveParamNoFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(Integer.class, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertNull(method);
+ }
+
+ public void testPrimitiveParamFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(Integer.TYPE, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertEquals("foo", method.getName());
+ assertEquals(Integer.TYPE, method.getParameterTypes()[0]);
+ }
+
+ public void testPrimitiveParamFindOperation() throws NoSuchMethodException {
+ Method method = Foo.class.getMethod("foo", Integer.TYPE);
+ Operation<?> operation = findOperation(method, operations);
+ assertEquals(Integer.TYPE, operation.getInputType().getLogical().get(0).getPhysical());
+ }
+
+
+ public void testNotFoundMethod() {
+ Operation<Type> operation = new Operation<Type>("not there", null, null, null, false, null);
+ assertNull(findMethod(operation, methods));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ methods = Foo.class.getMethods();
+
+ Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+ operations = new ArrayList<Operation<?>>();
+ operations.add(operation);
+
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ DataType<Type> type = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ types = new ArrayList<DataType<Type>>();
+ type = new DataType<Type>(String.class, Object.class);
+ DataType<Type> type2 = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ types.add(type2);
+ inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ types = new ArrayList<DataType<Type>>();
+ type = new DataType<Type>(Integer.class, Object.class);
+ types.add(type);
+ inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ types = new ArrayList<DataType<Type>>();
+ type = new DataType<Type>(Integer.TYPE, Object.class);
+ types.add(type);
+ inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ }
+
+ private interface Foo {
+ void foo();
+
+ void foo(String foo);
+
+ void foo(int b);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java
new file mode 100644
index 0000000000..18887880fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyProcessorTestCase extends TestCase {
+
+ private ImplementationProcessor processor;
+
+
+ public void testVisitMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitMethod(null, method, type, null);
+ JavaMappedProperty<?> prop = type.getProperties().get("test");
+ assertNotNull(prop.getDefaultValueFactory());
+ }
+
+ public void testVisitNoParamsMethod() throws Exception {
+ Method method = Foo.class.getMethod("setNoParamsBar");
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalPropertyException e) {
+ //expected
+ }
+ }
+
+ public void testVisitNonVoidMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBadBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalPropertyException e) {
+ //expected
+ }
+ }
+
+ public void testDuplicateMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitMethod(null, method, type, null);
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ //expected
+ }
+ }
+
+ public void testVisitField() throws Exception {
+ Field field = Foo.class.getDeclaredField("d");
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitField(null, field, type, null);
+ JavaMappedProperty<?> prop = type.getProperties().get("test");
+ assertNotNull(prop.getDefaultValueFactory());
+ }
+
+ public void testVisitConstructor() throws Exception {
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitConstructor(null, ctor, type, null);
+ ConstructorDefinition def = type.getConstructorDefinition();
+ assertEquals("test", def.getInjectionNames().get(0));
+ assertNotNull(type.getProperties().get("test"));
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ ImplementationProcessorService service = EasyMock.createMock(ImplementationProcessorService.class);
+ service.addName(EasyMock.isA(List.class), EasyMock.eq(0), EasyMock.eq("test"));
+ EasyMock.expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ ((List<Object>) EasyMock.getCurrentArguments()[0]).add("test");
+ return null;
+ }
+ });
+ EasyMock.replay(service);
+ processor = new TestProcessor(service);
+ }
+
+ @Retention(RUNTIME)
+ private @interface Bar {
+
+ }
+
+ private class TestProcessor extends AbstractPropertyProcessor<Bar> {
+
+ public TestProcessor(ImplementationProcessorService service) {
+ super(Bar.class, service);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> void initProperty(JavaMappedProperty<T> property,
+ Bar annotation,
+ CompositeComponent parent,
+ DeploymentContext context) {
+ property.setDefaultValueFactory(EasyMock.createMock(ObjectFactory.class));
+ property.setName("test");
+ }
+
+ protected String getName(Bar annotation) {
+ return "test";
+ }
+ }
+
+
+ private static class Foo {
+
+ @Bar
+ protected String d;
+
+ public Foo(String a, @Bar String b) {
+ }
+
+ public Foo(@Bar String d) {
+ this.d = d;
+ }
+
+ @Bar
+ public void setBar(String d) {
+ this.d = d;
+ }
+
+ @Bar
+ public void setNoParamsBar() {
+ }
+
+ @Bar
+ public String setBadBar(String d) {
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java
new file mode 100644
index 0000000000..f8c991f7d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LoaderExceptionTestCase extends TestCase {
+
+ public void testResourceURI() throws Exception {
+ LoaderException e = new LoaderException();
+ e.setResourceURI("test");
+ assertEquals("test", e.getResourceURI());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
new file mode 100644
index 0000000000..7facc55a6f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeTestCase extends TestCase {
+
+ public void testEquals() throws Exception {
+ Scope module = new Scope("module");
+ assertTrue(module.equals(Scope.MODULE));
+ }
+
+ public void testEqualsNew() throws Exception {
+ Scope foo = new Scope("foo");
+ Scope foo2 = new Scope("FOO");
+ assertTrue(foo.equals(foo2));
+ }
+
+ public void testNotEquals() throws Exception {
+ Scope foo = new Scope("BAR");
+ Scope foo2 = new Scope("FOO");
+ assertFalse(foo.equals(foo2));
+ }
+
+ public void testNotEqualsDifferent() throws Exception {
+ Scope foo = new Scope("FOO");
+ assertFalse(foo.equals(new Bar("FOO")));
+ }
+
+ public class Bar {
+ private String scope;
+
+ public Bar(String scope) {
+ this.scope = scope;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
new file mode 100644
index 0000000000..0c986dec34
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Type;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceContractTestCase extends TestCase {
+
+ public void testAddOperation() throws Exception {
+ ServiceContract<Type> contract = new TestContract();
+ Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+ Map<String, Operation<Type>> ops = new HashMap<String, Operation<Type>>();
+ ops.put("foo", operation);
+ contract.setOperations(ops);
+ assertEquals(contract, operation.getServiceContract());
+ assertFalse(operation.isCallback());
+ }
+
+ public void testAddCallbackOperation() throws Exception {
+ ServiceContract<Type> contract = new TestContract();
+ Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+ Map<String, Operation<Type>> ops = new HashMap<String, Operation<Type>>();
+ ops.put("foo", operation);
+ contract.setCallbackOperations(ops);
+ assertEquals(contract, operation.getServiceContract());
+ assertTrue(operation.isCallback());
+ }
+
+
+ private class TestContract extends ServiceContract<Type> {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..ec178af70a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.Array;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractInboundInvocationHandlerTestCase extends TestCase {
+
+ public void testInvocation() throws Throwable {
+ InvocationHandler handler = new InvocationHandler();
+ Interceptor interceptor = new MockInterceptor();
+ TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.replay(invoker);
+ InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor);
+ EasyMock.replay(chain);
+ Object resp = handler.invoke(chain, invoker, new String[]{"foo"});
+ assertEquals("response", resp);
+ }
+
+
+ private class InvocationHandler extends AbstractInboundInvocationHandler {
+
+ protected Object getMessageId() {
+ return new Object();
+ }
+
+ protected Object getCorrelationId() {
+ return new Object();
+ }
+ }
+
+ private class MockInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ assertNotNull(msg.getCorrelationId());
+ assertNotNull(msg.getTargetInvoker());
+ assertNotNull(msg.getMessageId());
+ assertEquals("foo", Array.get(msg.getBody(), 0));
+ msg.setBody("response");
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..a6104e4af1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractOutboundInvocationHandlerTestCase extends TestCase {
+
+ public void testInvocation() throws Throwable {
+ InvocationHandler handler = new InvocationHandler();
+ Interceptor interceptor = new MockInterceptor();
+ TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.replay(invoker);
+ OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor);
+ EasyMock.replay(chain);
+ Object resp = handler.invoke(chain, invoker, new String[]{"foo"});
+ assertEquals("response", resp);
+ }
+
+ public void testShortCircuitInvocation() throws Throwable {
+ InvocationHandler handler = new InvocationHandler();
+ TargetInvoker invoker = new MockInvoker();
+ OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(null);
+ EasyMock.expect(chain.getTargetInvoker()).andReturn(invoker);
+ EasyMock.replay(chain);
+ Object resp = handler.invoke(chain, invoker, new String[]{"foo"});
+ assertEquals("response", resp);
+ }
+
+
+ private class MockInvoker implements TargetInvoker {
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ assertEquals("foo", Array.get(payload, 0));
+ return "response";
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ fail();
+ return null;
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ private class InvocationHandler extends AbstractOutboundInvocationHandler {
+
+ protected Object getFromAddress() {
+ return new Object();
+ }
+
+ protected Object getMessageId() {
+ return new Object();
+ }
+
+ protected Object getCorrelationId() {
+ return new Object();
+ }
+ }
+
+ private class MockInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ assertNotNull(msg.getCorrelationId());
+ assertNotNull(msg.getTargetInvoker());
+ assertNotNull(msg.getMessageId());
+ assertNotNull(msg.getFromAddress());
+ assertEquals("foo", Array.get(msg.getBody(), 0));
+ msg.setBody("response");
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java
new file mode 100644
index 0000000000..9478473894
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java
@@ -0,0 +1,384 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.wire;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+
+/**
+ * TODO some tests commented out due to DataType.equals() needing to be strict
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContractCompatibilityTestCase extends TestCase {
+
+ private WireService wireService = new MockWireService();
+
+ public void testNoOperation() throws Exception {
+ ServiceContract source = new MockContract<Type>("FooContract");
+ ServiceContract target = new MockContract<Type>("FooContract");
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testBasic() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ Operation<Type> opSource2 = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opSource2);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testBasicIncompatibleOperationNames() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ Operation<Type> opSource2 = new Operation<Type>("op2", null, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op2", opSource2);
+ target.setOperations(targetOperations);
+ try {
+ wireService.checkCompatibility(source, target, false);
+ fail();
+ } catch (IncompatibleServiceContractException e) {
+ //expected
+ }
+ }
+
+ public void testInputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ List<DataType<Type>> sourceInputTypes = new ArrayList<DataType<Type>>();
+ sourceInputTypes.add(new DataType<Type>(Object.class, Object.class));
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(String.class, sourceInputTypes);
+ Operation<Type> opSource1 = new Operation<Type>("op1", inputType, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ List<DataType<Type>> targetInputTypes = new ArrayList<DataType<Type>>();
+ targetInputTypes.add(new DataType<Type>(Object.class, Object.class));
+ DataType<List<DataType<Type>>> targetInputType =
+ new DataType<List<DataType<Type>>>(String.class, targetInputTypes);
+
+ Operation<Type> opTarget = new Operation<Type>("op1", targetInputType, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+
+ public void testIncompatibleInputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ List<DataType<Type>> sourceInputTypes = new ArrayList<DataType<Type>>();
+ sourceInputTypes.add(new DataType<Type>(Integer.class, Integer.class));
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(String.class, sourceInputTypes);
+ Operation<Type> opSource1 = new Operation<Type>("op1", inputType, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ List<DataType<Type>> targetInputTypes = new ArrayList<DataType<Type>>();
+ targetInputTypes.add(new DataType<Type>(String.class, String.class));
+ DataType<List<DataType<Type>>> targetInputType =
+ new DataType<List<DataType<Type>>>(String.class, targetInputTypes);
+
+ Operation<Type> opTarget = new Operation<Type>("op1", targetInputType, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ try {
+ wireService.checkCompatibility(source, target, false);
+ fail();
+ } catch (IncompatibleServiceContractException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Verfies source input types can be super types of the target
+ */
+ public void testSourceSuperTypeInputCompatibility() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// List<DataType<Type>> sourceInputTypes = new ArrayList<DataType<Type>>();
+// sourceInputTypes.add(new DataType<Type>(Object.class, Object.class));
+// DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(String.class, sourceInputTypes);
+// Operation<Type> opSource1 = new Operation<Type>("op1", inputType, null, null, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// List<DataType<Type>> targetInputTypes = new ArrayList<DataType<Type>>();
+// targetInputTypes.add(new DataType<Type>(String.class, String.class));
+// DataType<List<DataType<Type>>> targetInputType =
+// new DataType<List<DataType<Type>>>(String.class, targetInputTypes);
+//
+// Operation<Type> opTarget = new Operation<Type>("op1", targetInputType, null, null, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testOutputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceOutputType = new DataType<Type>(String.class, String.class);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, sourceOutputType, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ DataType<Type> targetOutputType = new DataType<Type>(String.class, String.class);
+ Operation<Type> opTarget = new Operation<Type>("op1", null, targetOutputType, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verfies a return type that is a supertype of of the target is compatible
+ */
+ public void testSupertypeOutputTypes() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// DataType<Type> sourceOutputType = new DataType<Type>(Object.class, Object.class);
+// Operation<Type> opSource1 = new Operation<Type>("op1", null, sourceOutputType, null, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// DataType<Type> targetOutputType = new DataType<Type>(String.class, String.class);
+// Operation<Type> opTarget = new Operation<Type>("op1", null, targetOutputType, null, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testIncompatibleOutputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceOutputType = new DataType<Type>(String.class, String.class);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, sourceOutputType, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ DataType<Type> targetOutputType = new DataType<Type>(Integer.class, Integer.class);
+ Operation<Type> opTarget = new Operation<Type>("op1", null, targetOutputType, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ try {
+ wireService.checkCompatibility(source, target, false);
+ fail();
+ } catch (IncompatibleServiceContractException e) {
+ //expected
+ }
+ }
+
+ public void testFaultTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceFaultType = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ DataType<Type> targetFaultType = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> targetFaultTypes = new ArrayList<DataType<Type>>();
+ targetFaultTypes.add(0, targetFaultType);
+
+ Operation<Type> opTarget = new Operation<Type>("op1", null, null, targetFaultTypes, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testSourceFaultTargetNoFaultCompatibility() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceFaultType = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ Operation<Type> opTarget = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verifies a source's fault which is a supertype of the target's fault are compatibile
+ *
+ * @throws Exception
+ */
+ public void testFaultSuperTypes() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// DataType<Type> sourceFaultType = new DataType<Type>(Exception.class, Exception.class);
+// List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+// sourceFaultTypes.add(0, sourceFaultType);
+// Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// DataType<Type> targetFaultType = new DataType<Type>(TuscanyException.class, TuscanyException.class);
+// List<DataType<Type>> targetFaultTypes = new ArrayList<DataType<Type>>();
+// targetFaultTypes.add(0, targetFaultType);
+//
+// Operation<Type> opTarget = new Operation<Type>("op1", null, null, targetFaultTypes, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verifies a source's faults which are supertypes and a superset of the target's faults are compatibile
+ */
+ public void testFaultSuperTypesAndSuperset() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// DataType<Type> sourceFaultType = new DataType<Type>(Exception.class, Exception.class);
+// DataType<Type> sourceFaultType2 = new DataType<Type>(RuntimeException.class, RuntimeException.class);
+// List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+// sourceFaultTypes.add(0, sourceFaultType);
+// sourceFaultTypes.add(1, sourceFaultType2);
+// Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// DataType<Type> targetFaultType = new DataType<Type>(TuscanyException.class, TuscanyException.class);
+// List<DataType<Type>> targetFaultTypes = new ArrayList<DataType<Type>>();
+// targetFaultTypes.add(0, targetFaultType);
+//
+// Operation<Type> opTarget = new Operation<Type>("op1", null, null, targetFaultTypes, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ private class MockContract<T> extends ServiceContract<T> {
+ public MockContract() {
+ }
+
+ public MockContract(Class interfaceClass) {
+ super(interfaceClass);
+ }
+
+ public MockContract(String interfaceName) {
+ super(interfaceName);
+ }
+ }
+
+ private class MockWireService extends WireServiceExtension {
+ public MockWireService() {
+ super(null, null);
+ }
+
+ public Object createProxy(RuntimeWire wire) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object createCallbackProxy(ServiceContract<?> contract, InboundWire wire) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public WireInvocationHandler createHandler(RuntimeWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public WireInvocationHandler createCallbackHandler(InboundWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public OutboundInvocationChain createOutboundChain(Operation<?> operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public InboundInvocationChain createInboundChain(Operation<?> operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public InboundWire createWire(ServiceDefinition service) {
+ throw new UnsupportedOperationException();
+ }
+
+ public OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createWires(Component component, ComponentDefinition<?> definition) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createWires(Reference reference, ServiceContract<?> contract) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createWires(Service service, String targetName, ServiceContract<?> contract) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/pom.xml
new file mode 100644
index 0000000000..91c1418550
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-plugin-java2wsdl</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Tuscany SCA - Maven Plugin for Java2WSDL</name>
+ <description>Implementation of Java2WSDL Generator</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sca-tools</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/plugin/Java2WSDLGeneratorMojo.java b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/plugin/Java2WSDLGeneratorMojo.java
new file mode 100644
index 0000000000..a5f6158dcd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/plugin/Java2WSDLGeneratorMojo.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.plugin;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.tuscany.tools.java2wsdl.generate.Java2WSDLGeneratorFactory;
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+
+/**
+ * @version $Rev$ $Date$
+ * @goal generate
+ * @phase generate-sources
+ * @description Generate WSDL from a given Java class / interface
+ */
+public class Java2WSDLGeneratorMojo extends AbstractMojo
+{
+
+ /**
+ * The name of the class for which the WSDL must be generated
+ * @parameter
+ *
+ */
+ private String sourceClassName;
+
+ /**
+ * The location where the wsdls should be generated into
+ * @parameter expression="${project.build.directory}\\java2wsdl-wsdl"
+ */
+ private String targetLocation;
+
+ /**
+ * The name of the wsdl file
+ * @parameter
+ */
+ private String wsdlFilename;
+
+
+ /**
+ * Classpaths to be included
+ * @parameter
+ *
+ */
+ String[] classpaths;
+
+ /**
+ * The name of the service
+ * @parameter
+ */
+ private String serviceName;
+
+ /**
+ * The binding style for the service
+ * @parameter
+ */
+ private String bindingStyle;
+
+ /**
+ * The binding use option
+ * @parameter
+ */
+ private String bindingUse;
+
+ /**
+ * The soap address
+ * @parameter
+ */
+ private String soapAddress;
+
+ public void execute() throws MojoExecutionException
+ {
+ try
+ {
+ Java2WSDLGeneratorFactory.getInstance().createGenerator().generateWSDL(createOptionsMap ());
+ }
+ catch ( Exception e )
+ {
+ throw new MojoExecutionException("Exception in Java2WSDL Maven Plugin ", e);
+ }
+ }
+
+ protected Map createOptionsMap()
+ {
+ Map optionsMap = new Hashtable();
+
+ optionsMap.put(Java2WSDLConstants.CLASSNAME_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.CLASSNAME_OPTION, new String[]{sourceClassName}));
+
+ if ( targetLocation != null )
+ {
+ optionsMap.put(Java2WSDLConstants.OUTPUT_LOCATION_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.OUTPUT_LOCATION_OPTION, new String[]{targetLocation}));
+ }
+
+ if ( wsdlFilename != null )
+ {
+ optionsMap.put(Java2WSDLConstants.OUTPUT_FILENAME_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.OUTPUT_FILENAME_OPTION, new String[]{wsdlFilename}));
+ }
+
+ if ( classpaths != null && classpaths.length > 0 )
+ {
+ optionsMap.put(Java2WSDLConstants.CLASSPATH_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.CLASSPATH_OPTION, classpaths));
+ }
+
+ if ( serviceName != null )
+ {
+ optionsMap.put(Java2WSDLConstants.SERVICE_NAME_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.SERVICE_NAME_OPTION, new String[]{serviceName}));
+ }
+
+ if ( bindingStyle != null )
+ {
+ optionsMap.put(Java2WSDLConstants.STYLE_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.STYLE_OPTION, new String[]{bindingStyle}));
+ }
+
+ if ( bindingUse != null )
+ {
+ optionsMap.put(Java2WSDLConstants.USE_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.USE_OPTION, new String[]{bindingUse}));
+ }
+
+ if ( soapAddress != null )
+ {
+ optionsMap.put(Java2WSDLConstants.LOCATION_OPTION,
+ new Java2WSDLCommandLineOption(Java2WSDLConstants.LOCATION_OPTION, new String[]{soapAddress}));
+ }
+
+ return optionsMap;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..25d78feeac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,1277 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+APACHE TUSCANY SUBCOMPONENTS:
+
+The Apache Tuscany distribution includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+For the Eclipse Modeling Framework component and the Celtix binding:
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and
+are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program by such
+Contributor itself or anyone acting on such Contributor's behalf.
+Contributions do not include additions to the Program which: (i) are
+separate modules of software distributed in conjunction with the
+Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and
+object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor, if
+any, in source code and object code form. This patent license shall
+apply to the combination of the Contribution and the Program if, at
+the time the Contribution is added by the Contributor, such addition
+of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the
+licenses to its Contributions set forth herein, no assurances are
+provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow
+Recipient to distribute the Program, it is Recipient's responsibility
+to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental and
+consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are
+offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable
+manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the
+Program.
+
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a
+commercial product offering should do so in a manner which does not
+create potential liability for other Contributors. Therefore, if a
+Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend
+and indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the acts
+or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement.
+In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b)
+allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such
+claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable
+laws, damage to or loss of data, programs or equipment, and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+the Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of
+the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign
+the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions)
+may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives
+no rights or licenses to the intellectual property of any Contributor
+under this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+For the Rhino JavaScript container component:
+
+Mozilla Public License 1.1 (MPL 1.1)
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original Code,
+prior Modifications used by a Contributor, and the Modifications made by that
+particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+combination of the Original Code and Modifications, in each case including
+portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+accepted in the software development community for the electronic transfer of
+data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified as
+the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+extent possible, whether at the time of the initial grant or subsequently
+acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+substance or structure of either the Original Code or any previous
+Modifications. When Covered Code is released as a series of files, a
+Modification is:
+ A. Any addition to or deletion from the contents of a file
+containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+which is described in the Source Code notice required by Exhibit A as Original
+Code, and which, at the time of its release under this License is not already
+Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+hereafter acquired, including without limitation, method, process, and
+apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+making modifications to it, including all modules it contains, plus any
+associated interface definition files, scripts used to control compilation and
+installation of an Executable, or source code differential comparisons against
+either the Original Code or another well known, available Covered Code of the
+Contributor's choice. The Source Code can be in a compressed or archival form,
+provided the appropriate decompression or de-archiving software is widely
+available for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+exercising rights under, and complying with all of the terms of, this License
+or a future version of this License issued under Section 6.1. For legal
+entities, "You" includes any entity which controls, is controlled by, or is
+under common control with You. For purposes of this definition, "control"
+means (a) the power, direct or indirect, to cause the direction or management
+of such entity, whether by contract or otherwise, or (b) ownership of more
+than fifty percent (50%) of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+non-exclusive license, subject to third party intellectual property claims:
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Initial Developer to use, reproduce, modify, display,
+perform, sublicense and distribute the Original Code (or portions thereof)
+with or without Modifications, and/or as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or selling
+of Original Code, to make, have made, use, practice, sell, and offer for sale,
+and/or otherwise dispose of the Original Code (or portions thereof).
+ (c) the licenses granted in this Section 2.1(a) and
+(b) are effective on the date Initial Developer first distributes Original
+Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+granted: 1) for code that You delete from the Original Code; 2) separate from
+the Original Code; or 3) for infringements caused by: i) the modification of
+the Original Code or ii) the combination of the Original Code with other
+software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Contributor, to use, reproduce, modify, display,
+perform, sublicense and distribute the Modifications created by such
+Contributor (or portions thereof) either on an unmodified basis, with other
+Modifications, as Covered Code and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or selling
+of Modifications made by that Contributor either alone and/or in combination
+with its Contributor Version (or portions of such combination), to make, use,
+sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications
+made by that Contributor (or portions thereof); and 2) the combination of
+Modifications made by that Contributor with its Contributor Version (or
+portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+effective on the date Contributor first makes Commercial Use of the Covered
+Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+granted: 1) for any code that Contributor has deleted from the Contributor
+Version; 2) separate from the Contributor Version; 3) for infringements
+caused by: i) third party modifications of Contributor Version or ii) the
+combination of Modifications made by that Contributor with other software
+(except as part of the Contributor Version) or other devices; or 4) under
+Patent Claims infringed by Covered Code in the absence of Modifications made
+by that Contributor.
+
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+governed by the terms of this License, including without limitation Section
+2.2. The Source Code version of Covered Code may be distributed only under the
+terms of this License or a future version of this License released under
+Section 6.1, and You must include a copy of this License with every copy of
+the Source Code You distribute. You may not offer or impose any terms on any
+Source Code version that alters or restricts the applicable version of this
+License or the recipients' rights hereunder. However, You may include an
+additional document offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+made available in Source Code form under the terms of this License either on
+the same media as an Executable version or via an accepted Electronic
+Distribution Mechanism to anyone to whom you made an Executable version
+available; and if made available via Electronic Distribution Mechanism, must
+remain available for at least twelve (12) months after the date it initially
+became available, or at least six (6) months after a subsequent version of
+that particular Modification has been made available to such recipients. You
+are responsible for ensuring that the Source Code version remains available
+even if the Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+file documenting the changes You made to create that Covered Code and the date
+of any change. You must include a prominent statement that the Modification is
+derived, directly or indirectly, from Original Code provided by the Initial
+Developer and including the name of the Initial Developer in (a) the Source
+Code, and (b) in any notice in an Executable version or related documentation
+in which You describe the origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+intellectual property rights is required to exercise the rights granted by
+such Contributor under Sections 2.1 or 2.2, Contributor must include a text
+file with the Source Code distribution titled "LEGAL" which describes the
+claim and the party making the claim in sufficient detail that a recipient
+will know whom to contact. If Contributor obtains such knowledge after the
+Modification is made available as described in Section 3.2, Contributor shall
+promptly modify the LEGAL file in all copies Contributor makes available
+thereafter and shall take other steps (such as notifying appropriate mailing
+lists or newsgroups) reasonably calculated to inform those who received the
+Covered Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+interface and Contributor has knowledge of patent licenses which are
+reasonably necessary to implement that API, Contributor must also include this
+information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+Section 3.4(a) above, Contributor believes that Contributor's Modifications
+are Contributor's original creation(s) and/or Contributor has sufficient
+rights to grant the rights conveyed by this License.
+
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+Code. If it is not possible to put such notice in a particular Source Code
+file due to its structure, then You must include such notice in a location
+(such as a relevant directory) where a user would be likely to look for such a
+notice. If You created one or more Modification(s) You may add your name as a
+Contributor to the notice described in Exhibit A. You must also duplicate
+this License in any documentation for the Source Code where You describe
+recipients' rights or ownership rights relating to Covered Code. You may
+choose to offer, and to charge a fee for, warranty, support, indemnity or
+liability obligations to one or more recipients of Covered Code. However, You
+may do so only on Your own behalf, and not on behalf of the Initial Developer
+or any Contributor. You must make it absolutely clear than any such warranty,
+support, indemnity or liability obligation is offered by You alone, and You
+hereby agree to indemnify the Initial Developer and every Contributor for any
+liability incurred by the Initial Developer or such Contributor as a result of
+warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+requirements of Section 3.1-3.5 have been met for that Covered Code, and if
+You include a notice stating that the Source Code version of the Covered Code
+is available under the terms of this License, including a description of how
+and where You have fulfilled the obligations of Section 3.2. The notice must
+be conspicuously included in any notice in an Executable version, related
+documentation or collateral in which You describe recipients' rights relating
+to the Covered Code. You may distribute the Executable version of Covered Code
+or ownership rights under a license of Your choice, which may contain terms
+different from this License, provided that You are in compliance with the
+terms of this License and that the license for the Executable version does not
+attempt to limit or alter the recipient's rights in the Source Code version
+from the rights set forth in this License. If You distribute the Executable
+version under a different license You must make it absolutely clear that any
+terms which differ from this License are offered by You alone, not by the
+Initial Developer or any Contributor. You hereby agree to indemnify the
+Initial Developer and every Contributor for any liability incurred by the
+Initial Developer or such Contributor as a result of any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+not governed by the terms of this License and distribute the Larger Work as a
+single product. In such a case, You must make sure the requirements of this
+License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Code due to statute,
+judicial order, or regulation then You must: (a) comply with the terms of this
+License to the maximum extent possible; and (b) describe the limitations and
+the code they affect. Such description must be included in the LEGAL file
+described in Section 3.4 and must be included with all distributions of the
+Source Code. Except to the extent prohibited by statute or regulation, such
+description must be sufficiently detailed for a recipient of ordinary skill to
+be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has attached
+the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+and/or new versions of the License from time to time. Each version will be
+given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+License, You may always continue to use it under the terms of that version.
+You may also choose to use such Covered Code under the terms of any subsequent
+version of the License published by Netscape. No one other than Netscape has
+the right to modify the terms applicable to Covered Code created under this
+License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+only do in order to apply it to code which is not already Covered Code
+governed by this License), You must (a) rename Your license so that the
+phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or
+any confusingly similar phrase do not appear in your license (except to note
+that your license differs from this License) and (b) otherwise make it clear
+that Your version of the license contains terms which differ from the Mozilla
+Public License and Netscape Public License. (Filling in the name of the
+Initial Developer, Original Code or Contributor in the notice described in
+Exhibit A shall not of themselves be deemed to be modifications of this
+License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE,
+FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE
+QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED
+CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR
+CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
+LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+automatically if You fail to comply with terms herein and fail to cure such
+breach within 30 days of becoming aware of the breach. All sublicenses to the
+Covered Code which are properly granted shall survive any termination of this
+License. Provisions which, by their nature, must remain in effect beyond the
+termination of this License shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+claim (excluding declatory judgment actions) against Initial Developer or a
+Contributor (the Initial Developer or Contributor against whom You file such
+action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+infringes any patent, then any and all rights granted by such Participant to
+You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice
+from Participant terminate prospectively, unless if within 60 days after
+receipt of notice You either: (i) agree in writing to pay Participant a
+mutually agreeable reasonable royalty for Your past and future use of
+Modifications made by such Participant, or (ii) withdraw Your litigation claim
+with respect to the Contributor Version against such Participant. If within
+60 days of notice, a reasonable royalty and payment arrangement are not
+mutually agreed upon in writing by the parties or the litigation claim is not
+withdrawn, the rights granted by Participant to You under Sections 2.1 and/or
+2.2 automatically terminate at the expiration of the 60 day notice period
+specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+Contributor Version, directly or indirectly infringes any patent, then any
+rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are
+revoked effective as of the date You first made, used, sold, distributed, or
+had made, Modifications made by that Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+alleging that such Participant's Contributor Version directly or indirectly
+infringes any patent where such claim is resolved (such as by license or
+settlement) prior to the initiation of patent infringement litigation, then
+the reasonable value of the licenses granted by such Participant under
+Sections 2.1 or 2.2 shall be taken into account in determining the amount or
+value of any payment or license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above, all
+end user license agreements (excluding distributors and resellers) which have
+been validly granted by You or any distributor hereunder prior to termination
+shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY
+SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING,
+WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
+FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH
+DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH
+OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
+EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in 48
+C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and
+"commercial computer software documentation," as such terms are used in 48
+C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R.
+227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users
+acquire Covered Code with only those rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it
+enforceable. This License shall be governed by California law provisions
+(except to the extent applicable law, if any, provides otherwise), excluding
+its conflict-of-law provisions. With respect to disputes in which at least one
+party is a citizen of, or an entity chartered or registered to do business in
+the United States of America, any litigation relating to this License shall be
+subject to the jurisdiction of the Federal Courts of the Northern District of
+California, with venue lying in Santa Clara County, California, with the
+losing party responsible for costs, including without limitation, court costs
+and reasonable attorneys' fees and expenses. The application of the United
+Nations Convention on Contracts for the International Sale of Goods is
+expressly excluded. Any law or regulation which provides that the language of
+a contract shall be construed against the drafter shall not apply to this
+License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+responsible for claims and damages arising, directly or indirectly, out of its
+utilization of rights under this License and You agree to work with Initial
+Developer and Contributors to distribute such responsibility on an equitable
+basis. Nothing herein is intended or shall be deemed to constitute any
+admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits
+you to utilize portions of the Covered Code under Your choice of the MPL or
+the alternative licenses, if any, specified by the Initial Developer in the
+file described in Exhibit A.
+
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+language governing rights and
+ limitations under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+Portions created by
+ ______________________ are Copyright (C) ______
+_______________________. All Rights
+ Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms of
+the _____ license (the [___] License), in which case the provisions of
+[______] License are applicable instead of those above. If you wish to allow
+use of your version of this file only under the terms of the [____] License
+and not to allow others to use your version of this file under the MPL,
+indicate your decision by deleting the provisions above and replace them
+with the notice and other provisions required by the [___] License. If you do
+not delete the provisions above, a recipient may use your version of this file
+under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+the notices in the Source Code files of the Original Code. You should use the
+text of this Exhibit A rather than the text found in the Original Code Source
+Code for Your Modifications.]
+
+
+===============================================================================
+
+For the JAX-WS Reference Implementation component:
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+
+ 1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that
+ creates or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the
+ Original Software, prior Modifications used by a
+ Contributor (if any), and the Modifications made by that
+ particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or
+ (b) Modifications, or (c) the combination of files
+ containing Original Software with files containing
+ Modifications, in each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form
+ other than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity
+ that first makes Original Software available under this
+ License.
+
+ 1.6. "Larger Work" means a work which combines Covered
+ Software or portions thereof with code not governed by the
+ terms of this License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the
+ maximum extent possible, whether at the time of the initial
+ grant or subsequently acquired, any and all of the rights
+ conveyed herein.
+
+ 1.9. "Modifications" means the Source Code and Executable
+ form of any of the following:
+
+ A. Any file that results from an addition to,
+ deletion from or modification of the contents of a
+ file containing Original Software or previous
+ Modifications;
+
+ B. Any new file that contains any part of the
+ Original Software or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and
+ Executable form of computer software code that is
+ originally released under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned
+ or hereafter acquired, including without limitation,
+ method, process, and apparatus claims, in any patent
+ Licensable by grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer
+ software code in which modifications are made and (b)
+ associated documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal
+ entity exercising rights under, and complying with all of
+ the terms of, this License. For legal entities, "You"
+ includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or
+ indirect, to cause the direction or management of such
+ entity, whether by contract or otherwise, or (b) ownership
+ of more than fifty percent (50%) of the outstanding shares
+ or beneficial ownership of such entity.
+
+ 2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the
+ Initial Developer hereby grants You a world-wide,
+ royalty-free, non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Initial Developer,
+ to use, reproduce, modify, display, perform,
+ sublicense and distribute the Original Software (or
+ portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making,
+ using or selling of Original Software, to make, have
+ made, use, practice, sell, and offer for sale, and/or
+ otherwise dispose of the Original Software (or
+ portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b)
+ are effective on the date Initial Developer first
+ distributes or otherwise makes the Original Software
+ available to a third party under the terms of this
+ License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent
+ license is granted: (1) for code that You delete from
+ the Original Software, or (2) for infringements
+ caused by: (i) the modification of the Original
+ Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Contributor to
+ use, reproduce, modify, display, perform, sublicense
+ and distribute the Modifications created by such
+ Contributor (or portions thereof), either on an
+ unmodified basis, with other Modifications, as
+ Covered Software and/or as part of a Larger Work; and
+
+
+ (b) under Patent Claims infringed by the making,
+ using, or selling of Modifications made by that
+ Contributor either alone and/or in combination with
+ its Contributor Version (or portions of such
+ combination), to make, use, sell, offer for sale,
+ have made, and/or otherwise dispose of: (1)
+ Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications
+ made by that Contributor with its Contributor Version
+ (or portions of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and
+ 2.2(b) are effective on the date Contributor first
+ distributes or otherwise makes the Modifications
+ available to a third party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent
+ license is granted: (1) for any code that Contributor
+ has deleted from the Contributor Version; (2) for
+ infringements caused by: (i) third party
+ modifications of Contributor Version, or (ii) the
+ combination of Modifications made by that Contributor
+ with other software (except as part of the
+ Contributor Version) or other devices; or (3) under
+ Patent Claims infringed by Covered Software in the
+ absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be
+ distributed only under the terms of this License. You must
+ include a copy of this License with every copy of the
+ Source Code form of the Covered Software You distribute or
+ otherwise make available. You must inform recipients of any
+ such Covered Software in Executable form as to how they can
+ obtain such Covered Software in Source Code form in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You
+ contribute are governed by the terms of this License. You
+ represent that You believe Your Modifications are Your
+ original creation(s) and/or You have sufficient rights to
+ grant the rights conveyed by this License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications
+ that identifies You as the Contributor of the Modification.
+ You may not remove or alter any copyright, patent or
+ trademark notices contained within the Covered Software, or
+ any notices of licensing or any descriptive text giving
+ attribution to any Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered
+ Software in Source Code form that alters or restricts the
+ applicable version of this License or the recipients'
+ rights hereunder. You may choose to offer, and to charge a
+ fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Software.
+ However, you may do so only on Your own behalf, and not on
+ behalf of the Initial Developer or any Contributor. You
+ must make it absolutely clear that any such warranty,
+ support, indemnity or liability obligation is offered by
+ You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered
+ Software under the terms of this License or under the terms
+ of a license of Your choice, which may contain terms
+ different from this License, provided that You are in
+ compliance with the terms of this License and that the
+ license for the Executable form does not attempt to limit
+ or alter the recipient's rights in the Source Code form
+ from the rights set forth in this License. If You
+ distribute the Covered Software in Executable form under a
+ different license, You must make it absolutely clear that
+ any terms which differ from this License are offered by You
+ alone, not by the Initial Developer or Contributor. You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial
+ Developer or such Contributor as a result of any such terms
+ You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software
+ with other code not governed by the terms of this License
+ and distribute the Larger Work as a single product. In such
+ a case, You must make sure the requirements of this License
+ are fulfilled for the Covered Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and
+ may publish revised and/or new versions of this License
+ from time to time. Each version will be given a
+ distinguishing version number. Except as provided in
+ Section 4.3, no one other than the license steward has the
+ right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. If the Initial Developer includes a
+ notice in the Original Software prohibiting it from being
+ distributed or otherwise made available under any
+ subsequent version of the License, You must distribute and
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software
+ available under the terms of any subsequent version of the
+ License published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a
+ new license for Your Original Software, You may create and
+ use a modified version of this License if You: (a) rename
+ the license and remove any references to the name of the
+ license steward (except to note that the license differs
+ from this License); and (b) otherwise make it clear that
+ the license contains terms which differ from this License.
+
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will
+ terminate automatically if You fail to comply with terms
+ herein and fail to cure such breach within 30 days of
+ becoming aware of the breach. Provisions which, by their
+ nature, must remain in effect beyond the termination of
+ this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or
+ a Contributor (the Initial Developer or Contributor against
+ whom You assert such claim is referred to as "Participant")
+ alleging that the Participant Software (meaning the
+ Contributor Version where the Participant is a Contributor
+ or the Original Software where the Participant is the
+ Initial Developer) directly or indirectly infringes any
+ patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant)
+ and all Contributors under Sections 2.1 and/or 2.2 of this
+ License shall, upon 60 days notice from Participant
+ terminate prospectively and automatically at the expiration
+ of such 60 day notice period, unless if within such 60 day
+ period You withdraw Your claim with respect to the
+ Participant Software against such Participant either
+ unilaterally or pursuant to a written agreement with
+ Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2
+ above, all end user licenses that have been validly granted
+ by You or any distributor hereunder prior to termination
+ (excluding licenses granted to You by any distributor)
+ shall survive termination.
+
+ 7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48 C.F.R.
+ 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
+ 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+ through 227.7202-4 (June 1995), all U.S. Government End Users
+ acquire Covered Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the
+ extent necessary to make it enforceable. This License shall be
+ governed by the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, with the losing
+ party responsible for costs, including, without limitation, court
+ costs and reasonable attorneys' fees and expenses. The
+ application of the United Nations Convention on Contracts for the
+ International Sale of Goods is expressly excluded. Any law or
+ regulation which provides that the language of a contract shall
+ be construed against the drafter shall not apply to this License.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/README.txt b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/README.txt
new file mode 100644
index 0000000000..9b26d1690a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.java2wsdl/src/main/resources/META-INF/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/pom.xml
new file mode 100644
index 0000000000..b828c402af
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-war-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Tuscany War Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java
new file mode 100644
index 0000000000..55183cf0a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.plugin.war;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+
+/**
+ * Represents a configured tuscany dependency for boot and extension libraries.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Dependency {
+
+ /**
+ * JAR type artifact.
+ */
+ private static final String TYPE_JAR = "jar";
+
+ /**
+ * Default boot libraries. TODO Decide on whether to get snapshot version rather than hardcoded version..
+ */
+ private static final Dependency[] DEFAULT_BOOT_LIBS = new Dependency[] { new WebappHostDependency() };
+
+ /**
+ * Group Id that is injected in from configuration.
+ */
+ private String groupId;
+
+ /**
+ * Artifact Id that is injected in from configuration.
+ */
+ private String artifactId;
+
+ /**
+ * Version that is injected in from configuration.
+ */
+ private String version;
+
+ /**
+ * Default constructor.
+ *
+ */
+ public Dependency() {
+ }
+
+ /**
+ * Initializes the field.
+ *
+ * @param groupId
+ * Group id.
+ * @param artifactId
+ * Artifact id.
+ * @param version
+ * Artifact version.
+ */
+ public Dependency(String groupId, String artifactId, String version) {
+ super();
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ }
+
+ /**
+ * Gets the artifact using the specified artifact factory.
+ *
+ * @param artifactFactory
+ * Artifact factory to use.
+ * @return Artifact identified by the dependency.
+ */
+ public Artifact getArtifact(ArtifactFactory artifactFactory) {
+ return artifactFactory.createArtifact(groupId, artifactId, version, Artifact.SCOPE_RUNTIME, TYPE_JAR);
+ }
+
+ /**
+ * Returns the default boot libraries.
+ *
+ * @return Default boot libraries.
+ */
+ public static Dependency[] getDefaultBootLibs() {
+ return DEFAULT_BOOT_LIBS;
+ }
+
+ /**
+ * Checks whether the specified artifact has the same artifact id.
+ *
+ * @param artifact
+ * Artifact to be matched.
+ * @return True if the sepcified artifact has the same id.
+ */
+ public boolean match(Artifact artifact) {
+ // TODO Auto-generated method stub
+ return artifact.getArtifactId().equals(artifactId);
+ }
+
+ /**
+ * Webapp host depndency.
+ */
+ private static class WebappHostDependency extends Dependency {
+ // TODO Decide on whether to get snapshot version rather than hardcoded version
+ private WebappHostDependency() {
+ super("org.apache.tuscany.sca.runtime", "webapp-host", "1.0-incubator-M2-SNAPSHOT");
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java
new file mode 100644
index 0000000000..7d9e45b1ab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java
@@ -0,0 +1,473 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.plugin.war;
+
+import java.beans.XMLEncoder;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.metadata.ResolutionGroup;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Build the tuscany war file by adding the tuscany dependencies.
+ *
+ * Performs the following tasks.
+ *
+ * <ul>
+ * <li>Adds the boot dependencies transitively to WEB-INF/tuscany/boot</li>
+ * <li>By default boot libraries are transitively resolved from webapp-host</li>
+ * <li>The version of boot libraries can be specified using configuration/runTimeVersion element</li>
+ * <li>Boot libraries can be overridden using the configuration/bootLibs element in the plugin</li>
+ * <li>Adds the extension artifacts specified using configuration/extensions to WEB-INF/tuscany/extensions</li>
+ * <li>If configuration/loadExtensionsDependency is set to true extension dependencies are transitivel loaded</li>
+ * <li>Extension dependencies are loaded into WEB-INF/tuscany/repository directory in a Maven repo format</li>
+ * <li>Extension dependency metadata is written to WEB-INF/tuscany/repository/dependency.metadata file</li>
+ * </ul>
+ * @goal tuscany-war
+ * @phase package
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public class TuscanyWarMojo extends AbstractMojo {
+
+ /**
+ * Tuscany path.
+ */
+ private static final String TUSCANY_PATH = "WEB-INF/tuscany/";
+
+ /**
+ * Tuscany boot path.
+ */
+ private static final String BOOT_PATH = TUSCANY_PATH + "boot/";
+
+ /**
+ * Tuscany extension path.
+ */
+ private static final String EXTENSION_PATH = TUSCANY_PATH + "extensions/";
+
+ /**
+ * Tuscany repository path.
+ */
+ private static final String REPOSITORY_PATH = TUSCANY_PATH + "repository/";
+
+ /**
+ * Artifact metadata source.
+ *
+ * @component
+ */
+ private ArtifactMetadataSource metadataSource;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
+ * @required
+ * @readonly
+ */
+ private ArtifactFactory artifactFactory;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression="${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactResolver resolver;
+
+ /**
+ * Location of the local repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * @required
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ */
+ private List remoteRepositories;
+
+ /**
+ * The directory for the generated WAR.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private String outputDirectory;
+
+ /**
+ * The directory for the generated WAR.
+ *
+ * @parameter
+ */
+ private Dependency[] bootLibs = Dependency.getDefaultBootLibs();
+
+ /**
+ * The directory for the generated WAR.
+ *
+ * @parameter
+ */
+ private Dependency[] extensions = new Dependency[0];
+
+ /**
+ * The name of the generated WAR.
+ *
+ * @parameter expression="${project.build.finalName}"
+ * @required
+ */
+ private String warName;
+
+ /**
+ * A flag to indicate whether extension dependencies should be resolved transitively.
+ *
+ * @parameter
+ */
+ private boolean loadExtensionDependencies;
+
+ /**
+ * The default version of boot dependany jar files
+ *
+ * @parameter
+ */
+ private String runTimeVersion = null;
+
+ /**
+ * WEB-INF jar files.
+ */
+ private Set<String> packagedLibs = new HashSet<String>();
+
+ /**
+ * Transitive dependencies for extensions.
+ */
+ private Map transDepenedencyMap = new HashMap();
+
+ /**
+ * Executes the MOJO.
+ */
+ public void execute() throws MojoExecutionException {
+
+ JarFile originalWar = null;
+ JarOutputStream newWar = null;
+ File originalWarFile = null;
+ File newWarFile = null;
+
+ boolean success = false;
+
+ try {
+
+ // if there is a runtime version specified and no bootLib dependancies,
+ // modify the bootLibs to have the runtime version.
+ if (runTimeVersion != null && bootLibs == Dependency.getDefaultBootLibs()) {
+ Dependency dependancy = new Dependency("org.apache.tuscany.sca.runtime",
+ "webapp-host", runTimeVersion);
+ bootLibs = new Dependency[] {dependancy};
+ }
+
+ originalWarFile = new File(outputDirectory, warName + ".war");
+ originalWar = new JarFile(originalWarFile);
+
+ newWarFile = new File(outputDirectory, warName + "-temp.war");
+ newWar = new JarOutputStream(new FileOutputStream(newWarFile));
+
+ copyOriginal(originalWar, newWar);
+
+ addEntry(newWar, TUSCANY_PATH);
+ addEntry(newWar, BOOT_PATH);
+ addEntry(newWar, EXTENSION_PATH);
+ addEntry(newWar, REPOSITORY_PATH);
+
+ for (Dependency dependency : bootLibs) {
+ for (Artifact art : resolveArtifact(dependency.getArtifact(artifactFactory), true)) {
+ addArtifact(newWar, BOOT_PATH, art);
+ }
+ }
+
+ for (Dependency dependency : extensions) {
+ for (Artifact art : resolveArtifact(dependency.getArtifact(artifactFactory), loadExtensionDependencies)) {
+ if (dependency.match(art)) {
+ addArtifact(newWar, EXTENSION_PATH, art);
+ }
+
+ // Load dependencies even for the extension itself
+ if (loadExtensionDependencies) {
+ loadExtensionDependencies(newWar, art);
+ }
+
+ }
+ }
+
+ writeDependencyMetadata(newWar);
+
+ success = true;
+
+ } catch (Exception ex) {
+ throw new MojoExecutionException(ex.getMessage(), ex);
+ } finally {
+ IOUtils.closeQuietly(newWar);
+ }
+
+ if (success) {
+ if (!originalWarFile.delete()) {
+ throw new MojoExecutionException("Unable to rename war file");
+ }
+ if (!newWarFile.renameTo(originalWarFile)) {
+ throw new MojoExecutionException("Unable to rename war file");
+ }
+ }
+
+ }
+
+ /**
+ * Adds an entry to the JAR failing safe for duplicate.
+ *
+ * @param jar JAR to which the entry is added.
+ * @param entry Entry to be added.
+ * @return True if added successfully.
+ * @throws IOException In case of an IO error.
+ */
+ private boolean addEntry(JarOutputStream jar, String entry) throws IOException {
+ try {
+ jar.putNextEntry(new JarEntry(entry));
+ return true;
+ } catch(ZipException duplicateEntry) {
+ getLog().info(duplicateEntry.getMessage());
+ return false;
+ }
+ }
+
+ /**
+ * Writes the dependency metadata.
+ * @param newWar WAR to which the metadata is written.
+ * @throws IOException In case of an IO error.
+ */
+ private void writeDependencyMetadata(JarOutputStream newWar) throws IOException {
+
+ FileOutputStream depMapOutStream = null;
+ FileInputStream depMapInStream = null;
+
+ try {
+ String metadataFile = "dependency.metadata";
+
+ File file = new File(outputDirectory, "webapp");
+ file = new File(file, REPOSITORY_PATH);
+ file.mkdirs();
+
+ file = new File(file, metadataFile);
+ file.createNewFile();
+
+ depMapOutStream = new FileOutputStream(file);
+ XMLEncoder xmlEncoder = new XMLEncoder(depMapOutStream);
+ xmlEncoder.writeObject(transDepenedencyMap);
+ xmlEncoder.close();
+
+ if(addEntry(newWar, REPOSITORY_PATH + metadataFile)) {
+ depMapInStream = new FileInputStream(file);
+ IOUtils.copy(depMapInStream, newWar);
+ }
+
+ } finally {
+ IOUtils.closeQuietly(depMapOutStream);
+ IOUtils.closeQuietly(depMapInStream);
+ }
+
+ }
+
+ /**
+ * Builds the transitive dependencies for artifacts.
+ *
+ * @param newWar WARto which the artifacts are added.
+ * @param art Extension artifact.
+ * @throws IOException In case of an unexpected IO error.
+ * @throws ArtifactResolutionException If the artifact cannot be resolved.
+ * @throws ArtifactNotFoundException If the artifact is not found.
+ * @throws ArtifactMetadataRetrievalException In case of error in retrieving metadata.
+ */
+ private void loadExtensionDependencies(JarOutputStream newWar, Artifact art) throws IOException, ArtifactResolutionException, ArtifactNotFoundException, ArtifactMetadataRetrievalException {
+
+ String artPath = art.getGroupId() + "/" + art.getArtifactId() + "/" + art.getVersion() + "/";
+ String path = REPOSITORY_PATH + artPath;
+ addArtifact(newWar, path, art);
+
+ Set<String> transDepenedenyList = new HashSet<String>();
+ transDepenedencyMap.put(artPath, transDepenedenyList);
+
+ // Get the transitive dependencies for each dependency.
+ for (Artifact transArt : resolveArtifact(art, true)) {
+
+ String transArtPath = transArt.getGroupId() + "/" + transArt.getArtifactId() + "/" + transArt.getVersion() + "/" + transArt.getFile().getName();
+ transDepenedenyList.add(transArtPath);
+
+ }
+
+ }
+
+ /**
+ * Resolves the specified artifact.
+ *
+ * @param artifact Artifact to be resolved.
+ * @param transitive Whether to resolve transitively.
+ * @return A set of resolved artifacts.
+ * @throws IOException In case of an unexpected IO error.
+ * @throws ArtifactResolutionException If the artifact cannot be resolved.
+ * @throws ArtifactNotFoundException If the artifact is not found.
+ * @throws ArtifactMetadataRetrievalException In case of error in retrieving metadata.
+ */
+ private Set<Artifact> resolveArtifact(Artifact artifact, boolean transitive) throws IOException, ArtifactResolutionException,
+ ArtifactNotFoundException, ArtifactMetadataRetrievalException {
+
+ Set<Artifact> resolvedArtifacts = new HashSet<Artifact>();
+
+ // Resolve the artifact
+ resolver.resolve(artifact, remoteRepositories, localRepository);
+ resolvedArtifacts.add((Artifact) artifact);
+
+ if (!transitive) {
+ return resolvedArtifacts;
+ }
+
+ // Transitively resolve all the dependencies
+ ResolutionGroup resolutionGroup = metadataSource.retrieve(artifact, localRepository, remoteRepositories);
+ ArtifactResolutionResult result = resolver.resolveTransitively(resolutionGroup.getArtifacts(), artifact, remoteRepositories, localRepository,
+ metadataSource);
+
+ // Add the artifacts to the deployment unit
+ for (Object depArtifact : result.getArtifacts()) {
+ resolvedArtifacts.add((Artifact) depArtifact);
+ }
+ return resolvedArtifacts;
+
+ }
+
+ /**
+ * Adds the artifact to the war file.
+ *
+ * @param newWar War file to which the artifact is added.
+ * @param path Path within the war file where artifact is added.
+ * @param artifact Artifact to be added.
+ * @throws IOException In case of an unexpected IO error.
+ */
+ private void addArtifact(JarOutputStream newWar, String path, Artifact artifact) throws IOException {
+
+ FileInputStream artifactStream = null;
+ FileOutputStream fileOutputStream = null;
+
+ try {
+
+ File artifactFile = artifact.getFile();
+ // For extensions, we'll add it even the packagedLibs has it
+ if ((!EXTENSION_PATH.equals(path)) && packagedLibs.contains(artifactFile.getName())) {
+ return;
+ }
+ artifactStream = new FileInputStream(artifactFile);
+
+ newWar.putNextEntry(new JarEntry(path + artifactFile.getName()));
+
+ File file = new File(outputDirectory, "webapp");
+ file = new File(file, path);
+ file.mkdirs();
+
+ file = new File(file, artifactFile.getName());
+ fileOutputStream = new FileOutputStream(file);
+
+ IOUtils.copy(artifactStream, fileOutputStream);
+ IOUtils.closeQuietly(artifactStream);
+
+ artifactStream = new FileInputStream(artifactFile);
+ IOUtils.copy(artifactStream, newWar);
+
+ packagedLibs.add(artifactFile.getName());
+
+ getLog().info("Processed " + path + artifactFile.getName());
+
+ } finally {
+ IOUtils.closeQuietly(artifactStream);
+ IOUtils.closeQuietly(fileOutputStream);
+ }
+
+ }
+
+ /**
+ * Copies the original war file.
+ *
+ * @param originalWar Original war file.
+ * @param newWar New war file.
+ * @throws IOException In case of an unexpected IO error.
+ */
+ private void copyOriginal(JarFile originalWar, JarOutputStream newWar) throws IOException {
+
+ Enumeration entries = originalWar.entries();
+ packagedLibs.clear();
+
+ while (entries.hasMoreElements()) {
+
+ JarEntry entry = (JarEntry) entries.nextElement();
+ InputStream jarEntryStream = null;
+
+ try {
+ jarEntryStream = originalWar.getInputStream(entry);
+ newWar.putNextEntry(entry);
+ IOUtils.copy(jarEntryStream, newWar);
+ String name = entry.getName();
+
+ if (name.endsWith(".jar")) {
+ packagedLibs.add(name.substring(name.lastIndexOf("/") + 1));
+ }
+ } finally {
+ IOUtils.closeQuietly(jarEntryStream);
+ }
+
+ }
+
+ originalWar.close();
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/pom.xml
new file mode 100644
index 0000000000..ce46795405
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-plugin-wsdl2java</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Tuscany SCA - Maven Plugin for WSDL2Java</name>
+ <description>Implementation of WSDL2Java Generator</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sca-tools</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java
new file mode 100644
index 0000000000..2d08c31326
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.plugin;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator;
+
+/**
+ * @version $Rev$ $Date$
+ * @goal generate
+ * @phase generate-sources
+ * @description Generate SDO interface classes from an XML Schema
+ */
+public class WSDL2JavaGeneratorMojo extends AbstractMojo {
+ /**
+ * The directory containing wsdl files; defaults to ${basedir}/src/main/wsdl
+ * @parameter expression="${basedir}/src/main/wsdl"
+ */
+ private String wsdlDir;
+
+ /**
+ * Name of the wsdl file; if omitted all files in the directory are processed
+ * @parameter
+ */
+ private File wsdlFile;
+
+ /**
+ * The Java package to generate into. By default the value is derived from the schema URI.
+ *
+ * @parameter
+ */
+ private String javaPackage;
+
+ /**
+ * The directory to generate into; defaults to ${project.build.directory}/wsdl2java-source
+ *
+ * @parameter expression="${project.build.directory}/wsdl2java-source"
+ */
+ private String targetDirectory;
+
+ /**
+ * The directory to generate into; defaults to ${project.build.directory}/wsdl2java-source
+ *
+ * @parameter
+ */
+ private WSDLFileOption[] wsdlFiles;
+
+ /**
+ * @parameter expression="${project.compileSourceRoots}"
+ * @readonly
+ */
+ private List compilerSourceRoots;
+
+ public void execute() throws MojoExecutionException {
+
+ if(null != wsdlFiles){
+ for(int i=0; i< wsdlFiles.length ; ++i ){
+ System.err.println("wsdlFiles" + wsdlFiles[i].getFileName());
+ WSDLFileOption wf = wsdlFiles[i];
+
+ if(null == wf.getTargetDirectory())
+ wf.setTargetDirectory(targetDirectory);
+ if(null == wf.getJavaPackage()){
+ wf.setJavaPackage(javaPackage);
+ }
+ if(wf.getFileName() == null || wf.getFileName().length() ==0){
+ throw new MojoExecutionException("no fileName specfied for wsdl.");
+ }
+ if(!wf.getFileName().canRead() || !wf.getFileName().isFile()){
+
+ throw new MojoExecutionException("file can not be read:"+wf.getFileName());
+ }
+
+ }
+ }else{
+
+
+
+ if (wsdlFile == null) {
+
+ File[] files = new File(wsdlDir).listFiles(FILTER);
+
+ wsdlFiles= new WSDLFileOption[files.length];
+ for(int i= files.length -1; i> -1; --i){
+
+
+ wsdlFiles[i] = new WSDLFileOption();
+ wsdlFiles[i].setFileName(files[i]);
+ wsdlFiles[i].setJavaPackage(javaPackage);
+ wsdlFiles[i].setPorts(null);
+ wsdlFiles[i].setTargetDirectory(targetDirectory);
+
+
+ }
+
+ } else {
+ wsdlFiles= new WSDLFileOption[]{new WSDLFileOption()};
+ wsdlFiles[0].setFileName(wsdlFile);
+ wsdlFiles[0].setJavaPackage(javaPackage);
+ wsdlFiles[0].setPorts(null);
+ wsdlFiles[0].setTargetDirectory(targetDirectory);
+ }
+ }
+
+ int genOptions = 0;
+
+ for (int i = 0; i < wsdlFiles.length; i++) {
+ File file = wsdlFiles[i].getFileName();
+ File marker = new File(targetDirectory, ".gen#" + file.getName()+".wsdl2java");
+ if (file.lastModified() > marker.lastModified()) {
+ getLog().info("Generating Java service interfaces from " + file);
+ WSDL2JavaGenerator.generateFromWSDL(file.toString(), wsdlFiles[i].getPorts(), wsdlFiles[i].getTargetDirectory(), wsdlFiles[i].getJavaPackage(), null, genOptions);
+ }
+ try {
+ marker.createNewFile();
+ } catch (IOException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ marker.setLastModified(System.currentTimeMillis());
+ }
+
+ compilerSourceRoots.add(targetDirectory);
+ }
+
+ private static final FileFilter FILTER = new FileFilter() {
+ public boolean accept(File pathname) {
+ return (pathname.isFile() || !pathname.isHidden());
+ }
+ };
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDLFileOption.java b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDLFileOption.java
new file mode 100644
index 0000000000..3e6ebf0acc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDLFileOption.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.plugin;
+
+import java.io.File;
+
+public class WSDLFileOption {
+ /**
+ * Name of the wsdl file; if omitted all files in the directory are processed
+ *
+ */
+ private File fileName;
+
+ /**
+ * The Java package to generate into. By default the value is derived from the schema URI.
+ *
+ *
+ */
+ private String javaPackage;
+
+ /**
+ * The directory to generate into; defaults to ${project.build.directory}/wsdl2java-source
+ *
+ *
+ */
+ private String targetDirectory;
+
+ /**
+ * @parameter expression="${project.compileSourceRoots}"
+ * @readonly
+ */
+
+ private String ports[];
+
+ /**
+ * @parameter expression="${project.compileSourceRoots}"
+ * @readonly
+ */
+
+
+ public WSDLFileOption(){}
+
+ public String getJavaPackage() {
+ return javaPackage;
+ }
+
+ public void setJavaPackage(String javaPackage) {
+ this.javaPackage = javaPackage;
+ }
+
+
+ public String[] getPorts() {
+ return ports;
+ }
+
+ public void setPorts(String[] ports) {
+ this.ports = ports;
+ }
+
+ public String getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public void setTargetDirectory(String targetDirectory) {
+ this.targetDirectory = targetDirectory;
+ }
+
+ public File getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(File fileName) {
+ this.fileName = fileName;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..25d78feeac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,1277 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+APACHE TUSCANY SUBCOMPONENTS:
+
+The Apache Tuscany distribution includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+For the Eclipse Modeling Framework component and the Celtix binding:
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and
+are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program by such
+Contributor itself or anyone acting on such Contributor's behalf.
+Contributions do not include additions to the Program which: (i) are
+separate modules of software distributed in conjunction with the
+Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and
+object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor, if
+any, in source code and object code form. This patent license shall
+apply to the combination of the Contribution and the Program if, at
+the time the Contribution is added by the Contributor, such addition
+of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the
+licenses to its Contributions set forth herein, no assurances are
+provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow
+Recipient to distribute the Program, it is Recipient's responsibility
+to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental and
+consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are
+offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable
+manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the
+Program.
+
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a
+commercial product offering should do so in a manner which does not
+create potential liability for other Contributors. Therefore, if a
+Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend
+and indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the acts
+or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement.
+In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b)
+allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such
+claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable
+laws, damage to or loss of data, programs or equipment, and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+the Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of
+the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign
+the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions)
+may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives
+no rights or licenses to the intellectual property of any Contributor
+under this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+For the Rhino JavaScript container component:
+
+Mozilla Public License 1.1 (MPL 1.1)
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original Code,
+prior Modifications used by a Contributor, and the Modifications made by that
+particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+combination of the Original Code and Modifications, in each case including
+portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+accepted in the software development community for the electronic transfer of
+data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified as
+the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+extent possible, whether at the time of the initial grant or subsequently
+acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+substance or structure of either the Original Code or any previous
+Modifications. When Covered Code is released as a series of files, a
+Modification is:
+ A. Any addition to or deletion from the contents of a file
+containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+which is described in the Source Code notice required by Exhibit A as Original
+Code, and which, at the time of its release under this License is not already
+Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+hereafter acquired, including without limitation, method, process, and
+apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+making modifications to it, including all modules it contains, plus any
+associated interface definition files, scripts used to control compilation and
+installation of an Executable, or source code differential comparisons against
+either the Original Code or another well known, available Covered Code of the
+Contributor's choice. The Source Code can be in a compressed or archival form,
+provided the appropriate decompression or de-archiving software is widely
+available for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+exercising rights under, and complying with all of the terms of, this License
+or a future version of this License issued under Section 6.1. For legal
+entities, "You" includes any entity which controls, is controlled by, or is
+under common control with You. For purposes of this definition, "control"
+means (a) the power, direct or indirect, to cause the direction or management
+of such entity, whether by contract or otherwise, or (b) ownership of more
+than fifty percent (50%) of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+non-exclusive license, subject to third party intellectual property claims:
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Initial Developer to use, reproduce, modify, display,
+perform, sublicense and distribute the Original Code (or portions thereof)
+with or without Modifications, and/or as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or selling
+of Original Code, to make, have made, use, practice, sell, and offer for sale,
+and/or otherwise dispose of the Original Code (or portions thereof).
+ (c) the licenses granted in this Section 2.1(a) and
+(b) are effective on the date Initial Developer first distributes Original
+Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+granted: 1) for code that You delete from the Original Code; 2) separate from
+the Original Code; or 3) for infringements caused by: i) the modification of
+the Original Code or ii) the combination of the Original Code with other
+software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Contributor, to use, reproduce, modify, display,
+perform, sublicense and distribute the Modifications created by such
+Contributor (or portions thereof) either on an unmodified basis, with other
+Modifications, as Covered Code and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or selling
+of Modifications made by that Contributor either alone and/or in combination
+with its Contributor Version (or portions of such combination), to make, use,
+sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications
+made by that Contributor (or portions thereof); and 2) the combination of
+Modifications made by that Contributor with its Contributor Version (or
+portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+effective on the date Contributor first makes Commercial Use of the Covered
+Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+granted: 1) for any code that Contributor has deleted from the Contributor
+Version; 2) separate from the Contributor Version; 3) for infringements
+caused by: i) third party modifications of Contributor Version or ii) the
+combination of Modifications made by that Contributor with other software
+(except as part of the Contributor Version) or other devices; or 4) under
+Patent Claims infringed by Covered Code in the absence of Modifications made
+by that Contributor.
+
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+governed by the terms of this License, including without limitation Section
+2.2. The Source Code version of Covered Code may be distributed only under the
+terms of this License or a future version of this License released under
+Section 6.1, and You must include a copy of this License with every copy of
+the Source Code You distribute. You may not offer or impose any terms on any
+Source Code version that alters or restricts the applicable version of this
+License or the recipients' rights hereunder. However, You may include an
+additional document offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+made available in Source Code form under the terms of this License either on
+the same media as an Executable version or via an accepted Electronic
+Distribution Mechanism to anyone to whom you made an Executable version
+available; and if made available via Electronic Distribution Mechanism, must
+remain available for at least twelve (12) months after the date it initially
+became available, or at least six (6) months after a subsequent version of
+that particular Modification has been made available to such recipients. You
+are responsible for ensuring that the Source Code version remains available
+even if the Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+file documenting the changes You made to create that Covered Code and the date
+of any change. You must include a prominent statement that the Modification is
+derived, directly or indirectly, from Original Code provided by the Initial
+Developer and including the name of the Initial Developer in (a) the Source
+Code, and (b) in any notice in an Executable version or related documentation
+in which You describe the origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+intellectual property rights is required to exercise the rights granted by
+such Contributor under Sections 2.1 or 2.2, Contributor must include a text
+file with the Source Code distribution titled "LEGAL" which describes the
+claim and the party making the claim in sufficient detail that a recipient
+will know whom to contact. If Contributor obtains such knowledge after the
+Modification is made available as described in Section 3.2, Contributor shall
+promptly modify the LEGAL file in all copies Contributor makes available
+thereafter and shall take other steps (such as notifying appropriate mailing
+lists or newsgroups) reasonably calculated to inform those who received the
+Covered Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+interface and Contributor has knowledge of patent licenses which are
+reasonably necessary to implement that API, Contributor must also include this
+information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+Section 3.4(a) above, Contributor believes that Contributor's Modifications
+are Contributor's original creation(s) and/or Contributor has sufficient
+rights to grant the rights conveyed by this License.
+
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+Code. If it is not possible to put such notice in a particular Source Code
+file due to its structure, then You must include such notice in a location
+(such as a relevant directory) where a user would be likely to look for such a
+notice. If You created one or more Modification(s) You may add your name as a
+Contributor to the notice described in Exhibit A. You must also duplicate
+this License in any documentation for the Source Code where You describe
+recipients' rights or ownership rights relating to Covered Code. You may
+choose to offer, and to charge a fee for, warranty, support, indemnity or
+liability obligations to one or more recipients of Covered Code. However, You
+may do so only on Your own behalf, and not on behalf of the Initial Developer
+or any Contributor. You must make it absolutely clear than any such warranty,
+support, indemnity or liability obligation is offered by You alone, and You
+hereby agree to indemnify the Initial Developer and every Contributor for any
+liability incurred by the Initial Developer or such Contributor as a result of
+warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+requirements of Section 3.1-3.5 have been met for that Covered Code, and if
+You include a notice stating that the Source Code version of the Covered Code
+is available under the terms of this License, including a description of how
+and where You have fulfilled the obligations of Section 3.2. The notice must
+be conspicuously included in any notice in an Executable version, related
+documentation or collateral in which You describe recipients' rights relating
+to the Covered Code. You may distribute the Executable version of Covered Code
+or ownership rights under a license of Your choice, which may contain terms
+different from this License, provided that You are in compliance with the
+terms of this License and that the license for the Executable version does not
+attempt to limit or alter the recipient's rights in the Source Code version
+from the rights set forth in this License. If You distribute the Executable
+version under a different license You must make it absolutely clear that any
+terms which differ from this License are offered by You alone, not by the
+Initial Developer or any Contributor. You hereby agree to indemnify the
+Initial Developer and every Contributor for any liability incurred by the
+Initial Developer or such Contributor as a result of any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+not governed by the terms of this License and distribute the Larger Work as a
+single product. In such a case, You must make sure the requirements of this
+License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Code due to statute,
+judicial order, or regulation then You must: (a) comply with the terms of this
+License to the maximum extent possible; and (b) describe the limitations and
+the code they affect. Such description must be included in the LEGAL file
+described in Section 3.4 and must be included with all distributions of the
+Source Code. Except to the extent prohibited by statute or regulation, such
+description must be sufficiently detailed for a recipient of ordinary skill to
+be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has attached
+the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+and/or new versions of the License from time to time. Each version will be
+given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+License, You may always continue to use it under the terms of that version.
+You may also choose to use such Covered Code under the terms of any subsequent
+version of the License published by Netscape. No one other than Netscape has
+the right to modify the terms applicable to Covered Code created under this
+License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+only do in order to apply it to code which is not already Covered Code
+governed by this License), You must (a) rename Your license so that the
+phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or
+any confusingly similar phrase do not appear in your license (except to note
+that your license differs from this License) and (b) otherwise make it clear
+that Your version of the license contains terms which differ from the Mozilla
+Public License and Netscape Public License. (Filling in the name of the
+Initial Developer, Original Code or Contributor in the notice described in
+Exhibit A shall not of themselves be deemed to be modifications of this
+License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE,
+FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE
+QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED
+CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR
+CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
+LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+automatically if You fail to comply with terms herein and fail to cure such
+breach within 30 days of becoming aware of the breach. All sublicenses to the
+Covered Code which are properly granted shall survive any termination of this
+License. Provisions which, by their nature, must remain in effect beyond the
+termination of this License shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+claim (excluding declatory judgment actions) against Initial Developer or a
+Contributor (the Initial Developer or Contributor against whom You file such
+action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+infringes any patent, then any and all rights granted by such Participant to
+You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice
+from Participant terminate prospectively, unless if within 60 days after
+receipt of notice You either: (i) agree in writing to pay Participant a
+mutually agreeable reasonable royalty for Your past and future use of
+Modifications made by such Participant, or (ii) withdraw Your litigation claim
+with respect to the Contributor Version against such Participant. If within
+60 days of notice, a reasonable royalty and payment arrangement are not
+mutually agreed upon in writing by the parties or the litigation claim is not
+withdrawn, the rights granted by Participant to You under Sections 2.1 and/or
+2.2 automatically terminate at the expiration of the 60 day notice period
+specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+Contributor Version, directly or indirectly infringes any patent, then any
+rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are
+revoked effective as of the date You first made, used, sold, distributed, or
+had made, Modifications made by that Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+alleging that such Participant's Contributor Version directly or indirectly
+infringes any patent where such claim is resolved (such as by license or
+settlement) prior to the initiation of patent infringement litigation, then
+the reasonable value of the licenses granted by such Participant under
+Sections 2.1 or 2.2 shall be taken into account in determining the amount or
+value of any payment or license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above, all
+end user license agreements (excluding distributors and resellers) which have
+been validly granted by You or any distributor hereunder prior to termination
+shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY
+SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING,
+WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
+FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH
+DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH
+OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
+EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in 48
+C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and
+"commercial computer software documentation," as such terms are used in 48
+C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R.
+227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users
+acquire Covered Code with only those rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it
+enforceable. This License shall be governed by California law provisions
+(except to the extent applicable law, if any, provides otherwise), excluding
+its conflict-of-law provisions. With respect to disputes in which at least one
+party is a citizen of, or an entity chartered or registered to do business in
+the United States of America, any litigation relating to this License shall be
+subject to the jurisdiction of the Federal Courts of the Northern District of
+California, with venue lying in Santa Clara County, California, with the
+losing party responsible for costs, including without limitation, court costs
+and reasonable attorneys' fees and expenses. The application of the United
+Nations Convention on Contracts for the International Sale of Goods is
+expressly excluded. Any law or regulation which provides that the language of
+a contract shall be construed against the drafter shall not apply to this
+License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+responsible for claims and damages arising, directly or indirectly, out of its
+utilization of rights under this License and You agree to work with Initial
+Developer and Contributors to distribute such responsibility on an equitable
+basis. Nothing herein is intended or shall be deemed to constitute any
+admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits
+you to utilize portions of the Covered Code under Your choice of the MPL or
+the alternative licenses, if any, specified by the Initial Developer in the
+file described in Exhibit A.
+
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+language governing rights and
+ limitations under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+Portions created by
+ ______________________ are Copyright (C) ______
+_______________________. All Rights
+ Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms of
+the _____ license (the [___] License), in which case the provisions of
+[______] License are applicable instead of those above. If you wish to allow
+use of your version of this file only under the terms of the [____] License
+and not to allow others to use your version of this file under the MPL,
+indicate your decision by deleting the provisions above and replace them
+with the notice and other provisions required by the [___] License. If you do
+not delete the provisions above, a recipient may use your version of this file
+under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+the notices in the Source Code files of the Original Code. You should use the
+text of this Exhibit A rather than the text found in the Original Code Source
+Code for Your Modifications.]
+
+
+===============================================================================
+
+For the JAX-WS Reference Implementation component:
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+
+ 1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that
+ creates or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the
+ Original Software, prior Modifications used by a
+ Contributor (if any), and the Modifications made by that
+ particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or
+ (b) Modifications, or (c) the combination of files
+ containing Original Software with files containing
+ Modifications, in each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form
+ other than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity
+ that first makes Original Software available under this
+ License.
+
+ 1.6. "Larger Work" means a work which combines Covered
+ Software or portions thereof with code not governed by the
+ terms of this License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the
+ maximum extent possible, whether at the time of the initial
+ grant or subsequently acquired, any and all of the rights
+ conveyed herein.
+
+ 1.9. "Modifications" means the Source Code and Executable
+ form of any of the following:
+
+ A. Any file that results from an addition to,
+ deletion from or modification of the contents of a
+ file containing Original Software or previous
+ Modifications;
+
+ B. Any new file that contains any part of the
+ Original Software or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and
+ Executable form of computer software code that is
+ originally released under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned
+ or hereafter acquired, including without limitation,
+ method, process, and apparatus claims, in any patent
+ Licensable by grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer
+ software code in which modifications are made and (b)
+ associated documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal
+ entity exercising rights under, and complying with all of
+ the terms of, this License. For legal entities, "You"
+ includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or
+ indirect, to cause the direction or management of such
+ entity, whether by contract or otherwise, or (b) ownership
+ of more than fifty percent (50%) of the outstanding shares
+ or beneficial ownership of such entity.
+
+ 2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the
+ Initial Developer hereby grants You a world-wide,
+ royalty-free, non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Initial Developer,
+ to use, reproduce, modify, display, perform,
+ sublicense and distribute the Original Software (or
+ portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making,
+ using or selling of Original Software, to make, have
+ made, use, practice, sell, and offer for sale, and/or
+ otherwise dispose of the Original Software (or
+ portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b)
+ are effective on the date Initial Developer first
+ distributes or otherwise makes the Original Software
+ available to a third party under the terms of this
+ License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent
+ license is granted: (1) for code that You delete from
+ the Original Software, or (2) for infringements
+ caused by: (i) the modification of the Original
+ Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Contributor to
+ use, reproduce, modify, display, perform, sublicense
+ and distribute the Modifications created by such
+ Contributor (or portions thereof), either on an
+ unmodified basis, with other Modifications, as
+ Covered Software and/or as part of a Larger Work; and
+
+
+ (b) under Patent Claims infringed by the making,
+ using, or selling of Modifications made by that
+ Contributor either alone and/or in combination with
+ its Contributor Version (or portions of such
+ combination), to make, use, sell, offer for sale,
+ have made, and/or otherwise dispose of: (1)
+ Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications
+ made by that Contributor with its Contributor Version
+ (or portions of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and
+ 2.2(b) are effective on the date Contributor first
+ distributes or otherwise makes the Modifications
+ available to a third party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent
+ license is granted: (1) for any code that Contributor
+ has deleted from the Contributor Version; (2) for
+ infringements caused by: (i) third party
+ modifications of Contributor Version, or (ii) the
+ combination of Modifications made by that Contributor
+ with other software (except as part of the
+ Contributor Version) or other devices; or (3) under
+ Patent Claims infringed by Covered Software in the
+ absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be
+ distributed only under the terms of this License. You must
+ include a copy of this License with every copy of the
+ Source Code form of the Covered Software You distribute or
+ otherwise make available. You must inform recipients of any
+ such Covered Software in Executable form as to how they can
+ obtain such Covered Software in Source Code form in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You
+ contribute are governed by the terms of this License. You
+ represent that You believe Your Modifications are Your
+ original creation(s) and/or You have sufficient rights to
+ grant the rights conveyed by this License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications
+ that identifies You as the Contributor of the Modification.
+ You may not remove or alter any copyright, patent or
+ trademark notices contained within the Covered Software, or
+ any notices of licensing or any descriptive text giving
+ attribution to any Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered
+ Software in Source Code form that alters or restricts the
+ applicable version of this License or the recipients'
+ rights hereunder. You may choose to offer, and to charge a
+ fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Software.
+ However, you may do so only on Your own behalf, and not on
+ behalf of the Initial Developer or any Contributor. You
+ must make it absolutely clear that any such warranty,
+ support, indemnity or liability obligation is offered by
+ You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered
+ Software under the terms of this License or under the terms
+ of a license of Your choice, which may contain terms
+ different from this License, provided that You are in
+ compliance with the terms of this License and that the
+ license for the Executable form does not attempt to limit
+ or alter the recipient's rights in the Source Code form
+ from the rights set forth in this License. If You
+ distribute the Covered Software in Executable form under a
+ different license, You must make it absolutely clear that
+ any terms which differ from this License are offered by You
+ alone, not by the Initial Developer or Contributor. You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial
+ Developer or such Contributor as a result of any such terms
+ You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software
+ with other code not governed by the terms of this License
+ and distribute the Larger Work as a single product. In such
+ a case, You must make sure the requirements of this License
+ are fulfilled for the Covered Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and
+ may publish revised and/or new versions of this License
+ from time to time. Each version will be given a
+ distinguishing version number. Except as provided in
+ Section 4.3, no one other than the license steward has the
+ right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. If the Initial Developer includes a
+ notice in the Original Software prohibiting it from being
+ distributed or otherwise made available under any
+ subsequent version of the License, You must distribute and
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software
+ available under the terms of any subsequent version of the
+ License published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a
+ new license for Your Original Software, You may create and
+ use a modified version of this License if You: (a) rename
+ the license and remove any references to the name of the
+ license steward (except to note that the license differs
+ from this License); and (b) otherwise make it clear that
+ the license contains terms which differ from this License.
+
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will
+ terminate automatically if You fail to comply with terms
+ herein and fail to cure such breach within 30 days of
+ becoming aware of the breach. Provisions which, by their
+ nature, must remain in effect beyond the termination of
+ this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or
+ a Contributor (the Initial Developer or Contributor against
+ whom You assert such claim is referred to as "Participant")
+ alleging that the Participant Software (meaning the
+ Contributor Version where the Participant is a Contributor
+ or the Original Software where the Participant is the
+ Initial Developer) directly or indirectly infringes any
+ patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant)
+ and all Contributors under Sections 2.1 and/or 2.2 of this
+ License shall, upon 60 days notice from Participant
+ terminate prospectively and automatically at the expiration
+ of such 60 day notice period, unless if within such 60 day
+ period You withdraw Your claim with respect to the
+ Participant Software against such Participant either
+ unilaterally or pursuant to a written agreement with
+ Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2
+ above, all end user licenses that have been validly granted
+ by You or any distributor hereunder prior to termination
+ (excluding licenses granted to You by any distributor)
+ shall survive termination.
+
+ 7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48 C.F.R.
+ 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
+ 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+ through 227.7202-4 (June 1995), all U.S. Government End Users
+ acquire Covered Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the
+ extent necessary to make it enforceable. This License shall be
+ governed by the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, with the losing
+ party responsible for costs, including, without limitation, court
+ costs and reasonable attorneys' fees and expenses. The
+ application of the United Nations Convention on Contracts for the
+ International Sale of Goods is expressly excluded. Any law or
+ regulation which provides that the language of a contract shall
+ be construed against the drafter shall not apply to this License.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/README.txt b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/README.txt
new file mode 100644
index 0000000000..9b26d1690a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/plugin.wsdl2java/src/main/resources/META-INF/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/plugins/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/plugins/pom.xml
new file mode 100644
index 0000000000..3bee18fe27
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/plugins/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.plugins</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Maven Plugins</name>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>plugin.war</module>
+ <module>plugin.wsdl2java</module>
+ <module>plugin.java2wsdl</module>
+ </modules>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/pom.xml
new file mode 100644
index 0000000000..60638876ed
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/pom.xml
@@ -0,0 +1,364 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>parent</artifactId>
+ <version>1-incubator</version>
+ </parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Implementation Project</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <properties>
+ <sca.version>1.0-incubator-M2-SNAPSHOT</sca.version>
+ <scaKernelVersion>1.0-incubator-M2-SNAPSHOT</scaKernelVersion>
+ <axis2Version>1.1</axis2Version>
+ </properties>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <!-- needed for SDO plugin -->
+ <pluginRepository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <modules>
+ <module>kernel</module>
+ <module>test</module>
+ <module>services</module>
+ <module>runtime</module>
+ <module>commands</module>
+ <module>tools</module>
+ <module>plugins</module>
+ <module>distribution</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Tuscany Kernel Modules -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${scaKernelVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- org.osoa.sca API -->
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- javax.servlet API -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- javax.resource API -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- javax.transaction API -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- commonj.work and commonj.timer APIs -->
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>commonj-api_r1.1</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- java.xml.stream API -->
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- StAX implementation -->
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Axis2 Implementation -->
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>${axis2Version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- AXIOM Implementation -->
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Woden implementation -->
+ <dependency>
+ <groupId>incubator-woden</groupId>
+ <artifactId>woden</artifactId>
+ <version>1.0.0M6</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- wsdl4j implementation -->
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+
+ <!-- XmlSchema implementation -->
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>buildtools</artifactId>
+ <version>1.0-incubator-M2</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>process-sources</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <configLocation>tuscany-checkstyle.xml</configLocation>
+ <suppressionsLocation>tuscany-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnError>true</failsOnError>
+ <linkXRef>false</linkXRef>
+ <sourceDirectory>${basedir}/src</sourceDirectory>
+ <propertyExpansion>${checkstyle.properties}</propertyExpansion>
+ </configuration>
+ <goals>
+ <goal>checkstyle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <rulesets>
+ <ruleset>${basedir}/.ruleset</ruleset>
+ </rulesets>
+ <linkXRef>false</linkXRef>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ <executions>
+ <execution>
+ <id>process-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <argLine>-ea</argLine>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-osgi-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <osgiManifest>
+ <bundleName>${pom.name}</bundleName>
+ <bundleDescription>${pom.description}</bundleDescription>
+ <bundleVendor>${pom.organization.name}</bundleVendor>
+ <bundleLocalization>plugin</bundleLocalization>
+ </osgiManifest>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clover-plugin</artifactId>
+ <configuration>
+ <jdk>1.5</jdk>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>package</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <aggregate>false</aggregate>
+ <links>
+ <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
+ </links>
+ <offlineLinks>
+ <offlineLink>
+ <url>../api</url>
+ <location>../api/target/apidocs</location>
+ </offlineLink>
+ <offlineLink>
+ <url>../host-api</url>
+ <location>../host-api/target/apidocs</location>
+ </offlineLink>
+ <offlineLink>
+ <url>../spi</url>
+ <location>../spi/target/apidocs</location>
+ </offlineLink>
+ </offlineLinks>
+ <!--
+ <outputDirectory>${tuscany.home}/distribution/build/javadoc/${project.artifactId}</outputDirectory>
+ -->
+ <quiet>true</quiet>
+ <bottom>-</bottom>
+ <header>${project.name}</header>
+ <footer>${project.name}</footer>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/pom.xml
new file mode 100644
index 0000000000..ae8a4ad2c1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>equinox</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Equinox Runtime</name>
+ <description>Tuscany Equinox Runtime Host</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/src/test/java/org/apache/tuscany/equinox/EquinoxStartTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/src/test/java/org/apache/tuscany/equinox/EquinoxStartTestCase.java
new file mode 100644
index 0000000000..93866cbf41
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/equinox/src/test/java/org/apache/tuscany/equinox/EquinoxStartTestCase.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.equinox;
+
+import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
+import org.eclipse.osgi.framework.internal.core.OSGi;
+import org.eclipse.osgi.framework.internal.defaultadaptor.DefaultAdaptor;
+import org.osgi.framework.Bundle;
+import junit.framework.TestCase;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class EquinoxStartTestCase extends TestCase {
+
+ public void testStart() throws Exception {
+ FrameworkAdaptor adaptor = new DefaultAdaptor(new String[]{});
+ OSGi osgi = new OSGi(adaptor);
+ osgi.launch();
+// FileInputStream stream = new FileInputStream("/Users/jmarino/workspace/tuscany/tuscany/tuscany/sandbox/jboynes/sca/runtime/equinox/src/test/resources/http.jar");
+// osgi.getBundleContext().installBundle("foo", stream);
+ for (Bundle bundle : osgi.getBundleContext().getBundles()) {
+
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.pmd b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.pmd
new file mode 100644
index 0000000000..0e3d0ef921
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/></pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/LICENSE.txt
new file mode 100755
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/README.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/README.txt
new file mode 100755
index 0000000000..9b26d1690a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/pom.xml
new file mode 100644
index 0000000000..01a9070e0d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-osgi</artifactId>
+ <packaging>osgi-bundle</packaging>
+ <name>Apache Tuscany OSGi Runtime</name>
+ <description>Integration code to embed the Tuscany runtime in an OSGi container and a binding implementation for
+ consuming OSGi services and publishing SCA services to OSGi.</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.1.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-osgi-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <ignorePackage>com.sun.msv.grammar, com.sun.msv.grammar.trex, com.sun.msv.reader,
+ com.sun.msv.reader.trex.ng, com.sun.msv.reader.util, com.sun.msv.util, com.sun.msv.verifier,
+ com.sun.msv.verifier.regexp, javax.resource.spi.work
+ </ignorePackage>
+ <osgiManifest>
+ <bundleName>${pom.name}</bundleName>
+ <bundleDescription>${pom.description}</bundleDescription>
+ <bundleVendor>${pom.organization.name}</bundleVendor>
+ <bundleLocalization>plugin</bundleLocalization>
+ <bundleSymbolicName>org.apache.tuscany</bundleSymbolicName>
+ <bundleActivator>org.apache.tuscany.osgi.LauncherActivator</bundleActivator>
+ <!--<exportPackage>org.apache.tuscany.*</exportPackage>-->
+ </osgiManifest>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/LauncherActivator.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/LauncherActivator.java
new file mode 100755
index 0000000000..2d7027e208
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/LauncherActivator.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+
+import org.apache.tuscany.api.TuscanyException;
+import org.apache.tuscany.core.launcher.LauncherImpl;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.apache.tuscany.osgi.util.BundleContextUtil;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Responsible for launching the Tuscany Runtime in as part of an OSGi bundle
+ */
+public class LauncherActivator implements BundleActivator {
+
+ private LauncherImpl launcher;
+
+ public void start(BundleContext context) throws Exception {
+ BundleContextUtil.setContext(context);
+ startRuntime(context);
+
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ if (launcher != null) {
+ launcher.shutdownRuntime();
+ }
+ }
+
+
+ private void startRuntime(BundleContext context) throws OSGILauncherInitException {
+ launcher = new LauncherImpl();
+ // Current thread context classloader should be the webapp classloader
+ ClassLoader webappClassLoader = Thread.currentThread().getContextClassLoader();
+ launcher.setApplicationLoader(webappClassLoader);
+
+ try {
+ System.out.println(":::" + new File(".").toURL().toString());
+ // URL systemScdl = getSystemSCDL(systemScdlPath);
+ CompositeComponent rt =
+ launcher.bootRuntime(new File("./sca/system.scdl").toURI().toURL(), new NullMonitorFactory());
+ } catch (Exception e) {
+ throw new OSGILauncherInitException(e);
+ }
+ }
+
+ private void bootApplication(String name, URL scdl) throws TuscanyException {
+ CompositeComponent root = launcher.bootApplication(name, scdl);
+ root.start();
+ }
+
+ private void loadExtension(String name, URL scdl) throws TuscanyException {
+ CompositeComponent root = launcher.bootApplication(name, scdl);
+ root.start();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGILauncherInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGILauncherInitException.java
new file mode 100644
index 0000000000..b01f18314d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGILauncherInitException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OSGILauncherInitException extends TuscanyException {
+ public OSGILauncherInitException() {
+ }
+
+ public OSGILauncherInitException(String string) {
+ super(string);
+ }
+
+ public OSGILauncherInitException(String string, Throwable throwable) {
+ super(string, throwable);
+ }
+
+ public OSGILauncherInitException(Throwable throwable) {
+ super(throwable);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGiHost.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGiHost.java
new file mode 100644
index 0000000000..c16d27a937
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/OSGiHost.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi;
+
+import java.util.Properties;
+
+import org.apache.tuscany.spi.host.ServletHost;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface OSGiHost extends ServletHost {
+
+ void registerService(String serviceName, Object service, Properties properties);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteMethodException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteMethodException.java
new file mode 100755
index 0000000000..657640d854
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteMethodException.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+public class NoRemoteMethodException extends OSGiBindingException {
+
+ private static final long serialVersionUID = 5037327699117168707L;
+
+ public NoRemoteMethodException(String message) {
+ super(message);
+ }
+
+ public NoRemoteMethodException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoRemoteMethodException(Throwable cause) {
+ super("", cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteServiceException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteServiceException.java
new file mode 100755
index 0000000000..0df2a282c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/NoRemoteServiceException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import org.osgi.framework.BundleException;
+
+/**
+ * FIXME class not used
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoRemoteServiceException extends BundleException {
+
+ public NoRemoteServiceException(String message) {
+ super(message);
+ }
+
+ public NoRemoteServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoRemoteServiceException(Throwable cause) {
+ super("", cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBinding.java
new file mode 100755
index 0000000000..11d96ebe9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBinding.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a binding to an OSGi service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiBinding extends Binding {
+ private String uri;
+ private String service;
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setService(String service) {
+ this.service = service;
+ }
+
+ public String getService() {
+ return service;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingBuilder.java
new file mode 100755
index 0000000000..99977e9166
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingBuilder.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+import org.apache.tuscany.osgi.OSGiHost;
+
+/**
+ * Builds a Service or Reference for an OSGi binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiBindingBuilder extends BindingBuilderExtension<OSGiBinding> {
+
+ OSGiHost host;
+
+ @Constructor
+ public OSGiBindingBuilder(@Autowire OSGiHost host) {
+ this.host = host;
+ }
+
+ protected Class<OSGiBinding> getBindingType() {
+ return OSGiBinding.class;
+ }
+
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<OSGiBinding> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+ String name = boundServiceDefinition.getName();
+ Class<? extends Object> service = getServiceInterface(boundServiceDefinition);
+ String osgiServiceName = boundServiceDefinition.getBinding().getService();
+ return new OSGiService(name, parent, wireService, osgiServiceName, service, host);
+ }
+
+ public OSGiReference build(CompositeComponent parent,
+ BoundReferenceDefinition<OSGiBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ String name = boundReferenceDefinition.getName();
+ String uri = boundReferenceDefinition.getBinding().getURI();
+ Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
+ return new OSGiReference(name, interfaze, parent, wireService, uri);
+ }
+
+ protected Class<? extends Object> getServiceInterface(BoundServiceDefinition<OSGiBinding> boundServiceDefinition) {
+ return boundServiceDefinition.getServiceContract().getInterfaceClass();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingException.java
new file mode 100755
index 0000000000..a8b913bad0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class OSGiBindingException extends TuscanyRuntimeException {
+ protected OSGiBindingException() {
+ }
+
+ protected OSGiBindingException(String message) {
+ super(message);
+ }
+
+ protected OSGiBindingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected OSGiBindingException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingLoader.java
new file mode 100755
index 0000000000..7f335a4dbe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiBindingLoader.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+
+/**
+ * Loader for handling <code>binding.osgi</code> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class OSGiBindingLoader extends LoaderExtension<OSGiBinding> {
+ public static final QName BINDING_OSGI = new QName("http://tuscany.apache.org/xmlns/osgi/1.0", "binding.osgi");
+
+ @Constructor
+ public OSGiBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_OSGI;
+ }
+
+ public OSGiBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ String uri = reader.getAttributeValue(null, "uri");
+ String service = reader.getAttributeValue(null, "service");
+ LoaderUtil.skipToEndElement(reader);
+
+ OSGiBinding binding = new OSGiBinding();
+ binding.setURI(uri);
+ binding.setService(service);
+ return binding;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiInvoker.java
new file mode 100755
index 0000000000..b6fb480101
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiInvoker.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Invokes the target service of an OSGi reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OSGiInvoker implements TargetInvoker {
+ private final Method remoteMethod;
+ private final Object proxy;
+
+ OSGiInvoker(Object proxy, Method remoteMethod) {
+ assert remoteMethod.isAccessible();
+ this.remoteMethod = remoteMethod;
+ this.proxy = proxy;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBody(e.getCause());
+ }
+ return msg;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ return remoteMethod.invoke(proxy, (Object[]) payload);
+ } catch (IllegalAccessException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ }
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ // FIXME I think we can always have this cacheable as OSGi services are thread-safe
+ public void setCacheable(boolean cacheable) {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiReference.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiReference.java
new file mode 100755
index 0000000000..e365c4c6a2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiReference.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.idl.java.JavaIDLUtils;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OSGiReference extends ReferenceExtension {
+ //private final String uri;
+
+ public OSGiReference(String name, Class<?> interfaze, CompositeComponent parent, WireService service, String uri) {
+ super(name, interfaze, parent, service);
+ //this.uri = uri;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ try {
+ Object proxy = getProxy();
+ String name = operation.getName();
+ Method method = JavaIDLUtils.findMethod(operation, contract.getInterfaceClass().getMethods());
+ Class<?>[] parameterTypes = method.getParameterTypes();
+ Method remoteMethod = proxy.getClass().getMethod(name, parameterTypes);
+ return new OSGiInvoker(proxy, remoteMethod);
+ } catch (NoSuchMethodException e) {
+ // FIXME we should probably have this as a checked exception, which will entail adding to the SPI signature
+ throw new NoRemoteMethodException(operation.toString(), e);
+ }
+ }
+
+ protected Remote getProxy() {
+ //FIXME use service reference
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiService.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiService.java
new file mode 100755
index 0000000000..afca35a71b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/binding/OSGiService.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.binding;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.osgi.OSGiHost;
+import org.osgi.framework.ServiceFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OSGiService extends ServiceExtension {
+ private final String osgiServiceName;
+ //private final Class<? extends Object> service;
+ private OSGiHost host;
+
+ /**
+ * Creates a new service instance
+ *
+ * @param name the name of the SCA service
+ * @param parent the containing composite
+ * @param wireService the wire service to use for creating proxies
+ * @param osgiServiceName the name to publish the service as to the OSGi hose
+ * @param service the service type
+ * @param host the OSGi host
+ */
+ public OSGiService(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ String osgiServiceName,
+ Class<?> service,
+ OSGiHost host) {
+ super(name, service, parent, wireService);
+ this.osgiServiceName = osgiServiceName;
+ //this.service = service;
+ this.host = host;
+ }
+
+ public void start() {
+ super.start();
+ Properties properties = new Properties();
+ Object instance = getServiceInstance();
+ if (instance instanceof ServiceFactory) {
+ host.registerService(osgiServiceName, instance, properties);
+ } else {
+ ServiceFactoryProxyHandler factoryProxy = new ServiceFactoryProxyHandler(instance);
+ Class<?> interfaces[] = instance.getClass().getInterfaces();
+ Class<?> proxyInterfaces[] = new Class<?>[interfaces.length + 1];
+ int i;
+ for (i = 0; i < interfaces.length; i++) {
+ proxyInterfaces[i] = interfaces[i];
+ }
+ proxyInterfaces[i] = ServiceFactory.class;
+ ClassLoader classLoader = instance.getClass().getClassLoader();
+ // TODO It seems we need a mixin capability for the service. We could add that to WireService
+ Object targetProxy = Proxy.newProxyInstance(classLoader, proxyInterfaces, factoryProxy);
+ host.registerService(osgiServiceName, targetProxy, properties);
+ }
+ //Register the service with OSGi
+ }
+
+ public void stop() {
+ super.stop();
+ //Unregister the service with OSGi
+ }
+
+ private class ServiceFactoryProxyHandler implements InvocationHandler {
+
+ private Object instance;
+
+ public ServiceFactoryProxyHandler(Object instance) {
+ this.instance = instance;
+ }
+
+ public Object invoke(Object object, Method method, Object[] parms) throws Throwable {
+ if (method.getName().equals("getService")) {
+ return instance;
+ } else if (method.getName().equals("ungetService")) {
+ return null;
+ }
+ return method.invoke(instance, parms);
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/BundleContextUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/BundleContextUtil.java
new file mode 100755
index 0000000000..02549a59fd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/BundleContextUtil.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.util;
+
+import java.util.Dictionary;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public final class BundleContextUtil {
+
+ private static BundleContext context;
+ private static final ServiceReference EMPTY_REFERENCE_ARRAY[] = {};
+
+ private BundleContextUtil() {
+ }
+
+ public static void setContext(BundleContext ctx) {
+ context = ctx;
+ }
+
+ public static ServiceReference[] getServiceReference(String clazz, String filter) throws InvalidSyntaxException {
+ ServiceReference[] references;
+ references = context.getServiceReferences(clazz, filter);
+ if (references == null) {
+ references = EMPTY_REFERENCE_ARRAY;
+ }
+ return references;
+ }
+
+ public static Object getService(ServiceReference reference) {
+ return context.getService(reference);
+ }
+
+ public static Object getService(ServiceReference references[]) {
+ if (references == null) {
+ return null;
+ }
+ return context.getService(references[0]);
+ }
+
+ public static void addServiceListener(ServiceListener listener, String filter) {
+ try {
+ if (filter != null) {
+ context.addServiceListener(listener, filter);
+ } else {
+ context.addServiceListener(listener);
+ }
+ } catch (InvalidSyntaxException e) {
+ //FIXME
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public static void removeServiceListener(ServiceListener listener) {
+ context.removeServiceListener(listener);
+ }
+
+ public static ServiceRegistration registerService(String serviceName,
+ Object serviceFactory,
+ Dictionary properties) {
+ return context.registerService(serviceName, serviceFactory, properties);
+ }
+
+ public static boolean trackServiceReference(String filter, ServiceListener listener) {
+ try {
+ context.addServiceListener(listener, filter);
+ return true;
+ } catch (InvalidSyntaxException e) {
+ return false;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/ClassloaderHook.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/ClassloaderHook.java
new file mode 100644
index 0000000000..9e08c04ded
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/java/org/apache/tuscany/osgi/util/ClassloaderHook.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.osgi.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.osgi.framework.Bundle;
+
+public class ClassloaderHook {
+
+ /**
+ * Return the BundleContext Classloader for the specified bundle.
+ *
+ * @param bundle The bundle whose BundleContext is desired.
+ * @return The BundleContext classloader for the specified bundle.
+ */
+ ClassLoader getClassLoader(final Bundle bundle) {
+ if (System.getSecurityManager() == null) {
+ Object bundleLoader = invokeMethod(bundle, "checkLoader", null, null);
+ return (ClassLoader) invokeMethod(bundleLoader, "createClassLoader", null, null);
+ }
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ Object bundleLoader = invokeMethod(bundle, "checkLoader", null, null);
+ return (ClassLoader) invokeMethod(bundleLoader, "createClassLoader", null, null);
+ }
+ });
+ }
+
+ /**
+ * Throws an IllegalStateException if the reflection logic cannot find what it is looking for. This probably means
+ * this class does not properly recognize the framework implementation.
+ *
+ * @param e Exception which indicates the reflection logic is confused.
+ */
+ protected void reflectionException(Exception e) {
+ throw new IllegalStateException(
+ "ClassLoaderHook does not recognize the framework implementation: " + e.getMessage());
+ }
+
+ private Object invokeMethod(Object target, String methodName, Class[] parms, Object[] args) {
+ Method method;
+ try {
+ method = target.getClass().getMethod(methodName, parms);
+ if (method != null) {
+ return method.invoke(target, parms, args);
+ }
+ } catch (SecurityException e) {
+ reflectionException(e);
+ } catch (NoSuchMethodException e) {
+ reflectionException(e);
+ } catch (IllegalArgumentException e) {
+ reflectionException(e);
+ } catch (IllegalAccessException e) {
+ reflectionException(e);
+ } catch (InvocationTargetException e) {
+ reflectionException(e);
+ }
+ return null;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/MANIFEST.MF b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/MANIFEST.MF
new file mode 100755
index 0000000000..bb72ca36e5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tuscany_binding_osgi Plug-in
+Bundle-SymbolicName: tuscany_binding_osgi
+Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.tuscany.binding.osgi.LauncherActivator
+Bundle-Localization: plugin
+Import-Package: org.osgi.framework;version="1.3.0",
+ org.osgi.util.tracker;version="1.3.1",
+ org.osoa.sca,
+ org.osoa.sca.annotations
+Require-Bundle: tuscany.osgi.sca.spi,
+ tuscany_external_dependencies,
+ tuscany.osgi.sca.core
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/sca/osgibinding.scdl b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/sca/osgibinding.scdl
new file mode 100755
index 0000000000..14dfbbbbca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/osgi/src/main/resources/META-INF/sca/osgibinding.scdl
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="binding.osgi">
+
+ <component name="osgi.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.osgOSGiBindingBuilderi.binding.OSGiBindingLoader"/>
+ </component>
+ <component name="osgi.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.osgi.binding.OSGiBindingBuilder"/>
+ </component>
+ <component name="osgi.componentLoader">
+ <system:implementation.system class="org.apache.tuscany.implementation.osgi.OSGiImplementationLoader"/>
+ </component>
+ <component name="osgi.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.implementation.osgi.OSGiComponentTypeLoader"/>
+ </component>
+ <component name="osgi.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.implementation.osgi.OSGiComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/pom.xml
new file mode 100644
index 0000000000..f2f097536e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Runtime Hosts</name>
+
+ <modules>
+ <module>webapp</module>
+ <module>webapp-host</module>
+ <module>standalone</module>
+ <module>standalone-host</module>
+ </modules>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/pom.xml
new file mode 100644
index 0000000000..bc782d8b3f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>standalone-host</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Standalone Runtime Host</name>
+ <description>Host code to support a standalone runtime</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>standalone</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java
new file mode 100644
index 0000000000..7091c90fa3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/DirectoryScanExtender.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.standalone.host;
+
+import java.io.File;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.core.services.extension.AbstractExtensionDeployer;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.services.VoidService;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+
+/**
+ * Service that extends the runtime by loading composites located in a directory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DirectoryScanExtender extends AbstractExtensionDeployer implements VoidService {
+ private final StandaloneRuntimeInfo runtimeInfo;
+ private final String path;
+
+ public DirectoryScanExtender(@Autowire StandaloneRuntimeInfo runtimeInfo,
+ @Property(name = "path") String path) {
+ this.runtimeInfo = runtimeInfo;
+ this.path = path;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ assert runtimeInfo != null;
+ File extensionDir = new File(runtimeInfo.getInstallDirectory(), path);
+ if (!extensionDir.isDirectory()) {
+ // we don't have an extension directory, there's nothing to do
+ return;
+ }
+
+ File[] files = extensionDir.listFiles();
+ for (File file : files) {
+ deployExtension(file);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
new file mode 100644
index 0000000000..0f9fefd5e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.standalone.host;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.launcher.CompositeContextImpl;
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StandaloneRuntimeImpl extends AbstractRuntime {
+ private CompositeContextImpl context;
+ private RuntimeComponent runtime;
+ private CompositeComponent systemComponent;
+ private CompositeComponent tuscanySystem;
+ private CompositeComponent application;
+
+ public void initialize() {
+ ClassLoader bootClassLoader = getClass().getClassLoader();
+
+ // Read optional system monitor factory classname
+ MonitorFactory mf = getMonitorFactory();
+
+ XMLInputFactory xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", bootClassLoader);
+
+ Bootstrapper bootstrapper = new DefaultBootstrapper(mf, xmlFactory);
+ runtime = bootstrapper.createRuntime();
+ runtime.start();
+ systemComponent = runtime.getSystemComponent();
+
+ // register the runtime info provided by the host
+ RuntimeInfo runtimeInfo = getRuntimeInfo();
+ systemComponent.registerJavaObject(RuntimeInfo.COMPONENT_NAME, RuntimeInfo.class, runtimeInfo);
+ systemComponent.registerJavaObject(StandaloneRuntimeInfo.COMPONENT_NAME,
+ StandaloneRuntimeInfo.class,
+ (StandaloneRuntimeInfo) runtimeInfo);
+
+ // register the monitor factory provided by the host
+ systemComponent.registerJavaObject("MonitorFactory", MonitorFactory.class, mf);
+
+ systemComponent.start();
+
+ try {
+ // deploy the system scdl
+ Deployer deployer = bootstrapper.createDeployer();
+ tuscanySystem = deploySystemScdl(deployer,
+ systemComponent,
+ ComponentNames.TUSCANY_SYSTEM,
+ getSystemScdl(),
+ bootClassLoader);
+ tuscanySystem.start();
+
+ // switch to the system deployer
+ deployer = (Deployer) tuscanySystem.getSystemChild("deployer").getServiceInstance();
+
+ application = deployApplicationScdl(deployer,
+ runtime.getRootComponent(),
+ getApplicationName(),
+ getApplicationScdl(),
+ getApplicationClassLoader());
+ application.start();
+
+ context = new CompositeContextImpl(application);
+ } catch (LoaderException e) {
+ // FIXME do something with this
+ e.printStackTrace();
+ }
+ }
+
+ public void destroy() {
+ context = null;
+ if (application != null) {
+ application.stop();
+ application = null;
+ }
+ if (tuscanySystem != null) {
+ tuscanySystem.stop();
+ tuscanySystem = null;
+ }
+ if (systemComponent != null) {
+ systemComponent.stop();
+ systemComponent = null;
+ }
+ if (runtime != null) {
+ runtime.stop();
+ runtime = null;
+ }
+ }
+
+ public SCA getContext() {
+ return context;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/pom.xml
new file mode 100644
index 0000000000..c8be645d5e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>standalone</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Standalone Runtime</name>
+ <description>Code to run Tuscany in a standalone application.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-host-api</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java
new file mode 100644
index 0000000000..6224121d39
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfo.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.standalone;
+
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface StandaloneRuntimeInfo extends RuntimeInfo {
+ static String COMPONENT_NAME = "StandaloneRuntimeInfo";
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java
new file mode 100644
index 0000000000..01b0ba0c46
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/standalone/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntimeInfoImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.standalone;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StandaloneRuntimeInfoImpl implements StandaloneRuntimeInfo {
+ private final File installDirectory;
+ private final File applicationRootDirectory;
+ private final URL baseURL;
+ private final boolean online;
+
+ public StandaloneRuntimeInfoImpl(URL baseURL,
+ File installDirectory,
+ File applicationRootDirectory,
+ boolean online) {
+ this.baseURL = baseURL;
+ this.installDirectory = installDirectory;
+ this.applicationRootDirectory = applicationRootDirectory;
+ this.online = online;
+ }
+
+ public File getInstallDirectory() {
+ return installDirectory;
+ }
+
+ public File getApplicationRootDirectory() {
+ return applicationRootDirectory;
+ }
+
+ public URL getBaseURL() {
+ return baseURL;
+ }
+
+ public boolean isOnline() {
+ return online;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/pom.xml
new file mode 100644
index 0000000000..83be251c32
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>webapp-host</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Web Application Host</name>
+ <description>Host code to run Tuscany in a Web application.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>maven</artifactId>
+ <version>${sca.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/InvalidCompositePath.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/InvalidCompositePath.java
new file mode 100644
index 0000000000..100bfa3560
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/InvalidCompositePath.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Denotes an invalid path representing a composite in application hierarchy
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidCompositePath extends TuscanyException {
+ public InvalidCompositePath() {
+ }
+
+ public InvalidCompositePath(String message) {
+ super(message);
+ }
+
+ public InvalidCompositePath(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidCompositePath(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
new file mode 100644
index 0000000000..8d556b4c2a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import static org.apache.tuscany.core.component.scope.HttpSessionScopeContainer.HTTP_IDENTIFIER;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.tuscany.core.component.event.HttpRequestEnded;
+import org.apache.tuscany.core.component.event.HttpRequestStart;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.EventPublisher;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.Scope;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * A <code>ServletHost</code> implementation that forwards requests to registered servlets
+ */
+@Service(ServletHost.class)
+public class ServletHostImpl implements ServletHost, ServletRequestInjector, EventPublisher {
+
+ protected Map<String, Servlet> servlets;
+
+ public ServletHostImpl() {
+ this.servlets = new HashMap<String, Servlet>();
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ protected ScopeRegistry registry = null;
+
+ @Autowire(required = false)
+ public void setSessionScopeContainer(ScopeRegistry registry) {
+ this.registry = registry;
+ }
+
+ WorkContext workContext = null;
+
+ @Autowire(required = false)
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
+ assert req instanceof HttpServletRequest : "implementation only supports HttpServletRequest";
+ String path = ((HttpServletRequest) req).getPathInfo();
+ Servlet servlet = servlets.get(path);
+ if (servlet == null) {
+ throw new IllegalStateException("No servlet registered for path: " + path);
+ }
+ servlet.service(req, resp);
+ }
+
+ public void registerMapping(String path, Servlet servlet) {
+ if (servlets.containsKey(path)) {
+ throw new IllegalStateException("Servlet already registered at path: " + path);
+ }
+ servlets.put(path, servlet);
+ }
+
+ public void unregisterMapping(String path) {
+ servlets.remove(path);
+ }
+
+ public void addListener(RuntimeEventListener listener) {
+ throw new UnSupportedRuntimeException("Not Supported");
+
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ throw new UnSupportedRuntimeException("Not Supported");
+
+ }
+
+ public void publish(Event event) {
+ if (null != registry && (event instanceof HttpSessionStart || event instanceof HttpSessionEnd)) {
+ ScopeContainer sc = registry.getScopeContainer(Scope.SESSION);
+ if (null != sc) {
+ sc.onEvent(event);
+
+ }
+ }
+ if (null != workContext) {
+ if (event instanceof HttpRequestStart) {
+ Object key = ((HttpRequestStart) event).getId();
+ if (null != key) {
+ workContext.setIdentifier(HTTP_IDENTIFIER, ((HttpRequestStart) event).getId());
+ } else { // new request with no session.
+ workContext.clearIdentifier(HTTP_IDENTIFIER);
+ }
+ } else if (event instanceof HttpRequestEnded) {
+ workContext.clearIdentifier(HTTP_IDENTIFIER);
+
+ }
+
+ }
+
+ }
+
+ public void removeListener(RuntimeEventListener listener) {
+ throw new UnSupportedRuntimeException("Not Supported");
+
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherInitException.java
new file mode 100644
index 0000000000..6e0726c801
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherInitException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Thrown when an error is encountered booting the runtme in a web app environment
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServletLauncherInitException extends TuscanyRuntimeException {
+
+ public ServletLauncherInitException() {
+ }
+
+ public ServletLauncherInitException(String message) {
+ super(message);
+ }
+
+ public ServletLauncherInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ServletLauncherInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/UnSupportedRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/UnSupportedRuntimeException.java
new file mode 100644
index 0000000000..9cfa7345d6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/UnSupportedRuntimeException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Thrown when an error is encountered booting the runtme in a web app environment
+ *
+ * @version $Rev: 439728 $ $Date: 2006-09-03 02:02:44 -0400 (Sun, 03 Sep 2006) $
+ */
+public class UnSupportedRuntimeException extends TuscanyRuntimeException {
+
+ public UnSupportedRuntimeException() {
+ }
+
+ public UnSupportedRuntimeException(String message) {
+ super(message);
+ }
+
+ public UnSupportedRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnSupportedRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java
new file mode 100644
index 0000000000..23d7b29e55
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+
+import org.apache.tuscany.core.services.extension.AbstractExtensionDeployer;
+import org.apache.tuscany.runtime.webapp.WebappRuntimeInfo;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WebResourceScanExtender extends AbstractExtensionDeployer {
+ private final WebappRuntimeInfo runtimeInfo;
+ private final String path;
+
+ public WebResourceScanExtender(@Autowire WebappRuntimeInfo runtimeInfo,
+ @Property(name = "path") String path) {
+ this.runtimeInfo = runtimeInfo;
+ this.path = path;
+ }
+
+ @Init
+ public void init() {
+ ServletContext servletContext = runtimeInfo.getServletContext();
+ Set extensions = servletContext.getResourcePaths(path);
+ if (extensions == null || extensions.isEmpty()) {
+ // no extensions in this webapp
+ return;
+ }
+
+ for (Object e : extensions) {
+ String extensionPath = (String) e;
+ URL extension;
+ try {
+ extension = servletContext.getResource(extensionPath);
+ } catch (MalformedURLException e1) {
+ // web container should return an invalid URL for a path it gave us
+ throw new AssertionError();
+ }
+
+ String name = extensionPath.substring(path.length());
+ if (name.charAt(name.length() - 1) == '/') {
+ // TODO support exploded extensions
+ continue;
+ }
+ if (name.charAt(0) == '.') {
+ // hidden file
+ continue;
+ }
+
+ int lastDot = name.lastIndexOf('.');
+ if (lastDot != -1) {
+ name = name.substring(0, lastDot);
+ }
+ deployExtension(name, extension);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
new file mode 100644
index 0000000000..c921b35050
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSessionEvent;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.core.bootstrap.Bootstrapper;
+import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.component.event.HttpRequestEnded;
+import org.apache.tuscany.core.component.event.HttpRequestStart;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.launcher.CompositeContextImpl;
+import org.apache.tuscany.core.monitor.MonitorFactoryUtil;
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.host.MonitorFactory;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.bootstrap.RuntimeComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.event.EventPublisher;
+import org.osoa.sca.SCA;
+
+/**
+ * Bootstrapper for the Tuscany runtime in a web application host. This listener manages one runtime per servlet
+ * context; the lifecycle of that runtime corresponds to the the lifecycle of the associated servlet context.
+ * <p/>
+ * The bootstrapper launches the runtime, booting system extensions and applications, according to the servlet
+ * parameters defined in {@link Constants}. When the runtime is instantiated, it is placed in the servlet context with
+ * the attribute {@link Constants.RUNTIME_ATTRIBUTE}. The runtime implements {@link WebappRuntime} so that filters and
+ * servlets loaded in the parent web app classloader may pass events and requests to it.
+ * <p/>
+ * By default, the top-most application composite component will be returned when "non-managed" web application code
+ * such as JSPs call {@link org.osoa.sca.CurrentCompositeContext}. If a composite deeper in the hierarchy should be
+ * returned instead, the <code>web.xml</code> must contain an entry for {@link Constants.CURRENT_COMPOSITE_PATH_PARAM}
+ * whose value is a component path expression using '/' as a delimeter such as foo/bar/baz.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public class WebappRuntimeImpl extends AbstractRuntime implements WebappRuntime {
+ private ServletContext servletContext;
+
+
+ private ServletRequestInjector requestInjector;
+ private CompositeContextImpl context;
+ private RuntimeComponent runtime;
+ private CompositeComponent systemComponent;
+ private CompositeComponent tuscanySystem;
+ private CompositeComponent application;
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public void setServletContext(ServletContext servletContext) {
+ this.servletContext = servletContext;
+ }
+
+ public void initialize() {
+ ClassLoader bootClassLoader = getClass().getClassLoader();
+
+ // Read optional system monitor factory classname
+ MonitorFactory mf = getMonitorFactory();
+
+
+ XMLInputFactory xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", bootClassLoader);
+
+ Bootstrapper bootstrapper = new DefaultBootstrapper(mf, xmlFactory);
+ runtime = bootstrapper.createRuntime();
+ runtime.start();
+ systemComponent = runtime.getSystemComponent();
+
+ // register the runtime info provided by the host
+ // FIXME andyp@bea.com -- autowire appears to need an exact type match,
+ // hence the need to register this twice
+ systemComponent.registerJavaObject(RuntimeInfo.COMPONENT_NAME,
+ RuntimeInfo.class,
+ (WebappRuntimeInfo) getRuntimeInfo());
+ systemComponent.registerJavaObject(WebappRuntimeInfo.COMPONENT_NAME,
+ WebappRuntimeInfo.class,
+ (WebappRuntimeInfo) getRuntimeInfo());
+
+ // register the monitor factory provided by the host
+ systemComponent.registerJavaObject("MonitorFactory", MonitorFactory.class, mf);
+
+ systemComponent.start();
+
+ if (getSystemScdl() == null) {
+ throw new TuscanyInitException("Could not find system SCDL");
+ }
+
+ try {
+ // deploy the system scdl
+ Deployer deployer = bootstrapper.createDeployer();
+ tuscanySystem = deploySystemScdl(deployer,
+ systemComponent,
+ ComponentNames.TUSCANY_SYSTEM,
+ getSystemScdl(),
+ bootClassLoader);
+ tuscanySystem.start();
+
+ requestInjector = (ServletRequestInjector) tuscanySystem.getSystemChild("servletHost").getServiceInstance();
+
+ // switch to the system deployer
+ deployer = (Deployer) tuscanySystem.getSystemChild("deployer").getServiceInstance();
+
+ if (getApplicationScdl() == null) {
+ throw new TuscanyInitException("Could not find application SCDL");
+ }
+
+ application = deployApplicationScdl(deployer,
+ runtime.getRootComponent(),
+ getApplicationName(),
+ getApplicationScdl(),
+ getHostClassLoader());
+ application.start();
+
+ context = new CompositeContextImpl(application);
+ } catch (Exception e) {
+ throw new ServletLauncherInitException(e);
+ }
+ }
+
+ public void destroy() {
+ context = null;
+ if (application != null) {
+ application.stop();
+ application = null;
+ }
+ if (tuscanySystem != null) {
+ tuscanySystem.stop();
+ tuscanySystem = null;
+ }
+ if (systemComponent != null) {
+ systemComponent.stop();
+ systemComponent = null;
+ }
+ if (runtime != null) {
+ runtime.stop();
+ runtime = null;
+ }
+ }
+
+ public SCA getContext() {
+ return context;
+ }
+
+ public ServletRequestInjector getRequestInjector() {
+ return requestInjector;
+ }
+
+ public void sessionCreated(HttpSessionEvent event) {
+ HttpSessionStart startSession = new HttpSessionStart(this, event.getSession().getId());
+ application.publish(startSession);
+ ((EventPublisher)requestInjector).publish(startSession);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event) {
+ HttpSessionEnd endSession = new HttpSessionEnd(this, event.getSession().getId());
+ application.publish(endSession);
+ ((EventPublisher)requestInjector).publish(endSession);
+ }
+
+ public void httpRequestStarted(Object sessionid) {
+ HttpRequestStart httpRequestStart = new HttpRequestStart(this, sessionid);
+ application.publish(httpRequestStart);
+ ((EventPublisher)requestInjector).publish(httpRequestStart);
+ }
+
+ public void httpRequestEnded(Object sessionid) {
+ HttpRequestEnded httpRequestEnded = new HttpRequestEnded(this, sessionid);
+ application.publish(httpRequestEnded);
+ ((EventPublisher)requestInjector).publish(httpRequestEnded);
+ }
+
+
+ public void startRequest() {
+ application.publish(new RequestStart(this));
+ }
+
+ public void stopRequest() {
+ application.publish(new RequestEnd(this));
+ }
+
+ /**
+ * Returns a monitor factory for the funtime
+ *
+ * @param loggingLevel
+ */
+ private MonitorFactory getMonitorFactory(String loggingLevel) {
+ String factoryName = "org.apache.tuscany.core.monitor.NullMonitorFactory";
+ Map<String, Object> props = null;
+ if (loggingLevel != null) {
+ factoryName = "org.apache.tuscany.core.monitor.JavaLoggingMonitorFactory";
+ props = new HashMap<String, Object>();
+ Level level = Level.SEVERE;
+ try {
+ level = Level.parse(loggingLevel);
+ } catch (IllegalArgumentException e) {
+ // ignore bad loggingLevel
+ }
+ props.put("bundleName", "SystemMessages");
+ props.put("defaultLevel", level);
+ }
+
+ return MonitorFactoryUtil.createMonitorFactory(factoryName, props);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/binding.axis2.scdl b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/binding.axis2.scdl
new file mode 100644
index 0000000000..7e6b39f800
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/binding.axis2.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Axis2 based WebService binding extension -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ xmlns:tuscany="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.axis2">
+
+ <!-- [rfeng] Commented it out for now. When this SCDL is loaded, the DependencyLoader component
+ has not been initiated yet. We may need to play with initLevel setting -->
+ <!--
+ <tuscany:dependency>
+ <group>axis2</group>
+ <artifact>axis2-core</artifact>
+ <version>SNAPSHOT</version>
+ </tuscany:dependency>
+ -->
+
+ <component name="webservice.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader"/>
+ </component>
+
+ <component name="webservice.axis2.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/databinding.sdo.scdl b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/databinding.sdo.scdl
new file mode 100644
index 0000000000..3296b40f66
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/sca/databinding.sdo.scdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ import.sdo configuration
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.sdo">
+
+ <!-- import.sdo element loader implementations -->
+ <component name="elementLoader.import.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl
new file mode 100644
index 0000000000..3cb2a03dea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.runtime.webapp.System">
+
+ <!-- Component that provides the Deployer service -->
+ <component name="deployer">
+ <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+ </component>
+
+ <!-- Work management -->
+ <component name="workContext">
+ <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+ </component>
+
+ <!-- Wire service -->
+ <component name="wireService">
+ <system:implementation.system class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+ </component>
+
+ <!-- Scope infrastructure -->
+ <component name="scopeRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+ </component>
+
+ <!-- Builder and BuilderRegistry -->
+ <component name="builder">
+ <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+ </component>
+
+ <!-- Loader and LoaderRegistry -->
+ <component name="loader">
+ <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+ </component>
+
+ <!-- Introspector and IntrospectionRegistry -->
+ <component name="introspector">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+ </component>
+
+ <!-- Connector infrastructure -->
+ <component name="connector">
+ <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+ </component>
+
+ <component name="wirePostProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+ </component>
+
+ <!-- Default scopes -->
+ <component name="scope.module">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
+ </component>
+ <component name="scope.stateless">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
+ </component>
+
+ <component name="scope.httpsession">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.HttpSessionScopeObjectFactory"/>
+ </component>
+
+ <!-- include loader configuration -->
+ <include name="org.apache.tuscany.launcher.Loader" scdlResource="org/apache/tuscany/core/loader.scdl"/>
+
+ <!-- include implementation processor configuration -->
+ <include name="org.apache.tuscany.launcher.Implementation" scdlResource="org/apache/tuscany/core/implementation.scdl"/>
+
+ <!-- Java interface definition language -->
+ <include name="org.apache.tuscany.launcher.InterfaceJava" scdlResource="org/apache/tuscany/core/interfaceJava.scdl"/>
+
+ <!-- include omposite implementation type -->
+ <include name="org.apache.tuscany.launcher.Composite" scdlResource="org/apache/tuscany/core/composite.scdl"/>
+
+ <!-- System implementation type -->
+ <include name="org.apache.tuscany.launcher.SystemImplementation" scdlResource="org/apache/tuscany/core/systemImplementation.scdl"/>
+
+ <!-- Java implementation type -->
+ <include name="org.apache.tuscany.launcher.JavaImplementation" scdlResource="org/apache/tuscany/core/javaImplementation.scdl"/>
+
+ <!-- Data Binding -->
+ <include name="org.apache.tuscany.launcher.DataBinding" scdlResource="org/apache/tuscany/core/databinding.scdl"/>
+
+ <!-- WorkScheduler service -->
+ <component name="workManager">
+ <system:implementation.system
+ class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+ <property name="poolSize">10</property>
+ </component>
+
+ <component name="workScheduler">
+ <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
+ </component>
+
+ <!-- Web app ServletHost -->
+ <component name="servletHost">
+ <system:implementation.system class="org.apache.tuscany.runtime.webapp.ServletHostImpl"/>
+ </component>
+
+ <component name="policyBuilderRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+ </component>
+
+ <component name="propertyFactory">
+ <system:implementation.system class="org.apache.tuscany.core.property.PropertyObjectFactoryImpl"/>
+ </component>
+
+ <component name="artifactRepository">
+ <system:implementation.system class="org.apache.tuscany.services.maven.MavenArtifactRepository"/>
+ <property name="remoteRepoUrl">http://repo1.maven.org/maven2,http://people.apache.org/repo/m2-incubating-repository,http://repo1.maven.org/maven,http://people.apache.org/repo/m2-snapshot-repository</property>
+ </component>
+
+ <component name="extender" initLevel="90">
+ <system:implementation.system class="org.apache.tuscany.runtime.webapp.WebResourceScanExtender"/>
+ <property name="path">/WEB-INF/tuscany/extensions/</property>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java
new file mode 100644
index 0000000000..75b49de188
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Foo {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java
new file mode 100644
index 0000000000..dd938f2a58
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FooImpl implements Foo {
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java
new file mode 100644
index 0000000000..543be9b7df
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.verify;
+
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServletHostTestCase extends TestCase {
+
+ public void testDispatch() throws Exception {
+ HttpServletRequest req = createMock(HttpServletRequest.class);
+ expect(req.getPathInfo()).andReturn("foo");
+ replay(req);
+ HttpServletResponse res = createMock(HttpServletResponse.class);
+ Servlet servlet = createMock(Servlet.class);
+ servlet.service(req, res);
+ EasyMock.expectLastCall();
+ replay(servlet);
+ ServletHostImpl host = new ServletHostImpl();
+ host.registerMapping("foo", servlet);
+ host.service(req, res);
+ verify(servlet);
+ }
+
+ public void testDuplicateRegistration() throws Exception {
+ Servlet servlet = createMock(Servlet.class);
+ ServletHostImpl host = new ServletHostImpl();
+ host.registerMapping("foo", servlet);
+ try {
+ host.registerMapping("foo", servlet);
+ fail();
+ } catch (IllegalStateException e) {
+ // expected
+ }
+ }
+
+ public void testUnregister() throws Exception {
+ HttpServletRequest req = createMock(HttpServletRequest.class);
+ expect(req.getPathInfo()).andReturn("foo");
+ replay(req);
+ HttpServletResponse res = createMock(HttpServletResponse.class);
+ Servlet servlet = createMock(Servlet.class);
+ replay(servlet);
+ ServletHostImpl host = new ServletHostImpl();
+ host.registerMapping("foo", servlet);
+ host.unregisterMapping("foo");
+ try {
+ host.service(req, res);
+ } catch (IllegalStateException e) {
+ // expected
+ }
+ verify(servlet);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java
new file mode 100644
index 0000000000..fe0269833e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImplTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.URL;
+import javax.servlet.ServletContext;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WebappRuntimeImplTestCase extends TestCase {
+ private URL applicationScdl;
+ private URL systemScdl;
+ private WebappRuntimeImpl runtime;
+ private ServletContext context;
+
+ /**
+ * Verifies the web app host is configured properly to perform a basic boot
+ */
+ public void testBootWithDefaults() throws Exception {
+ expect(context.getResourcePaths("/WEB-INF/tuscany/extensions/")).andReturn(null);
+ replay(context);
+ runtime.initialize();
+ verify(context);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ systemScdl = getClass().getResource("/META-INF/tuscany/webapp.scdl");
+ applicationScdl = getClass().getResource("/testapp.scdl");
+ context = createMock(ServletContext.class);
+
+ runtime = new WebappRuntimeImpl();
+ runtime.setRuntimeInfo(new WebappRuntimeInfoImpl(context, null, false));
+ runtime.setMonitorFactory(new NullMonitorFactory());
+ runtime.setHostClassLoader(getClass().getClassLoader());
+ runtime.setServletContext(context);
+ runtime.setSystemScdl(systemScdl);
+ runtime.setApplicationName("foo");
+ runtime.setApplicationScdl(applicationScdl);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/resources/testapp.scdl b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/resources/testapp.scdl
new file mode 100644
index 0000000000..9b5bda7fb6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp-host/src/test/resources/testapp.scdl
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="testapp">
+
+ <component name="component">
+ <implementation.java class="org.apache.tuscany.runtime.webapp.FooImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/pom.xml
new file mode 100644
index 0000000000..ebaa1a6a76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>webapp</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Web Application Runtime</name>
+ <description>Integration code to run Tuscany in a Web application.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-host-api</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
new file mode 100644
index 0000000000..b461da66a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+/**
+ * Constants used by the web application booter
+ *
+ * @version $Rev$ $Date$
+ */
+public final class Constants {
+
+ /**
+ * Name of the parameter that defines the name of webapp resource containing bootstrap jars.
+ */
+ static final String BOOTDIR_PARAM = "tuscany.bootDir";
+
+ /**
+ * Default value for BOOTDIR_PARAM.
+ */
+ static final String BOOTDIR_DEFAULT = "/WEB-INF/tuscany/boot";
+
+ /**
+ * Name of the parameter that defines the class to load to launch the runtime.
+ */
+ static final String RUNTIME_PARAM = "tuscany.runtimeImpl";
+
+ /**
+ * Name of the default webapp runtime implementation.
+ */
+ static final String RUNTIME_DEFAULT = "org.apache.tuscany.runtime.webapp.WebappRuntimeImpl";
+
+ /**
+ * Servlet context-param name for user-specified system SCDL path.
+ */
+ static final String SYSTEM_SCDL_PATH_PARAM = "tuscany.systemScdlPath";
+
+ /**
+ * Default webapp system SCDL path.
+ */
+ static final String SYSTEM_SCDL_PATH_DEFAULT = "META-INF/tuscany/webapp.scdl";
+
+ /**
+ * Servlet context-param name for user-specified application SCDL path.
+ */
+ static final String APPLICATION_SCDL_PATH_PARAM = "tuscany.applicationScdlPath";
+
+ /**
+ * Default application SCDL path.
+ */
+ static final String APPLICATION_SCDL_PATH_DEFAULT = "/WEB-INF/default.scdl";
+
+ /**
+ * Servlet context-param name for setting if the runtime is online.
+ */
+ static final String ONLINE_PARAM = "tuscany.online";
+
+
+
+
+ /**
+ * Context attribute to which the Tuscany runtime for this servlet context is stored.
+ */
+ static final String RUNTIME_ATTRIBUTE = "tuscany.runtime";
+
+ /**
+ * Servlet context-param name for the path to the composite to set as the webb app composite
+ */
+ static final String CURRENT_COMPOSITE_PATH_PARAM = "tuscany.currentCompositePath";
+
+ /**
+ * Servlet context-param name for user-specified system SCDL path.
+ */
+ static final String EXTENSION_SCDL_PATH_PARAM = "tuscany.extensionScdlPath";
+
+ /**
+ * Default path for extensions if no "extensionScdlPath param is specified
+ */
+ static final String DEFAULT_EXTENSION_PATH_PARAM = "/WEB-INF/tuscany/extensions";
+
+ /**
+ * Servlet context-param name for system monitoring level. Supported values are the names of statics defined in
+ * java.util.logging.Level. If absent, no monitoring will take place.
+ */
+ static final String SYSTEM_MONITORING_PARAM = "tuscany.monitoringLevel";
+
+ private Constants() {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherMonitor.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherMonitor.java
new file mode 100644
index 0000000000..5936240481
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherMonitor.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import org.apache.tuscany.api.annotation.LogLevel;
+
+/**
+ * A monitor interface used during runtime bootstrap
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServletLauncherMonitor {
+
+ @LogLevel("DEBUG")
+ void deployExtension(String path);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
new file mode 100644
index 0000000000..05682745d9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+import static org.apache.tuscany.runtime.webapp.Constants.ONLINE_PARAM;
+
+/**
+ * Launches a Tuscany runtime in a web application, loading information from servlet context parameters. This listener
+ * manages one runtime per servlet context; the lifecycle of that runtime corresponds to the the lifecycle of the
+ * associated servlet context.
+ * <p/>
+ * The runtime is launched in a child classloader of the web application, thereby providing isolation between
+ * application and system artifacts. Application code only has access to the SCA API and may not reference Tuscany
+ * system artifacts directly.
+ * <p/>
+ * The <code>web.xml</code> of a web application embedding Tuscany must have entries for this listener and {@link
+ * TuscanySessionListener}. The latter notifies the runtime of session creation and expiration events through a
+ * "bridging" contract, {@link WebappRuntime}. The <code>web.xml</code> may also optionally be configured with
+ * entries for {@link TuscanyFilter} and {@link TuscanyServlet}. The former must be mapped to all urls that execute
+ * "unmanaged" code which accesses the Tuscany runtime though the SCA API, for example, JSPs and Servlets. The latter
+ * forwards service requests into the runtime, by default requests sent to URLs relative to the context path beginning
+ * with <code>/services</code>.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyContextListener implements ServletContextListener {
+
+ public void contextInitialized(ServletContextEvent event) {
+ ServletContext servletContext = event.getServletContext();
+ WebappUtil utils = getUtils(servletContext);
+ try {
+ ClassLoader webappClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader bootClassLoader = utils.getBootClassLoader(webappClassLoader);
+ WebappRuntime runtime = utils.getRuntime(bootClassLoader);
+ boolean online = Boolean.valueOf(utils.getInitParameter(ONLINE_PARAM, "true"));
+ WebappRuntimeInfo info = new WebappRuntimeInfoImpl(servletContext,
+ servletContext.getResource("/WEB-INF/tuscany/"),
+ online);
+ URL systemScdl = utils.getSystemScdl(bootClassLoader);
+ URL applicationScdl = utils.getApplicationScdl(webappClassLoader);
+ String name = utils.getApplicationName();
+
+ runtime.setServletContext(servletContext);
+ runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
+ runtime.setRuntimeInfo(info);
+ runtime.setHostClassLoader(webappClassLoader);
+ runtime.setSystemScdl(systemScdl);
+ runtime.setApplicationName(name);
+ runtime.setApplicationScdl(applicationScdl);
+ runtime.initialize();
+
+ servletContext.setAttribute(RUNTIME_ATTRIBUTE, runtime);
+ } catch (TuscanyRuntimeException e) {
+ servletContext.log(e.getMessage(), e);
+ // TODO: Dump the stack trace so that we can see from the Tomcat console
+ e.printStackTrace();
+ throw e;
+ } catch (MalformedURLException e) {
+ servletContext.log(e.getMessage(), e);
+ // TODO: Dump the stack trace so that we can see from the Tomcat console
+ e.printStackTrace();
+ throw new TuscanyInitException(e);
+ } catch (Throwable e) {
+ servletContext.log(e.getMessage(), e);
+ // TODO: Dump the stack trace so that we can see from the Tomcat console
+ e.printStackTrace();
+ throw new TuscanyInitException(e);
+ }
+ }
+
+ protected WebappUtil getUtils(ServletContext servletContext) {
+ return new WebappUtilImpl(servletContext);
+ }
+
+ public void contextDestroyed(ServletContextEvent event) {
+ ServletContext servletContext = event.getServletContext();
+ WebappRuntime runtime = (WebappRuntime) servletContext.getAttribute(RUNTIME_ATTRIBUTE);
+ if (runtime == null) {
+ return;
+ }
+
+ servletContext.removeAttribute(RUNTIME_ATTRIBUTE);
+ runtime.destroy();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java
new file mode 100644
index 0000000000..07d9afe797
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.osoa.sca.SCA;
+
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+
+/**
+ * Maps an incoming request and the current composite context to the composite component for the web application. This
+ * filter must be applied to all web application urls that execute unmanaged code (e.g. JSPs and Servlets) which
+ * accesses the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyFilter implements Filter {
+
+ private SCA context;
+ private WebappRuntime runtime;
+
+ public void init(FilterConfig config) throws ServletException {
+ runtime = (WebappRuntime) config.getServletContext().getAttribute(RUNTIME_ATTRIBUTE);
+ if (runtime == null) {
+ throw new ServletException("Tuscany is not configured for the web application");
+ }
+ context = runtime.getContext();
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain)
+ throws IOException, ServletException {
+ try {
+ runtime.startRequest();
+ context.start();
+ filterChain.doFilter(req, resp);
+ } finally {
+ context.stop();
+ runtime.stopRequest();
+ }
+ }
+
+ public void destroy() {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyInitException.java
new file mode 100644
index 0000000000..57e96318a7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyInitException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Exception indicating that there was a problem starting the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyInitException extends TuscanyRuntimeException {
+ public TuscanyInitException(String string) {
+ super(string);
+ }
+
+ public TuscanyInitException(String string, Throwable throwable) {
+ super(string, throwable);
+ }
+
+ public TuscanyInitException(Throwable throwable) {
+ super(throwable);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyRequestListener.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyRequestListener.java
new file mode 100644
index 0000000000..0da3f20b22
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyRequestListener.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Notifies the Tuscany runtime of session creation and expiration events.
+ *
+ * @version $Rev: 441961 $ $Date: 2006-09-10 11:48:29 -0400 (Sun, 10 Sep 2006) $
+ */
+public class TuscanyRequestListener implements ServletRequestListener {
+ private WebappRuntime runtime;
+
+ public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
+
+ final ServletContext context = servletRequestEvent.getServletContext();
+ getRuntime(context);
+ ServletRequest servletRequest = servletRequestEvent.getServletRequest();
+ if (servletRequest instanceof HttpServletRequest) {
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+ HttpSession session = httpServletRequest.getSession(false);
+ runtime.httpRequestEnded(session == null ? null : session.getId());
+
+ }
+
+ }
+
+ public void requestInitialized(ServletRequestEvent servletRequestEvent) {
+
+ final ServletContext context = servletRequestEvent.getServletContext();
+ getRuntime(context);
+ ServletRequest servletRequest = servletRequestEvent.getServletRequest();
+ if (servletRequest instanceof HttpServletRequest) {
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+ HttpSession session = httpServletRequest.getSession(false);
+ runtime.httpRequestStarted(session == null ? null : session.getId());
+
+ }
+
+ }
+
+ protected WebappRuntime getRuntime(final ServletContext context) {
+ if (runtime == null) {
+
+ runtime = (WebappRuntime) context.getAttribute(RUNTIME_ATTRIBUTE);
+ if (runtime == null) {
+ context.log("requestInitialized", new ServletException("Tuscany runtime not configured"));
+ return null;
+ }
+ }
+ return runtime;
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
new file mode 100644
index 0000000000..6a8cf6e89d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.io.IOException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+
+/**
+ * A servlet that forwards requests intended for SCA services into the Tuscany runtime via a ServletRequestInjector.
+ * This servlet is typically mapped to relative paths beginning with <code>/services</code> in the <code>web.xml</code>
+ * <p/>
+ * TODO a better URL mapping scheme out to be implemented that corresponds to the SCA specification
+ */
+public class TuscanyServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private ServletRequestInjector requestInjector;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ ServletContext servletContext = config.getServletContext();
+ WebappRuntime runtime = (WebappRuntime) servletContext.getAttribute(RUNTIME_ATTRIBUTE);
+ if (runtime == null) {
+ throw new ServletException("Tuscany runtime not configured for web application");
+ }
+ requestInjector = runtime.getRequestInjector();
+ }
+
+ @Override
+ public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
+ requestInjector.service(req, res);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanySessionListener.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanySessionListener.java
new file mode 100644
index 0000000000..a6de97cd32
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanySessionListener.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+
+/**
+ * Notifies the Tuscany runtime of session creation and expiration events.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanySessionListener implements HttpSessionListener {
+ private WebappRuntime runtime;
+
+ public void sessionCreated(HttpSessionEvent event) {
+ if (runtime == null) {
+ ServletContext context = event.getSession().getServletContext();
+ runtime = (WebappRuntime) context.getAttribute(RUNTIME_ATTRIBUTE);
+ if (runtime == null) {
+ context.log("Error on session creation", new ServletException("Tuscany runtime not configured"));
+ return;
+ }
+ }
+ runtime.sessionCreated(event);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event) {
+ runtime.sessionDestroyed(event);
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
new file mode 100644
index 0000000000..535922fa51
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+
+/**
+ * The contract for artifacts loaded in the web application classloader to comminicate with the Tuscany runtime loaded
+ * in a child classloader. For example, filters and listeners may use this interface to notify the runtime of the web
+ * container events.
+ *
+ * @version $Rev$ $Date$
+ * @see TuscanyFilter
+ * @see TuscanySessionListener
+ */
+public interface WebappRuntime extends HttpSessionListener, TuscanyRuntime {
+ /**
+ * Returns the ServletContext associated with this runtime.
+ *
+ * @return the ServletContext associated with this runtime
+ */
+ ServletContext getServletContext();
+
+ /**
+ * Sets the ServletContext associated with this runtime.
+ *
+ * @param servletContext the ServletContext associated with this runtime
+ */
+ void setServletContext(ServletContext servletContext);
+
+ /**
+ * Returns the request injector for the runtime
+ */
+ ServletRequestInjector getRequestInjector();
+
+ /**
+ * Notification that the web application has begun servicing a request
+ */
+ void startRequest();
+
+ /**
+ * Notification that the web application has stopped servicing a request
+ */
+ void stopRequest();
+
+ /**
+ * httpRequestStarted request has been started with sessid id
+ * @param session id.
+ */
+ void httpRequestStarted(Object id);
+
+ /**
+ * httpRequestEnded request has been ended with sessid id
+ * @param session id.
+ */
+
+ void httpRequestEnded(Object id);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java
new file mode 100644
index 0000000000..98e045cb62
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface WebappRuntimeInfo extends RuntimeInfo {
+ static String COMPONENT_NAME = "WebappRuntimeInfo";
+ /**
+ * Returns the ServletContext associated with this webapp runtime.
+ *
+ * @return the ServletContext associated with this webapp runtime.
+ */
+ ServletContext getServletContext();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfoImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfoImpl.java
new file mode 100644
index 0000000000..a63bb33544
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfoImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.io.File;
+import java.net.URL;
+import javax.servlet.ServletContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WebappRuntimeInfoImpl implements WebappRuntimeInfo {
+ private final ServletContext servletContext;
+ private final URL baseURL;
+ private final boolean online;
+
+ public WebappRuntimeInfoImpl(ServletContext servletContext, URL baseURL, boolean online) {
+ this.servletContext = servletContext;
+ this.baseURL = baseURL;
+ this.online = online;
+ }
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public URL getBaseURL() {
+ return baseURL;
+ }
+
+ public File getInstallDirectory() {
+ return new File("");
+ }
+
+ public File getApplicationRootDirectory() {
+ return new File("");
+ }
+
+ public boolean isOnline() {
+ return online;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java
new file mode 100644
index 0000000000..3e1bd5d746
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface WebappUtil {
+ /**
+ * Return the classloader that should be used to boot the Tuscany runtime.
+ * This will be a child of the web application's ClassLoader.
+ *
+ * @param webappClassLoader the web application's classloader
+ * @return a classloader that can be used to load the Tuscany runtime classes
+ */
+ ClassLoader getBootClassLoader(ClassLoader webappClassLoader);
+
+ WebappRuntime getRuntime(ClassLoader bootClassLoader);
+
+ URL getSystemScdl(ClassLoader bootClassLoader);
+
+ String getApplicationName();
+
+ URL getApplicationScdl(ClassLoader bootClassLoader);
+
+ URL getScdlURL(String path, ClassLoader classLoader)
+ throws MalformedURLException;
+
+ /**
+ * Return a init parameter from the servlet context or provide a default.
+ *
+ * @param name the name of the parameter
+ * @param value the default value
+ * @return the value of the specified parameter, or the default if not defined
+ */
+ String getInitParameter(String name, String value);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java
new file mode 100644
index 0000000000..4940041c7d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Set;
+import javax.servlet.ServletContext;
+
+import static org.apache.tuscany.runtime.webapp.Constants.APPLICATION_SCDL_PATH_DEFAULT;
+import static org.apache.tuscany.runtime.webapp.Constants.APPLICATION_SCDL_PATH_PARAM;
+import static org.apache.tuscany.runtime.webapp.Constants.BOOTDIR_DEFAULT;
+import static org.apache.tuscany.runtime.webapp.Constants.BOOTDIR_PARAM;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_DEFAULT;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_PARAM;
+import static org.apache.tuscany.runtime.webapp.Constants.SYSTEM_SCDL_PATH_DEFAULT;
+import static org.apache.tuscany.runtime.webapp.Constants.SYSTEM_SCDL_PATH_PARAM;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WebappUtilImpl implements WebappUtil {
+ private final ServletContext servletContext;
+
+ public WebappUtilImpl(ServletContext servletContext) {
+ this.servletContext = servletContext;
+ }
+
+ public ClassLoader getBootClassLoader(ClassLoader webappClassLoader) {
+ String bootDirName = getInitParameter(BOOTDIR_PARAM, BOOTDIR_DEFAULT);
+ Set paths = servletContext.getResourcePaths(bootDirName);
+ if (paths == null) {
+ // nothing in boot directory, assume everything is in the webapp classloader
+ return webappClassLoader;
+ }
+ URL[] urls = new URL[paths.size()];
+ int i = 0;
+ for (Object path : paths) {
+ try {
+ urls[i++] = servletContext.getResource((String) path);
+ } catch (MalformedURLException e) {
+ throw new AssertionError("getResourcePaths returned an invalid path: " + path);
+ }
+ }
+ return new URLClassLoader(urls, webappClassLoader);
+ }
+
+ public WebappRuntime getRuntime(ClassLoader bootClassLoader) {
+ try {
+ String className = getInitParameter(RUNTIME_PARAM, RUNTIME_DEFAULT);
+ Class<?> runtimeClass = bootClassLoader.loadClass(className);
+ return (WebappRuntime) runtimeClass.newInstance();
+ } catch (InstantiationException e) {
+ throw new TuscanyInitException("Invalid runtime class", e);
+ } catch (IllegalAccessException e) {
+ throw new TuscanyInitException("Invalid runtime class", e);
+ } catch (ClassNotFoundException e) {
+ throw new TuscanyInitException("Runtime Implementation not found", e);
+ }
+ }
+
+ public URL getSystemScdl(ClassLoader bootClassLoader) {
+ String path = getInitParameter(SYSTEM_SCDL_PATH_PARAM, SYSTEM_SCDL_PATH_DEFAULT);
+ try {
+ return getScdlURL(path, bootClassLoader);
+ } catch (MalformedURLException e) {
+ throw new TuscanyInitException("Invalid resource path for " + SYSTEM_SCDL_PATH_PARAM + " : " + path, e);
+ }
+ }
+
+ public String getApplicationName() {
+ String name = servletContext.getServletContextName();
+ if (name == null) {
+ name = "application";
+ }
+ return name;
+ }
+
+ public URL getApplicationScdl(ClassLoader bootClassLoader) {
+ String path = getInitParameter(APPLICATION_SCDL_PATH_PARAM, APPLICATION_SCDL_PATH_DEFAULT);
+ try {
+ return getScdlURL(path, bootClassLoader);
+ } catch (MalformedURLException e) {
+ throw new TuscanyInitException("Invalid resource path for " + APPLICATION_SCDL_PATH_PARAM + " : " + path,
+ e);
+ }
+ }
+
+ public URL getScdlURL(String path, ClassLoader classLoader)
+ throws MalformedURLException {
+ URL ret = null;
+ if (path.charAt(0) == '/') {
+ // user supplied an absolute path - look up as a webapp resource
+ ret = servletContext.getResource(path);
+ }
+ if (ret == null) {
+ // user supplied a relative path - look up as a boot classpath resource
+ ret = classLoader.getResource(path);
+ }
+ return ret;
+ }
+
+ public String getInitParameter(String name, String value) {
+ String result = servletContext.getInitParameter(name);
+ if (result != null && result.length() != 0) {
+ return result;
+ }
+ return value;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
new file mode 100644
index 0000000000..b4f8f4c3db
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.URL;
+import java.lang.reflect.Method;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+
+import junit.framework.TestCase;
+import static org.easymock.classextension.EasyMock.*;
+
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyContextListenerTestCase extends TestCase {
+ private ServletContext context;
+ private TuscanyContextListener listener;
+ private ClassLoader cl;
+ private ClassLoader bootClassLoader;
+ private URL systemUrl;
+ private URL applicationUrl;
+ private Method getUtilsMethod;
+ private MonitorFactory monitorFactory;
+ private WebappUtil utils;
+
+ public void testInitializationUsingDefaults() throws Exception {
+ ServletContextEvent event = createMock(ServletContextEvent.class);
+ expect(event.getServletContext()).andReturn(context);
+ replay(event);
+
+ WebappRuntime runtime = createMock(WebappRuntime.class);
+ expect(utils.getBootClassLoader(cl)).andReturn(bootClassLoader);
+ expect(utils.getInitParameter("tuscany.online", "true")).andReturn("true");
+ expect(utils.getRuntime(bootClassLoader)).andReturn(runtime);
+ expect(utils.getSystemScdl(bootClassLoader)).andReturn(systemUrl);
+ expect(utils.getApplicationScdl(cl)).andReturn(applicationUrl);
+ expect(utils.getApplicationName()).andReturn("application");
+ replay(utils);
+
+ expect(context.getResource("/WEB-INF/tuscany/")).andReturn(null);
+ context.setAttribute(eq(Constants.RUNTIME_ATTRIBUTE), isA(WebappRuntime.class));
+ replay(context);
+ replay(cl);
+ replay(bootClassLoader);
+ expect(listener.getUtils(context)).andReturn(utils);
+ replay(listener);
+ runtime.setServletContext(context);
+ expect(runtime.createDefaultMonitorFactory()).andReturn(monitorFactory);
+ runtime.setMonitorFactory(monitorFactory);
+ runtime.setRuntimeInfo(isA(WebappRuntimeInfo.class));
+ runtime.setHostClassLoader(cl);
+ runtime.setSystemScdl(systemUrl);
+ runtime.setApplicationName("application");
+ runtime.setApplicationScdl(applicationUrl);
+ runtime.initialize();
+ replay(runtime);
+
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(cl);
+ listener.contextInitialized(event);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+ verify(event);
+ verify(context);
+ verify(listener);
+ verify(cl);
+ verify(bootClassLoader);
+ verify(runtime);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ getUtilsMethod = TuscanyContextListener.class.getDeclaredMethod("getUtils", ServletContext.class);
+ utils = createMock(WebappUtil.class);
+ listener = createMock(TuscanyContextListener.class, new Method[]{getUtilsMethod});
+ context = createMock(ServletContext.class);
+ cl = createMock(ClassLoader.class);
+ bootClassLoader = createMock(ClassLoader.class);
+ systemUrl = new URL("file:/system.scdl");
+ applicationUrl = new URL("file:/application.scdl");
+ monitorFactory = createMock(MonitorFactory.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyFilterTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyFilterTestCase.java
new file mode 100644
index 0000000000..b649c22178
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyFilterTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.osoa.sca.SCA;
+
+import junit.framework.TestCase;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyFilterTestCase extends TestCase {
+
+ public void testStartStopFilter() throws Exception {
+ SCA sca = EasyMock.createNiceMock(SCA.class);
+ sca.start();
+ sca.stop();
+ EasyMock.replay(sca);
+ WebappRuntime runtime = createMock(WebappRuntime.class);
+ expect(runtime.getContext()).andReturn(sca);
+ runtime.startRequest();
+ runtime.stopRequest();
+ replay(runtime);
+ ServletContext context = createNiceMock(ServletContext.class);
+ EasyMock.expect(context.getAttribute(RUNTIME_ATTRIBUTE)).andReturn(runtime);
+ replay(context);
+ TuscanyFilter filter = new TuscanyFilter();
+ FilterConfig config = createMock(FilterConfig.class);
+ expect(config.getServletContext()).andReturn(context);
+ replay(config);
+ filter.init(config);
+ ServletRequest req = createNiceMock(ServletRequest.class);
+ ServletResponse resp = createNiceMock(ServletResponse.class);
+ FilterChain chain = createNiceMock(FilterChain.class);
+ filter.doFilter(req, resp, chain);
+ verify(runtime);
+ EasyMock.verify(sca);
+ }
+
+ public void testExceptionCleanupFilter() throws Exception {
+ SCA sca = EasyMock.createNiceMock(SCA.class);
+ sca.start();
+ sca.stop();
+ EasyMock.replay(sca);
+ WebappRuntime runtime = createMock(WebappRuntime.class);
+ runtime.startRequest();
+ runtime.stopRequest();
+ expect(runtime.getContext()).andReturn(sca);
+ replay(runtime);
+ ServletContext context = createNiceMock(ServletContext.class);
+ EasyMock.expect(context.getAttribute(RUNTIME_ATTRIBUTE)).andReturn(runtime);
+ replay(context);
+ TuscanyFilter filter = new TuscanyFilter();
+ FilterConfig config = createMock(FilterConfig.class);
+ expect(config.getServletContext()).andReturn(context);
+ replay(config);
+ filter.init(config);
+ ServletRequest req = createNiceMock(ServletRequest.class);
+ ServletResponse resp = createNiceMock(ServletResponse.class);
+ FilterChain chain = createNiceMock(FilterChain.class);
+ chain.doFilter(isA(ServletRequest.class), isA(ServletResponse.class));
+ EasyMock.expectLastCall().andThrow(new TestException());
+ filter.doFilter(req, resp, chain);
+ verify(runtime);
+ EasyMock.verify(sca);
+ }
+
+ public void testRuntimeNotConfigured() throws Exception {
+ ServletContext context = createNiceMock(ServletContext.class);
+ TuscanyFilter filter = new TuscanyFilter();
+ FilterConfig config = createMock(FilterConfig.class);
+ expect(config.getServletContext()).andReturn(context);
+ replay(config);
+ try {
+ filter.init(config);
+ fail();
+ } catch (ServletException e) {
+ //expected
+ }
+ }
+
+ private class TestException extends RuntimeException {
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java
new file mode 100644
index 0000000000..5213ae9cb1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Verifies {@link TuscanyServlet} properly services a request
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyServletTestCase extends TestCase {
+
+ public void testRequestInjection() throws Exception {
+ ServletRequest req = createNiceMock(ServletRequest.class);
+ ServletResponse resp = createNiceMock(ServletResponse.class);
+ ServletRequestInjector injector = createMock(ServletRequestInjector.class);
+ injector.service(eq(req), eq(resp));
+ EasyMock.replay(injector);
+ WebappRuntime runtime = createMock(WebappRuntime.class);
+ expect(runtime.getRequestInjector()).andReturn(injector);
+ replay(runtime);
+ ServletContext context = createNiceMock(ServletContext.class);
+ EasyMock.expect(context.getAttribute(RUNTIME_ATTRIBUTE)).andReturn(runtime);
+ EasyMock.replay(context);
+ TuscanyServlet servlet = new TuscanyServlet();
+ ServletConfig config = createMock(ServletConfig.class);
+ expect(config.getServletContext()).andReturn(context);
+ replay(config);
+ servlet.init(config);
+ servlet.service(req, resp);
+ verify(context);
+ verify(injector);
+ }
+
+ public void testRuntimeNotConfigured() throws Exception {
+ ServletContext context = createNiceMock(ServletContext.class);
+ TuscanyServlet servlet = new TuscanyServlet();
+ ServletConfig config = createMock(ServletConfig.class);
+ expect(config.getServletContext()).andReturn(context);
+ replay(config);
+ try {
+ servlet.init(config);
+ fail();
+ } catch (ServletException e) {
+ //expected
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanySessionListenerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanySessionListenerTestCase.java
new file mode 100644
index 0000000000..3bac14fd8a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanySessionListenerTestCase.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionEvent;
+
+import junit.framework.TestCase;
+import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies {@link org.apache.tuscany.runtime.webapp.TuscanySessionListener} notifies the runtime of session events
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanySessionListenerTestCase extends TestCase {
+
+ public void testSessionPropagated() throws Exception {
+ WebappRuntime runtime = EasyMock.createNiceMock(WebappRuntime.class);
+ runtime.sessionCreated(EasyMock.isA(HttpSessionEvent.class));
+ runtime.sessionDestroyed(EasyMock.isA(HttpSessionEvent.class));
+ EasyMock.replay(runtime);
+ ServletContext context = EasyMock.createNiceMock(ServletContext.class);
+ EasyMock.expect(context.getAttribute(RUNTIME_ATTRIBUTE)).andReturn(runtime);
+ EasyMock.replay(context);
+ HttpSession session = EasyMock.createNiceMock(HttpSession.class);
+ EasyMock.expect(session.getServletContext()).andReturn(context);
+ EasyMock.replay(session);
+ HttpSessionEvent event = new HttpSessionEvent(session);
+ TuscanySessionListener listener = new TuscanySessionListener();
+ listener.sessionCreated(event);
+ listener.sessionDestroyed(event);
+ EasyMock.verify(context);
+ EasyMock.verify(runtime);
+ }
+
+ /**
+ * Verifies an error is logged when no runtime is configured
+ *
+ * @throws Exception
+ */
+ public void testRuntimeNotConfigured() throws Exception {
+ ServletContext context = EasyMock.createNiceMock(ServletContext.class);
+ context.log(EasyMock.isA(String.class), EasyMock.isA(ServletException.class));
+ EasyMock.replay(context);
+ TuscanySessionListener listener = new TuscanySessionListener();
+ HttpSession session = EasyMock.createNiceMock(HttpSession.class);
+ EasyMock.expect(session.getServletContext()).andReturn(context);
+ EasyMock.replay(session);
+ HttpSessionEvent event = new HttpSessionEvent(session);
+ listener.sessionCreated(event);
+ EasyMock.verify(context);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/WebappUtilTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/WebappUtilTestCase.java
new file mode 100644
index 0000000000..f865a4e740
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/WebappUtilTestCase.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.runtime.webapp;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.servlet.ServletContext;
+
+import junit.framework.TestCase;
+import static org.easymock.classextension.EasyMock.*;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WebappUtilTestCase extends TestCase {
+ private ServletContext context;
+ private WebappUtilImpl listener;
+ private ClassLoader cl;
+ private URL systemUrl;
+
+
+ public void testGetInitParameterWhenSpecified() {
+ String name = "name";
+ String value = "default";
+ expect(context.getInitParameter(name)).andReturn(value);
+ replay(context);
+
+ assertEquals(value, listener.getInitParameter(name, "default"));
+ verify(context);
+ }
+
+ public void testGetInitParameterUsingDefault() {
+ String name = "name";
+ String value = "default";
+ expect(context.getInitParameter(name)).andReturn(null);
+ replay(context);
+
+ assertEquals(value, listener.getInitParameter(name, value));
+ verify(context);
+ }
+
+ public void testGetInitParameterWithZeroLength() {
+ String name = "name";
+ String value = "default";
+ expect(context.getInitParameter(name)).andReturn("");
+ replay(context);
+
+ assertEquals(value, listener.getInitParameter(name, value));
+ verify(context);
+ }
+
+ public void testGetScdlFromWebapp() throws MalformedURLException {
+ String path = "/WEB-INF/test";
+ expect(context.getResource(path)).andReturn(systemUrl);
+ replay(context);
+ replay(cl);
+ assertSame(systemUrl, listener.getScdlURL(path, cl));
+ verify(context);
+ verify(cl);
+ }
+
+ public void testGetScdlFromWebappMissing() throws MalformedURLException {
+ String path = "/WEB-INF/test";
+ expect(context.getResource(path)).andReturn(null);
+ replay(context);
+ expect(cl.getResource(path)).andReturn(null);
+ replay(cl);
+ assertNull(listener.getScdlURL(path, cl));
+ verify(context);
+ verify(cl);
+ }
+
+ public void testGetScdlFromWebappMalformed() throws MalformedURLException {
+ String path = "/WEB-INF/test";
+ expect(context.getResource(path)).andThrow(new MalformedURLException());
+ replay(context);
+ replay(cl);
+ try {
+ listener.getScdlURL(path, cl);
+ fail();
+ } catch (MalformedURLException e) {
+ // OK
+ }
+ verify(context);
+ verify(cl);
+ }
+
+ public void testGetScdlFromClasspath() throws MalformedURLException {
+ String path = "META-INF/test";
+ replay(context);
+ expect(cl.getResource(path)).andReturn(systemUrl);
+ replay(cl);
+ assertSame(systemUrl, listener.getScdlURL(path, cl));
+ verify(context);
+ verify(cl);
+ }
+
+ public void testGetScdlFromClasspathMissing() throws MalformedURLException {
+ String path = "META-INF/test";
+ replay(context);
+ expect(cl.getResource(path)).andReturn(null);
+ replay(cl);
+ assertNull(listener.getScdlURL(path, cl));
+ verify(context);
+ verify(cl);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ context = createMock(ServletContext.class);
+ listener = new WebappUtilImpl(context);
+ cl = createMock(ClassLoader.class);
+ systemUrl = new URL("file:/system.scdl");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset
new file mode 100644
index 0000000000..70a035bc01
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml
new file mode 100755
index 0000000000..e9d32c7f9c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>axis2</artifactId>
+ <name>Apache Tuscany Binding for Axis2</name>
+ <description>Implementation of the SCA Web Services binding using Axis2.</description>
+
+ <repositories>
+ <!-- ws zones repos is for woden -->
+ <repository>
+ <id>apache.ws.zones</id>
+ <name>Apache WS zones Repository</name>
+ <url>http://ws.zones.apache.org/repository/</url>
+ <layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- A hack to bring in databinding-axiom transitively -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-axiom</artifactId>
+ <version>${sca.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <!-- Axis2 1.1 release -->
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>incubator-woden</groupId>
+ <artifactId>woden</artifactId>
+ <version>1.0.0M6</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>2.2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>httpcomponents-httpcore</groupId>
+ <artifactId>jakarta-httpcore</artifactId>
+ <version>4.0-alpha2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- end Axis2 1.1 release -->
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml
new file mode 100644
index 0000000000..7c835caa5c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<assembly>
+ <id>bin</id>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <formats>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>extension</outputDirectory>
+ <includes>
+ <include>org.apache.tuscany.bindings:axis2</include>
+ </includes>
+ <fileMode>644</fileMode>
+ </dependencySet>
+ </dependencySets>
+</assembly>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
new file mode 100644
index 0000000000..0cf3976f37
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+public class Axis2AsyncTargetInvoker extends Axis2TargetInvoker {
+
+ protected static final OMElement RESPONSE = null;
+
+ private InboundWire wire;
+ private Object messageId;
+ private Axis2ReferenceCallbackTargetInvoker callbackInvoker;
+
+ public Axis2AsyncTargetInvoker(ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory,
+ InboundWire wire) {
+ super(serviceClient, wsdlOperationName, options, soapFactory);
+ this.wire = wire;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object[] args = (Object[])payload;
+ OperationClient operationClient = createOperationClient(args);
+ callbackInvoker.setCorrelationId(messageId);
+ Axis2ReferenceCallback callback = new Axis2ReferenceCallback(callbackInvoker);
+ operationClient.setCallback(callback);
+
+ operationClient.execute(false);
+
+ // REVIEW it seems ok to return null
+ return RESPONSE;
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ wire.addMapping(msg.getMessageId(), msg.getFromAddress());
+ messageId = msg.getMessageId();
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public void setCallbackTargetInvoker(Axis2ReferenceCallbackTargetInvoker callbackInvoker) {
+ this.callbackInvoker = callbackInvoker;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
new file mode 100755
index 0000000000..1090be874d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospector;
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.IncompatibleServiceContractException;
+
+/**
+ * Builds a {@link org.osoa.sca.annotations.Service} or {@link org.apache.tuscany.spi.component.Reference} configured
+ * with the Axis2 binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingBuilder extends BindingBuilderExtension<WebServiceBinding> {
+ private static final String OM_DATA_BINDING = OMElement.class.getName();
+
+ private ServletHost servletHost;
+
+ private ConfigurationContext configContext;
+
+ private WorkContext workContext;
+
+ private InterfaceWSDLIntrospector introspector;
+
+ public Axis2BindingBuilder() {
+ initAxis();
+ }
+
+ @Autowire(required = false)
+ public void setServletHost(ServletHost servletHost) {
+ this.servletHost = servletHost;
+ }
+
+ /**
+ * @param introspector the introspector to set
+ */
+ @Autowire
+ public void setIntrospector(InterfaceWSDLIntrospector introspector) {
+ this.introspector = introspector;
+ }
+
+ @Autowire
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Service build(
+ CompositeComponent parent,
+ BoundServiceDefinition<WebServiceBinding> serviceDefinition,
+ DeploymentContext deploymentContext) {
+
+ try {
+ // Set the default databinding
+ ServiceContract<?> outboundContract = serviceDefinition.getServiceContract();
+ if (WSDLServiceContract.class.isInstance(outboundContract)) {
+ outboundContract.setDataBinding(OM_DATA_BINDING);
+ }
+
+ // FIXME: We need to define how the WSDL PortType is honored in the case that
+ // both the binding.ws and interface.wsdl are in place.
+ // The WSDL portType from the WSDL Port decides the incoming SOAP message format
+ // There are also cases that interface.java is used.
+
+ ServiceContract<?> inboundContract = null;
+ WebServiceBinding wsBinding = serviceDefinition.getBinding();
+ Port port = wsBinding.getWSDLPort();
+ if (port == null) {
+ // FIXME: [rfeng] No WSDL is referenced by binding.ws, we need to create one from
+ // the outbound service contract if it's JavaServiceContract
+ inboundContract = outboundContract;
+ }
+
+ PortType portType = wsBinding.getWSDLPort().getBinding().getPortType();
+ inboundContract = introspector.introspect(portType);
+
+ // FIXME:
+ inboundContract.setInterfaceClass(serviceDefinition.getServiceContract().getInterfaceClass());
+ inboundContract.setDataBinding(OM_DATA_BINDING);
+ inboundContract.setCallbackName(serviceDefinition.getServiceContract().getCallbackName());
+
+ try {
+ wireService.checkCompatibility(inboundContract, outboundContract, true);
+ } catch (IncompatibleServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+
+ Service service = new Axis2Service(serviceDefinition.getName(), outboundContract, parent, wireService, wsBinding,
+ servletHost, configContext, workContext);
+ service.setBindingServiceContract(inboundContract);
+
+ return service;
+
+ } catch (InvalidServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Reference build(
+ CompositeComponent parent,
+ BoundReferenceDefinition<WebServiceBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+
+ try {
+ // Set the default binding
+ ServiceContract<?> inboundContract = boundReferenceDefinition.getServiceContract();
+ if (WSDLServiceContract.class.isInstance(inboundContract)) {
+ inboundContract.setDataBinding(OM_DATA_BINDING);
+ }
+
+ // FIXME: We need to define how the WSDL PortType is honored in the case that
+ // both the binding.ws and interface.wsdl are in place
+ // The WSDL portType from the WSDL Port decides the incoming SOAP message format
+
+ ServiceContract<?> outboundContract = inboundContract;
+ WebServiceBinding wsBinding = boundReferenceDefinition.getBinding();
+ Port port = wsBinding.getWSDLPort();
+ if (port == null) {
+ // FIXME: [rfeng] No WSDL is referenced by binding.ws, we need to create one from
+ // the inbound service contract if it's JavaServiceContract
+ outboundContract = inboundContract;
+ }
+ PortType portType = port.getBinding().getPortType();
+ outboundContract = introspector.introspect(portType);
+
+ // Set the default databinding
+ outboundContract.setDataBinding(OM_DATA_BINDING);
+
+ try {
+ wireService.checkCompatibility(inboundContract, outboundContract, true);
+ } catch (IncompatibleServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+
+ Reference reference = new Axis2Reference(boundReferenceDefinition.getName(), parent, wireService, wsBinding,
+ inboundContract, workContext);
+ reference.setBindingServiceContract(outboundContract);
+
+ return reference;
+
+ } catch (InvalidServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+ }
+
+ protected Class<WebServiceBinding> getBindingType() {
+ return WebServiceBinding.class;
+ }
+
+ protected void initAxis() {
+ // TODO: Fix classloader switching. See TUSCANY-647
+ // TODO: also consider having a system component wrapping the Axis2 ConfigContext
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader scl = getClass().getClassLoader();
+ try {
+ if (tccl != scl) {
+ Thread.currentThread().setContextClassLoader(scl);
+ }
+ try {
+ this.configContext = new TuscanyAxisConfigurator().getConfigurationContext();
+ } catch (AxisFault e) {
+ throw new BuilderConfigException(e);
+ }
+ } finally {
+ if (tccl != scl) {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java
new file mode 100644
index 0000000000..a5743668a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+
+/**
+ * Base class for Exceptions raised during the loading process. Loader implementations should throw a subclass of this
+ * to indicate the actual problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingBuilderRuntimeException extends Axis2BindingRunTimeException {
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+
+ public Axis2BindingBuilderRuntimeException() {
+ }
+
+ public Axis2BindingBuilderRuntimeException(String message) {
+ super(message);
+ }
+
+ public Axis2BindingBuilderRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public Axis2BindingBuilderRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being loaded.
+ *
+ * @return the location of the resource that was being loaded
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being loaded.
+ *
+ * @param resourceURI the location of the resource that was being loaded
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java
new file mode 100644
index 0000000000..cd957c2ec6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingRunTimeException extends TuscanyRuntimeException {
+ private static final long serialVersionUID = -6423113430265944499L;
+
+ public Axis2BindingRunTimeException() {
+ super();
+ }
+
+ public Axis2BindingRunTimeException(String message) {
+ super(message);
+ }
+
+ public Axis2BindingRunTimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public Axis2BindingRunTimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java
new file mode 100644
index 0000000000..4a9e054237
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2CallbackInvocationHandler extends AbstractOutboundInvocationHandler {
+
+ private InboundWire inboundWire;
+ private Object messageId;
+ private Object correlationId;
+
+ public Axis2CallbackInvocationHandler(InboundWire inboundWire) {
+ this.inboundWire = inboundWire;
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws Throwable {
+ Object targetAddress = inboundWire.retrieveMapping(correlationId);
+ if (targetAddress == null) {
+ throw new AssertionError("No from address associated with message id [" + correlationId + "]");
+ }
+ //TODO optimize as this is slow in local invocations
+ Map<Operation<?>, OutboundInvocationChain> sourceCallbackInvocationChains =
+ inboundWire.getSourceCallbackInvocationChains(targetAddress);
+ OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation);
+ TargetInvoker invoker = chain.getTargetInvoker();
+ return invoke(chain, invoker, args);
+ }
+
+ // This must be called before invoke
+ public void setMessageId(Object messageId) {
+ this.messageId = messageId;
+ }
+
+ // This must be called before invoke
+ public void setCorrelationId(Object correlationId) {
+ this.correlationId = correlationId;
+ }
+
+ protected Object getFromAddress() {
+ return (inboundWire.getContainer() == null) ? null : inboundWire.getContainer().getName();
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
new file mode 100644
index 0000000000..a85c57313f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+public class Axis2OneWayTargetInvoker extends Axis2TargetInvoker {
+
+ protected static final OMElement RESPONSE = null;
+
+ public Axis2OneWayTargetInvoker(ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory) {
+
+ super(serviceClient, wsdlOperationName, options, soapFactory);
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object[] args = (Object[])payload;
+ OperationClient operationClient = createOperationClient(args);
+
+ operationClient.execute(false);
+
+ // REVIEW it seems ok to return null
+ return RESPONSE;
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ } catch (Throwable t) {
+ throw new Axis2BindingRunTimeException(t);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java
new file mode 100755
index 0000000000..53ae1ae51e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.binding.axis2.util.WebServiceOperationMetaData;
+import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * Axis2Reference uses Axis2 to invoke a remote web service
+ */
+public class Axis2Reference<T> extends ReferenceExtension {
+
+ private WebServicePortMetaData wsPortMetaData;
+ private ServiceClient serviceClient;
+
+ // private WorkContext workContext;
+
+ @SuppressWarnings("unchecked")
+ public Axis2Reference(String theName,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding wsBinding,
+ ServiceContract contract,
+ WorkContext workContext) {
+ super(theName, (Class<T>)contract.getInterfaceClass(), parent, wireService);
+ try {
+ Definition wsdlDefinition = wsBinding.getWSDLDefinition();
+ wsPortMetaData =
+ new WebServicePortMetaData(wsdlDefinition, wsBinding.getWSDLPort(), wsBinding.getURI(), false);
+ serviceClient = createServiceClient(wsdlDefinition, wsPortMetaData);
+ // this.workContext = workContext;
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ Axis2TargetInvoker invoker;
+ try {
+ boolean isOneWay = operation.isNonBlocking();
+ invoker = createOperationInvoker(serviceClient, operation, wsPortMetaData, false, isOneWay);
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ return invoker;
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation) {
+ Axis2AsyncTargetInvoker invoker;
+ try {
+ // FIXME: SDODataBinding needs to pass in TypeHelper and classLoader
+ // as parameters.
+ invoker =
+ (Axis2AsyncTargetInvoker)createOperationInvoker(serviceClient,
+ operation,
+ wsPortMetaData,
+ true,
+ false);
+ // FIXME: This makes the (BIG) assumption that there is only one
+ // callback method
+ // Relaxing this assumption, however, does not seem to be trivial,
+ // it may depend on knowledge
+ // of what actual callback method was invoked by the service at the
+ // other end
+ Operation callbackOperation = findCallbackOperation();
+ Axis2CallbackInvocationHandler invocationHandler =
+ new Axis2CallbackInvocationHandler(inboundWire);
+ Axis2ReferenceCallbackTargetInvoker callbackInvoker =
+ new Axis2ReferenceCallbackTargetInvoker(callbackOperation, inboundWire, invocationHandler);
+ invoker.setCallbackTargetInvoker(callbackInvoker);
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ return invoker;
+ }
+
+ private Operation findCallbackOperation() {
+ ServiceContract contract = inboundWire.getServiceContract();
+ Operation callbackOperation = null;
+ Collection callbackOperations = contract.getCallbackOperations().values();
+ if (callbackOperations.size() != 1) {
+ throw new Axis2BindingRunTimeException("Can only handle one callback operation");
+ } else {
+ callbackOperation = (Operation)callbackOperations.iterator().next();
+ }
+ return callbackOperation;
+ }
+
+ /**
+ * Create an Axis2 ServiceClient
+ */
+ private ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData wsPortMetaData)
+ throws AxisFault {
+
+ TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+ ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+ QName serviceQName = wsPortMetaData.getServiceName();
+ String portName = wsPortMetaData.getPortName().getLocalPart();
+ AxisService axisService =
+ AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
+ return new ServiceClient(configurationContext, axisService);
+ }
+
+ /**
+ * Create and configure an Axis2TargetInvoker for each operations
+ */
+ private Axis2TargetInvoker createOperationInvoker(ServiceClient serviceClient,
+ Operation m,
+ WebServicePortMetaData wsPortMetaData,
+ boolean hasCallback,
+ boolean isOneWay) throws AxisFault {
+ SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+ String portTypeNS = wsPortMetaData.getPortTypeName().getNamespaceURI();
+
+ String methodName = m.getName();
+
+ WebServiceOperationMetaData operationMetaData = wsPortMetaData.getOperationMetaData(methodName);
+
+ Options options = new Options();
+ options.setTo(new EndpointReference(wsPortMetaData.getEndpoint()));
+ options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
+
+ String wsdlOperationName = operationMetaData.getBindingOperation().getOperation().getName();
+
+ String soapAction = wsPortMetaData.getOperationMetaData(wsdlOperationName).getSOAPAction();
+ if (soapAction != null && soapAction.length() > 1) {
+ options.setAction(soapAction);
+ }
+
+ options.setTimeOutInMilliSeconds(5 * 60 * 1000);
+
+ QName wsdlOperationQName = new QName(portTypeNS, wsdlOperationName);
+
+ Axis2TargetInvoker invoker;
+ if (hasCallback) {
+ invoker =
+ new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory,
+ inboundWire);
+ } else if (isOneWay) {
+ invoker = new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+ } else {
+ invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+ }
+
+ return invoker;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
new file mode 100644
index 0000000000..d6bb1a0290
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+public class Axis2ReferenceCallback extends Callback {
+
+ private Axis2ReferenceCallbackTargetInvoker targetInvoker;
+
+ public Axis2ReferenceCallback(Axis2ReferenceCallbackTargetInvoker targetInvoker) {
+ this.targetInvoker = targetInvoker;
+ }
+
+ public void onComplete(AsyncResult result) {
+ MessageContext responseMC = result.getResponseMessageContext();
+ OMElement responseOM = responseMC.getEnvelope().getBody().getFirstElement();
+ try {
+ targetInvoker.invokeTarget(new Object[] {responseOM});
+ } catch (InvocationTargetException e) {
+ // FIXME what is the appropriate exception here?
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ public void setComplete(boolean complete) {
+ super.setComplete(complete);
+ }
+
+ public void onError(Exception e) {
+ throw new InvocationRuntimeException(e);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
new file mode 100644
index 0000000000..87f9b5654b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2ReferenceCallbackTargetInvoker implements TargetInvoker {
+
+ private Operation operation;
+ private InboundWire inboundWire;
+ private Object correlationId;
+ private boolean cacheable;
+ Axis2CallbackInvocationHandler invocationHandler;
+
+ public Axis2ReferenceCallbackTargetInvoker(Operation operation,
+ InboundWire inboundWire,
+ Axis2CallbackInvocationHandler invocationHandler) {
+
+ this.operation = operation;
+ this.inboundWire = inboundWire;
+ this.invocationHandler = invocationHandler;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ invocationHandler.setMessageId(null);
+ invocationHandler.setCorrelationId(correlationId);
+ Object[] args;
+ if (payload != null && !payload.getClass().isArray()) {
+ args = new Object[]{payload};
+ } else {
+ args = (Object[]) payload;
+ }
+ try {
+ return invocationHandler.invoke(operation, args);
+ } catch(Throwable t) {
+ t.printStackTrace();
+ throw new InvocationTargetException(t);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable(); // we only need to check if the scopes are correct
+ }
+
+ public Axis2ReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+ Axis2ReferenceCallbackTargetInvoker invoker = (Axis2ReferenceCallbackTargetInvoker) super.clone();
+ invoker.operation = this.operation;
+ invoker.inboundWire = this.inboundWire;
+ invoker.correlationId = this.correlationId;
+ invoker.cacheable = this.cacheable;
+ invoker.invocationHandler = this.invocationHandler;
+ return invoker;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ this.correlationId = correlationId;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
new file mode 100755
index 0000000000..47c9d8308a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
+import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageId;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * An implementation of a {@link ServiceExtension} configured with the Axis2
+ * binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2Service extends ServiceExtension {
+ private ServiceContract<?> serviceContract;
+
+ private ServletHost servletHost;
+
+ private ConfigurationContext configContext;
+
+ private WebServiceBinding binding;
+
+ private WorkContext workContext;
+
+ private Map<MessageId, InvocationContext> invCtxMap = new HashMap<MessageId, InvocationContext>();
+
+ private String serviceName;
+
+ public Axis2Service(String theName,
+ ServiceContract<?> serviceContract,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding binding,
+ ServletHost servletHost,
+ ConfigurationContext configContext,
+ WorkContext workContext) {
+
+ super(theName, serviceContract.getInterfaceClass(), parent, wireService);
+
+ this.serviceContract = serviceContract;
+ this.binding = binding;
+ this.servletHost = servletHost;
+ this.configContext = configContext;
+ this.workContext = workContext;
+ this.serviceName = theName;
+ }
+
+ public void start() {
+ super.start();
+
+ try {
+ configContext.getAxisConfiguration().addService(createAxisService(binding));
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+
+ Axis2ServiceServlet servlet = new Axis2ServiceServlet();
+ servlet.init(configContext);
+ configContext.setContextRoot(getName());
+ servletHost.registerMapping("/" + getName(), servlet);
+ }
+
+ @Destroy
+ public void stop() {
+ servletHost.unregisterMapping("/" + getName());
+ try {
+ configContext.getAxisConfiguration().removeService(getName());
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ super.stop();
+ }
+
+ private AxisService createAxisService(WebServiceBinding wsBinding) throws AxisFault {
+ Definition definition = wsBinding.getWSDLDefinition();
+ WebServicePortMetaData wsdlPortInfo =
+ new WebServicePortMetaData(definition, wsBinding.getWSDLPort(), null, false);
+
+ // TODO investigate if this is 20 wsdl what todo?
+ WSDLToAxisServiceBuilder builder =
+ new WSDL11ToAxisServiceBuilder(definition, wsdlPortInfo.getServiceName(), wsdlPortInfo.getPort()
+ .getName());
+ builder.setServerSide(true);
+ AxisService axisService = builder.populateService();
+
+ axisService.setName(this.getName());
+ axisService.setServiceDescription("Tuscany configured AxisService for service: '" + this.getName()
+ + "'");
+
+ // Use the existing WSDL
+ Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null);
+ wsdlParam.setValue(definition);
+ axisService.addParameter(wsdlParam);
+ Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
+ axisService.addParameter(userWSDL);
+
+ PortType wsdlPortType = wsdlPortInfo.getPortType();
+ for (Object o : wsdlPortType.getOperations()) {
+ Operation wsdlOperation = (Operation)o;
+ String operationName = wsdlOperation.getName();
+ QName operationQN = new QName(definition.getTargetNamespace(), operationName);
+
+ org.apache.tuscany.spi.model.Operation<?> op = serviceContract.getOperations().get(operationName);
+
+ MessageReceiver msgrec = null;
+ boolean opIsNonBlocking = op.isNonBlocking();
+ if (serviceContract.getCallbackName() != null) {
+ msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, op, workContext);
+ } else if (opIsNonBlocking) {
+ msgrec = new Axis2ServiceInMessageReceiver(this, op);
+ } else {
+ msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op);
+ }
+
+ AxisOperation axisOp = axisService.getOperation(operationQN);
+ if (opIsNonBlocking) {
+ axisOp.setMessageExchangePattern(WSDL20_2004Constants.MEP_URI_IN_ONLY);
+ } else {
+ axisOp.setMessageExchangePattern(WSDL20_2004Constants.MEP_URI_IN_OUT);
+ }
+ axisOp.setMessageReceiver(msgrec);
+ }
+
+ return axisService;
+ }
+
+ public Object invokeTarget(org.apache.tuscany.spi.model.Operation<?> op, Object[] args)
+ throws InvocationTargetException {
+ InvocationChain chain = inboundWire.getInvocationChains().get(op);
+ Interceptor headInterceptor = chain.getHeadInterceptor();
+ if (headInterceptor == null) {
+ try {
+ // short-circuit the dispatch and invoke the target directly
+ if (chain.getTargetInvoker() == null) {
+ throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
+ }
+ return chain.getTargetInvoker().invokeTarget(args);
+ } catch (InvocationTargetException e) {
+ // the cause was thrown by the target so throw it
+ throw e;
+ }
+ } else {
+ Object messageId = workContext.getCurrentMessageId();
+ workContext.setCurrentMessageId(null);
+ Object correlationId = workContext.getCurrentCorrelationId();
+ workContext.setCurrentCorrelationId(null);
+
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(chain.getTargetInvoker());
+ msg.setFromAddress(getFromAddress());
+ if (messageId == null) {
+ messageId = new MessageId();
+ }
+ msg.setMessageId(messageId);
+ msg.setCorrelationId(correlationId);
+ msg.setBody(args);
+ Message resp;
+ // dispatch the wire down the chain and get the response
+ // TODO http://issues.apache.org/jira/browse/TUSCANY-777
+ ClassLoader oldtccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ resp = headInterceptor.invoke(msg);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldtccl);
+ }
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return body;
+ }
+ }
+
+ protected Object getFromAddress() {
+ return this.serviceName;
+ }
+
+ /**
+ * Get the Method from an interface matching the WSDL operation name
+ */
+ protected Method getMethod(Class<?> serviceInterface, String operationName) {
+ // Note: this doesn't support overloaded operations
+ Method[] methods = serviceInterface.getMethods();
+ for (Method m : methods) {
+ if (m.getName().equals(operationName)) {
+ return m;
+ }
+ // tolerate WSDL with capatalized operation name
+ StringBuilder sb = new StringBuilder(operationName);
+ sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+ if (m.getName().equals(sb.toString())) {
+ return m;
+ }
+ }
+ throw new BuilderConfigException("no operation named " + operationName
+ + " found on service interface: "
+ + serviceInterface.getName());
+ }
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract,
+ org.apache.tuscany.spi.model.Operation operation) {
+
+ return new Axis2ServiceCallbackTargetInvoker(workContext, this);
+ }
+
+ public void addMapping(MessageId msgId, InvocationContext invCtx) {
+ this.invCtxMap.put(msgId, invCtx);
+ }
+
+ public InvocationContext retrieveMapping(MessageId msgId) {
+ return this.invCtxMap.get(msgId);
+ }
+
+ public void removeMapping(MessageId msgId) {
+ this.invCtxMap.remove(msgId);
+ }
+
+ protected class InvocationContext {
+ public MessageContext inMessageContext;
+
+ public org.apache.tuscany.spi.model.Operation<?> operation;
+
+ public SOAPFactory soapFactory;
+
+ public CountDownLatch doneSignal;
+
+ public InvocationContext(MessageContext messageCtx,
+ org.apache.tuscany.spi.model.Operation<?> operation,
+ SOAPFactory soapFactory,
+ CountDownLatch doneSignal) {
+ this.inMessageContext = messageCtx;
+ this.operation = operation;
+ this.soapFactory = soapFactory;
+ this.doneSignal = doneSignal;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
new file mode 100644
index 0000000000..ca7812e01b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.Utils;
+import org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext;
+import org.apache.tuscany.binding.axis2.Axis2AsyncTargetInvoker;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageId;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2ServiceCallbackTargetInvoker implements TargetInvoker {
+
+ private Axis2Service service;
+
+ private MessageId currentCorrelationId;
+
+ public Axis2ServiceCallbackTargetInvoker(WorkContext workContext, Axis2Service service) {
+ this.service = service;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ // Use current correlation id as index to retrieve inv context
+ InvocationContext invCtx = service.retrieveMapping(this.currentCorrelationId);
+
+ MessageContext outMC = Utils.createOutMessageContext(invCtx.inMessageContext);
+ outMC.getOperationContext().addMessageContext(outMC);
+
+ OMElement responseOM = null;
+ if (payload != null && !payload.getClass().isArray()) {
+ responseOM = (OMElement)payload;
+ } else {
+ responseOM = (OMElement)((Object[])payload)[0];
+ }
+ SOAPEnvelope soapEnvelope = invCtx.soapFactory.getDefaultEnvelope();
+ soapEnvelope.getBody().addChild(responseOM);
+ outMC.setEnvelope(soapEnvelope);
+ outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+
+ AxisEngine engine =
+ new AxisEngine(invCtx.inMessageContext.getOperationContext().getServiceContext().getConfigurationContext());
+ engine.send(outMC);
+
+ invCtx.doneSignal.countDown();
+
+ service.removeMapping(this.currentCorrelationId);
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ } catch(Throwable t) {
+ throw new Axis2BindingRunTimeException(t);
+ }
+
+ return Axis2AsyncTargetInvoker.RESPONSE;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ this.currentCorrelationId = (MessageId)msg.getCorrelationId();
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public Axis2ServiceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+ try {
+ return (Axis2ServiceCallbackTargetInvoker)super.clone();
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
new file mode 100644
index 0000000000..3b1b0d25e4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInMessageReceiver;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver {
+
+ protected Operation<?> operation;
+
+ private Axis2Service axis2Service;
+
+ public Axis2ServiceInMessageReceiver(Axis2Service service, Operation<?> operation) {
+ this.axis2Service = service;
+ this.operation = operation;
+ }
+
+ public Axis2ServiceInMessageReceiver() {
+
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+
+ axis2Service.invokeTarget(operation, args);
+
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new InvocationRuntimeException(e);
+ } catch (Throwable t) {
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new Axis2BindingRunTimeException(t);
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
new file mode 100644
index 0000000000..f83862399c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.MessageId;
+
+public class Axis2ServiceInOutAsyncMessageReceiver extends AbstractMessageReceiver {
+
+ private Operation<?> operation;
+
+ private WorkContext workContext;
+
+ private Axis2Service service;
+
+ public Axis2ServiceInOutAsyncMessageReceiver(Axis2Service service,
+ Operation operation,
+ WorkContext workContext) {
+ this.operation = operation;
+ this.workContext = workContext;
+ this.service = service;
+ }
+
+ public Axis2ServiceInOutAsyncMessageReceiver() {
+ }
+
+ public final void receive(final MessageContext messageCtx) {
+ try {
+ // Create a new message id and hand it to
+ // JDKInboundInvocationHandler
+ // via work context
+ MessageId messageId = new MessageId();
+ workContext.setCurrentMessageId(messageId);
+ // Now use message id as index to context to be used by callback
+ // target invoker
+ CountDownLatch doneSignal = new CountDownLatch(1);
+ InvocationContext invCtx =
+ service.new InvocationContext(messageCtx, operation, getSOAPFactory(messageCtx), doneSignal);
+ service.addMapping(messageId, invCtx);
+
+ invokeBusinessLogic(messageCtx);
+
+ try {
+ doneSignal.await();
+ } catch(InterruptedException e) {
+ e.printStackTrace();
+ }
+ } catch (AxisFault e) {
+ // log.error(e);
+ }
+ }
+
+ public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+ service.invokeTarget(operation, args);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new InvocationRuntimeException(e);
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
new file mode 100644
index 0000000000..4522632d9f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver {
+
+ protected Operation<?> operation;
+
+ private Axis2Service axis2Service;
+
+ public Axis2ServiceInOutSyncMessageReceiver(Axis2Service service, Operation<?> operation) {
+ this.axis2Service = service;
+ this.operation = operation;
+ }
+
+ public Axis2ServiceInOutSyncMessageReceiver() {
+
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+
+ OMElement responseOM = (OMElement)axis2Service.invokeTarget(operation, args);
+
+ SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
+ soapEnvelope.getBody().addChild(responseOM);
+ outMC.setEnvelope(soapEnvelope);
+ outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new InvocationRuntimeException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java
new file mode 100644
index 0000000000..cab5b28ee7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.transport.http.AxisServlet;
+
+/**
+ * This overrides the servlet init of the AxisServlet so Tuscany can use
+ * a single Axis2 ConfigurationContext instance shared between AxisServlet
+ * instances for each SCA service with a ws binding.
+ * TODO: need to review if thats really what we want to be doing
+ */
+public class Axis2ServiceServlet extends AxisServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final ServletConfig DUMMY_CONFIG = createDummyServletConfig();
+
+ private boolean inited;
+
+ public void init(ConfigurationContext configContext) {
+ this.configContext = configContext;
+ try {
+ super.init(DUMMY_CONFIG);
+ } catch (ServletException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * We've setup the Servlet by passing in a ConfigurationContext on our init method
+ * override this method to just return that
+ */
+ @Override
+ protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException {
+ return this.configContext;
+ }
+
+ /**
+ * The AxisServlet gets NPE during init without a ServletConfig so this is a mocked up one to prevent that.
+ */
+ private static ServletConfig createDummyServletConfig() {
+ ServletConfig sc = new ServletConfig() {
+
+ public String getServletName() {
+ return "TuscanyAxis2DummyServlet";
+ }
+
+ public ServletContext getServletContext() {
+ return new ServletContext() {
+
+ public ServletContext getContext(String uripath) {
+ return null;
+ }
+
+ public int getMajorVersion() {
+ return 0;
+ }
+
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ public String getMimeType(String file) {
+ return null;
+ }
+
+ public Set getResourcePaths(String path) {
+ return Collections.emptySet();
+ }
+
+ public URL getResource(String path) throws MalformedURLException {
+ if("/".equals(path)) {
+ // HACK: To avoid NPE
+ return new URL("/axis2");
+ }
+ return null;
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ return null;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return null;
+ }
+
+ public RequestDispatcher getNamedDispatcher(String arg0) {
+ return null;
+ }
+
+ public Servlet getServlet(String arg0) throws ServletException {
+ return null;
+ }
+
+ public Enumeration getServlets() {
+ return null;
+ }
+
+ public Enumeration getServletNames() {
+ return null;
+ }
+
+ public void log(String arg0) {
+ }
+
+ public void log(Exception arg0, String arg1) {
+ }
+
+ public void log(String arg0, Throwable arg1) {
+ }
+
+ public String getRealPath(String arg0) {
+ return null;
+ }
+
+ public String getServerInfo() {
+ return null;
+ }
+
+ public String getInitParameter(String arg0) {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames() {
+ return null;
+ }
+
+ public Object getAttribute(String arg0) {
+ return null;
+ }
+
+ public Enumeration getAttributeNames() {
+ return null;
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ }
+
+ public void removeAttribute(String arg0) {
+ }
+
+ public String getServletContextName() {
+ return null;
+ }
+ };
+ }
+
+ public String getInitParameter(String arg0) {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames() {
+ return new Vector().elements();
+ }
+ };
+ return sc;
+ }
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // HACK: Get the correct context root which is not available during init() call
+ if (!inited) {
+ synchronized (configContext) {
+ configContext.setContextRoot(request.getContextPath());
+ inited = true;
+ }
+ }
+ super.service(request, response);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
new file mode 100755
index 0000000000..175f995c76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Axis2TargetInvoker uses an Axis2 OperationClient to invoke a remote web service
+ */
+public class Axis2TargetInvoker implements TargetInvoker {
+
+ private QName wsdlOperationName;
+
+ private Options options;
+
+ private SOAPFactory soapFactory;
+
+ private ServiceClient serviceClient;
+
+ public Axis2TargetInvoker(ServiceClient serviceClient, QName wsdlOperationName, Options options,
+ SOAPFactory soapFactory) {
+ this.wsdlOperationName = wsdlOperationName;
+ this.options = options;
+ this.soapFactory = soapFactory;
+ this.serviceClient = serviceClient;
+ }
+
+ /**
+ * Invoke a WS operation
+ *
+ * @param payload
+ * @return
+ * @throws InvocationTargetException
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object[] args = (Object[]) payload;
+ OperationClient operationClient = createOperationClient(args);
+
+ operationClient.execute(true);
+
+ MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ return responseMC.getEnvelope().getBody().getFirstElement();
+
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ }
+
+ }
+
+ protected OperationClient createOperationClient(Object[] args) throws AxisFault {
+ SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+ if (args != null && args.length > 0) {
+ SOAPBody body = env.getBody();
+ for (Object bc : args) {
+ if (bc instanceof OMElement) {
+ body.addChild((OMElement) bc);
+ } else {
+ throw new IllegalArgumentException(
+ "Can't handle mixed payloads betweem OMElements and other types.");
+ }
+ }
+ }
+ MessageContext requestMC = new MessageContext();
+ requestMC.setEnvelope(env);
+ // Axis2 operationClients can not be shared so create a new one for each request
+ OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
+ operationClient.setOptions(options);
+ operationClient.addMessageContext(requestMC);
+ return operationClient;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public Axis2TargetInvoker clone() throws CloneNotSupportedException {
+ try {
+ return (Axis2TargetInvoker) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java
new file mode 100755
index 0000000000..6d4ec6eaf9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a Celtix binding configuration in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBinding extends Binding {
+
+ private Definition definition;
+ private Port port;
+ private Service service;
+ //private String portURI;
+ private String uri;
+ public WebServiceBinding(Definition definition, Port port, String uri, String portURI, Service service) {
+ this.definition = definition;
+ this.port = port;
+ this.uri = uri;
+ //this.portURI = portURI;
+ this.service = service;
+ }
+
+ public Port getWSDLPort() {
+ return port;
+ }
+
+ public Service getWSDLService() {
+ return service;
+ }
+
+ public void setWSDLPort(Port value) {
+ port = value;
+ }
+
+ public Definition getWSDLDefinition() {
+ return definition;
+ }
+
+ public void setWSDLDefinition(Definition def) {
+ definition = def;
+ }
+
+ // public void setPortURI(String uri) {
+ // portURI = uri;
+ // }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String theUri) {
+ this.uri = theUri;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java
new file mode 100755
index 0000000000..5535dbb5c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Parses a <code>WebServiceBinding</code> entry in an assembly XML file
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+@SuppressWarnings("deprecation")
+public class WebServiceBindingLoader extends LoaderExtension<WebServiceBinding> {
+ public static final QName BINDING_WS = new QName(XML_NAMESPACE_1_0, "binding.ws");
+
+ private WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ @Constructor( { "loaderRegistry", "wsdlDefinitionRegistry" })
+ public WebServiceBindingLoader(@Autowire LoaderRegistry loaderRegistry,
+ @Autowire WSDLDefinitionRegistry wsdlDefinitionRegistry) {
+ super(loaderRegistry);
+ this.wsdlDefinitionRegistry = wsdlDefinitionRegistry;
+ }
+
+ public QName getXMLType() {
+ return BINDING_WS;
+ }
+
+ public WebServiceBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ // not sure what uri was here ? String uri = reader.getAttributeValue(null, "uri");
+ String uri = null;
+ String endpoint = reader.getAttributeValue(null, "endpoint");
+ String wsdlLocation = reader.getAttributeValue(null, "location");
+ LoaderUtil.skipToEndElement(reader);
+ try {
+ return createBinding(uri, endpoint, wsdlLocation, deploymentContext);
+ } catch (Exception e) {
+ throw new LoaderException(e);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private WebServiceBinding createBinding(String uri, String endpoint, String wsdlLocation, DeploymentContext deploymentContext)
+ throws WSDLException, IOException, LoaderException {
+ // Get the WSDL port namespace and name
+ if (uri == null && endpoint != null) {
+ int h = endpoint.indexOf('#');
+ String serviceName;
+ String portName;
+
+ String namespace = endpoint.substring(0, h);
+ String fragment = endpoint.substring(h + 1);
+ if (fragment.startsWith("wsdl.endpoint(") && fragment.endsWith(")")) {
+ fragment = fragment.substring(14, fragment.length() - 1);
+ int slash = fragment.indexOf('/');
+ if (slash != -1) {
+ serviceName = fragment.substring(0, slash);
+ portName = fragment.substring(slash + 1);
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+ // FIXME need to find out how to get wsdl and what context to use --- terrible hack attack!
+ if (null == wsdlLocation) {
+ throw new Axis2BindingRunTimeException(
+ "Failed to determine wsdl location on binding. Try specifying 'location' attribute on binding.");
+ }
+ Definition definition =
+ wsdlDefinitionRegistry.loadDefinition(namespace+" "+wsdlLocation, deploymentContext.getClassLoader());
+
+ Port thePort = null;
+ Service service = null;
+ // Find the port with the given name
+ for (Service serv : (Collection<Service>) definition.getServices().values()) {
+ QName sqn = serv.getQName();
+ if (serviceName != null && !serviceName.equals(sqn.getLocalPart())) {
+ continue;
+ }
+
+ Port p = serv.getPort(portName);
+ if (p != null) {
+ service = serv;
+ thePort = p;
+ break;
+ }
+ }
+ if (thePort == null) {
+ throw new IllegalArgumentException("Cannot find WSDL port " + endpoint);
+
+ }
+ return new WebServiceBinding(definition, thePort, uri, endpoint, service);
+ }
+ // FIXME: Find the first port?
+ throw new LoaderException("Web Service endpoint cannot be resolved: " + endpoint);
+
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java
new file mode 100755
index 0000000000..c0ef46fee3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.axis2.engine.AxisConfigurator;
+
+/**
+ * Helps configure Axis2 from a resource in binding.axis2 instead of Axis2.xml
+ * <p/> TODO: Review: should there be a single global Axis
+ * ConfigurationContext
+ */
+public class TuscanyAxisConfigurator extends URLBasedAxisConfigurator implements AxisConfigurator {
+
+ public TuscanyAxisConfigurator() throws AxisFault {
+ super(TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/binding/axis2/engine/config/axis2.xml"), null);
+ }
+
+ public ConfigurationContext getConfigurationContext() throws AxisFault {
+ if (configContext == null)
+ configContext = ConfigurationContextFactory.createConfigurationContext(this);
+ return configContext;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java
new file mode 100755
index 0000000000..2a453bdf15
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java
@@ -0,0 +1,491 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2.util;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPHeader;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.xml.namespace.QName;
+
+/**
+ * Metadata for a WSDL operation
+ */
+@SuppressWarnings({"all"})
+public class WebServiceOperationMetaData implements Serializable {
+ private static final long serialVersionUID = 2425306250256227724L;
+
+ // WSDL Binding and BindingOperation
+ private Binding binding;
+ private BindingOperation bindingOperation;
+ // Fields to cache derived metadata
+ private transient Set<Part> inputHeaderParts;
+ private transient Set<Part> outputHeaderParts;
+ private transient String style;
+ private transient String use;
+ private transient String soapAction;
+ private transient List<Object> signature;
+ private String encoding;
+ private transient QName rpcOperationName;
+
+ public WebServiceOperationMetaData(Binding binding, BindingOperation bindingOperation) {
+ this.binding = binding;
+ this.bindingOperation = bindingOperation;
+ }
+
+ public WebServiceOperationMetaData(Binding binding, BindingOperation bindingOperation, String style, String use,
+ String encoding,
+ String soapAction) {
+ this.binding = binding;
+ this.bindingOperation = bindingOperation;
+ this.style = style;
+ this.use = use;
+ this.encoding = encoding;
+ this.soapAction = soapAction;
+ }
+
+ public Set<Part> getInputHeaderParts() {
+ if (inputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ inputHeaderParts = new HashSet<Part>();
+ BindingInput bindingInput = bindingOperation.getBindingInput();
+
+ if (bindingInput != null) {
+ Operation operation = bindingOperation.getOperation();
+ javax.wsdl.Message message = operation.getInput().getMessage();
+ List elements = bindingInput.getExtensibilityElements();
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object extensibilityElement = i.next();
+ Part part = getPartFromSOAPHeader(message, extensibilityElement);
+ if (part != null) {
+ inputHeaderParts.add(part);
+ }
+ }
+ }
+ }
+ return inputHeaderParts;
+ }
+
+ public Set<Part> getOutputHeaderParts() {
+ if (outputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ outputHeaderParts = new HashSet<Part>();
+ BindingOutput bindingOutput = bindingOperation.getBindingOutput();
+
+ if (bindingOutput != null) {
+ Operation operation = bindingOperation.getOperation();
+ javax.wsdl.Message message = operation.getOutput().getMessage();
+ List elements = bindingOutput.getExtensibilityElements();
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object extensibilityElement = i.next();
+ Part part = getPartFromSOAPHeader(message, extensibilityElement);
+ if (part != null) {
+ outputHeaderParts.add(part);
+ }
+ }
+ }
+ }
+ return outputHeaderParts;
+ }
+
+ private Part getPartFromSOAPHeader(Message message, Object extensibilityElement) {
+ Part part = null;
+ if (extensibilityElement instanceof SOAPHeader) {
+ SOAPHeader soapHeader = (SOAPHeader) extensibilityElement;
+ QName msgName = soapHeader.getMessage();
+ if (message.getQName().equals(msgName)) {
+ part = message.getPart(soapHeader.getPart());
+ }
+ } else if (extensibilityElement instanceof SOAPHeader) {
+ SOAPHeader soapHeader = (SOAPHeader) extensibilityElement;
+ QName msgName = soapHeader.getMessage();
+ if (message.getQName().equals(msgName)) {
+ part = message.getPart(soapHeader.getPart());
+ }
+ }
+ return part;
+ }
+
+ public String getStyle() {
+ if (style == null) {
+ SOAPOperation soapOperation = (SOAPOperation) WebServicePortMetaData
+ .getExtensibilityElement(bindingOperation.getExtensibilityElements(),
+ SOAPOperation.class);
+ if (soapOperation != null) {
+ style = soapOperation.getStyle();
+ }
+ if (style == null) {
+ SOAPBinding soapBinding = WebServicePortMetaData
+ .getExtensibilityElement(binding.getExtensibilityElements(), SOAPBinding.class);
+ if (soapBinding != null) {
+ style = soapBinding.getStyle();
+ }
+ }
+ if (style == null) {
+ style = "document";
+ }
+ }
+ return style;
+ }
+
+ /**
+ * Returns the SOAP action for the given operation.
+ */
+ public String getSOAPAction() {
+ if (soapAction == null) {
+ final List wsdlBindingOperationExtensions = bindingOperation.getExtensibilityElements();
+ final SOAPOperation soapOp =
+ WebServicePortMetaData.getExtensibilityElement(wsdlBindingOperationExtensions, SOAPOperation.class);
+ if (soapOp != null) {
+ soapAction = soapOp.getSoapActionURI();
+ }
+ }
+ return soapAction;
+ }
+
+ public QName getRPCOperationName() {
+ if (rpcOperationName == null) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
+ String ns =
+ (soapBody != null) ? soapBody.getNamespaceURI() : binding.getPortType().getQName().getNamespaceURI();
+ String name = bindingOperation.getOperation().getName();
+ rpcOperationName = new QName(ns, name);
+ }
+ return rpcOperationName;
+ }
+
+ private List<String> getSOAPBodyParts(boolean input) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(input);
+ if (soapBody != null) {
+ List parts = soapBody.getParts();
+ if (parts != null) {
+ List<String> names = new ArrayList<String>();
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Object part = i.next();
+ if (part instanceof String) {
+ names.add((String) part);
+ } else if (part instanceof Part) {
+ names.add(((Part) part).getName());
+ }
+ }
+ return names;
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ private javax.wsdl.extensions.soap.SOAPBody getSOAPBody(boolean input) {
+ List elements = null;
+ if (input) {
+ BindingInput bindingInput = bindingOperation.getBindingInput();
+ if (bindingInput == null) {
+ return null;
+ }
+ elements = bindingInput.getExtensibilityElements();
+ } else {
+ BindingOutput bindingOutput = bindingOperation.getBindingOutput();
+ if (bindingOutput == null) {
+ return null;
+ }
+ elements = bindingOutput.getExtensibilityElements();
+ }
+ javax.wsdl.extensions.soap.SOAPBody soapBody = WebServicePortMetaData.getExtensibilityElement(elements,
+ javax.wsdl.extensions.soap.SOAPBody.class);
+ return soapBody;
+ }
+
+ /**
+ * Returns the use attribute
+ */
+ public String getUse() {
+ if (use == null) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
+ if (soapBody != null) {
+ use = soapBody.getUse();
+ }
+ if (use == null) {
+ use = "literal";
+ }
+ }
+ return use;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getEncoding() {
+ if (encoding == null) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
+ if (soapBody != null) {
+ List<String> styles = (List<String>) soapBody.getEncodingStyles();
+ if (styles != null && !styles.isEmpty()) {
+ encoding = styles.get(0);
+ }
+ }
+ if (encoding == null) {
+ encoding = "";
+ }
+ }
+ return encoding;
+ }
+
+ public boolean isDocLitWrapped() {
+ boolean flag = getStyle().equals("document") && getUse().equals("literal");
+ if (!flag) {
+ return false;
+ }
+ Message msg = getMessage(true);
+ if (msg == null) {
+ return false;
+ }
+ List parts = msg.getOrderedParts(null);
+ if (parts.size() != 1) {
+ return false;
+ }
+ Part part = (Part) parts.get(0);
+ QName element = part.getElementName();
+ if (element == null) {
+ return false;
+ }
+ return element.getLocalPart().equals(bindingOperation.getOperation().getName());
+ }
+
+ /*
+ * public SOAPMediator createMediator(boolean serverMode) throws SOAPException {
+ * // create a new mediator for each invoke for thread-safety
+ * boolean rpcStyle = getStyle().equals("rpc"); boolean rpcEncoded = isEncoded();
+ *
+ * SOAPMediator mediator = null;
+ *
+ * if (!rpcStyle) { // Document mediator = new SOAPDocumentLiteralMediatorImpl(this, serverMode);
+ * } else { if (!rpcEncoded) mediator = new
+ * SOAPRPCLiteralMediatorImpl(this, serverMode); // RPC-literal else mediator =
+ * new SOAPRPCEncodedMediatorImpl(this, serverMode); // RPC-encoded }
+ * return mediator; }
+ */
+
+ /**
+ * Get the operation signature from the WSDL operation
+ */
+ public List<?> getOperationSignature() {
+ if (signature == null) {
+ signature = new ArrayList<Object>();
+
+ Operation operation = bindingOperation.getOperation();
+ if (operation == null) {
+ return signature;
+ }
+
+ final Input input = operation.getInput();
+ if (input == null) {
+ return signature;
+ }
+
+ String sstyle = getStyle();
+
+ if ("rpc".equals(sstyle)) {
+ Collection partNames = input.getMessage().getParts().values();
+ for (Iterator i = partNames.iterator(); i.hasNext();) {
+ Part part = (Part) i.next();
+ signature.add(part.getName());
+ }
+ } else {
+ /*
+ * WS-I Basic Profile 1.1 4.7.6 Operation Signatures Definition: operation signature
+ *
+ * The profile defines the "operation signature" to be the fully qualified name of the child element of
+ * SOAP body of the SOAP input
+ * message described by an operation in a WSDL binding.
+ *
+ * In the case of rpc-literal binding, the operation name is used as a wrapper for the part accessors.
+ * In the document-literal case, designed so that they meet this requirement.
+ *
+ * An endpoint that supports multiple operations must unambiguously identify the operation being
+ * invoked based on the input message
+ * that it receives. This is only possible if all the operations specified in the wsdl:binding
+ * associated with an endpoint have a
+ * unique operation signature.
+ *
+ * R2710 The operations in a wsdl:binding in a DESCRIPTION MUST result in operation signatures that are
+ * different from one another.
+ */
+ List<String> bodyParts = getSOAPBodyParts(true);
+
+ Collection<?> parts = input.getMessage().getParts().values();
+ // Exclude the parts to be transmitted in SOAP header
+ if (bodyParts == null) {
+ parts.removeAll(getInputHeaderParts());
+ }
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Part part = (Part) i.next();
+ if (bodyParts == null) {
+ // All parts
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ elementName = new QName("", part.getName());
+ // TODO: [rfeng] throw new
+ // ServiceRuntimeException("Message part for
+ // document style must refer to an XSD element
+ // using a QName: " + part);
+ }
+ signature.add(elementName);
+ } else {
+ // "parts" in soap:body
+ if (bodyParts.contains(part.getName())) {
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ elementName = new QName("", part.getName());
+ // TODO: [rfeng] throw new
+ // ServiceRuntimeException("Message part for
+ // document style must refer to an XSD
+ // element using a QName: " + part);
+ }
+ signature.add(elementName);
+ }
+
+ }
+ }
+ }
+ }
+ return signature;
+ }
+
+ public Message getMessage(boolean isInput) {
+ Operation operation = bindingOperation.getOperation();
+ if (operation == null) {
+ return null;
+ }
+
+ if (isInput) {
+ final Input input = operation.getInput();
+ return input == null ? null : input.getMessage();
+ } else {
+ final Output output = operation.getOutput();
+ return output == null ? null : output.getMessage();
+ }
+ }
+
+ public Part getInputPart(int index) {
+ Part part = null;
+ Message message = getMessage(true);
+ if (message == null) {
+ return part;
+ }
+
+ List parts = message.getOrderedParts(null);
+ return (Part) parts.get(index);
+
+ }
+
+ public Part getOutputPart(int index) {
+ Part part = null;
+ Message message = getMessage(false);
+ if (message == null) {
+ return part;
+ }
+
+ List parts = message.getOrderedParts(null);
+ return (Part) parts.get(index);
+
+ }
+
+ /**
+ * Get a list of indexes for each part in the SOAP body
+ *
+ * @param isInput
+ */
+ public List<Integer> getBodyPartIndexes(boolean isInput) {
+ List<Integer> indexes = new ArrayList<Integer>();
+
+ Message message = getMessage(isInput);
+ if (message == null) {
+ return indexes;
+ }
+
+ List<String> bodyParts = getSOAPBodyParts(isInput);
+ List parts = message.getOrderedParts(null);
+ Set headerParts = isInput ? getInputHeaderParts() : getOutputHeaderParts();
+
+ int index = 0;
+ for (Iterator i = parts.iterator(); i.hasNext(); index++) {
+ Part part = (Part) i.next();
+ if (headerParts.contains(part)) {
+ continue;
+ }
+ if (bodyParts == null) {
+ // All parts
+ indexes.add(index);
+ } else {
+ // "parts" in soap:body
+ if (bodyParts.contains(part.getName())) {
+ indexes.add(index);
+ }
+ }
+ }
+ return indexes;
+ }
+
+ /**
+ * Get the corresponding index for a part in the SOAP header by element name
+ *
+ * @param elementName
+ * @param isInput
+ */
+ public int getHeaderPartIndex(QName elementName, boolean isInput) {
+
+ Message message = getMessage(isInput);
+ if (message == null) {
+ return -1;
+ }
+
+ List parts = message.getOrderedParts(null);
+ Set headerParts = isInput ? getInputHeaderParts() : getOutputHeaderParts();
+
+ int index = 0;
+ for (Iterator i = parts.iterator(); i.hasNext(); index++) {
+ Part part = (Part) i.next();
+ // Test if the part is in header section
+ if (headerParts.contains(part) && elementName.equals(part.getElementName())) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ public BindingOperation getBindingOperation() {
+ return bindingOperation;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java
new file mode 100755
index 0000000000..a8d4f0f581
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+
+/**
+ * Metadata for a WSDL port
+ *
+ */
+public class WebServicePortMetaData {
+
+ private Service wsdlService;
+ private QName wsdlServiceName;
+ private Port wsdlPort;
+ private Binding wsdlBinding;
+ private QName wsdlPortName;
+ private PortType wsdlPortType;
+ private QName wsdlPortTypeName;
+ private String endpoint;
+ private boolean managed;
+ private List<WebServiceOperationMetaData> allOperationMetaData;
+ private WSDLServiceContract interfaceType;
+
+ /**
+ * Constructor
+ *
+ * @param wsdlDefinition
+ */
+ public WebServicePortMetaData(Definition wsdlDefinition, Port wsdlPort, String endpoint, boolean managed) {
+
+ // Lookup the named port
+ this.wsdlPort = wsdlPort;
+ wsdlPortName = new QName(wsdlDefinition.getTargetNamespace(), wsdlPort.getName());
+ Collection services = wsdlDefinition.getServices().values();
+ for (Object serviceObj : services) {
+ Service service = (Service) serviceObj;
+ if (service.getPorts().containsValue(wsdlPort)) {
+ wsdlService = service;
+ wsdlServiceName = service.getQName();
+ break;
+ }
+ }
+
+ // Save the binding
+ wsdlBinding = wsdlPort.getBinding();
+ if (wsdlBinding == null) {
+ throw new IllegalArgumentException("WSDL binding cannot be found for " + wsdlPortName);
+ }
+
+ // Save the portType
+ wsdlPortType = wsdlBinding.getPortType();
+ if (wsdlPortType == null) {
+ throw new IllegalArgumentException("WSDL portType cannot be found for " + wsdlPortName);
+ }
+ wsdlPortTypeName = wsdlPortType.getQName();
+
+ // Save the endpoint
+ this.endpoint = endpoint;
+
+ // Track if this endpoint is managed or not
+ this.managed = managed;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param serviceName
+ * @param portName
+ * @param portTypeName
+ * @param endpoint
+ */
+ public WebServicePortMetaData(QName serviceName, String portName, QName portTypeName, String endpoint) {
+ wsdlServiceName = serviceName;
+ wsdlPortName = new QName(serviceName.getNamespaceURI(), portName);
+ wsdlPortTypeName = portTypeName;
+ this.endpoint = endpoint;
+ }
+
+ /**
+ * @return Returns the wsdlPort.
+ */
+ public javax.wsdl.Port getPort() {
+ return wsdlPort;
+ }
+
+ /**
+ * @return Returns the wsdlService.
+ */
+ public QName getServiceName() {
+ return wsdlServiceName;
+ }
+
+ /**
+ * @return Returns the wsdlService.
+ */
+ public javax.wsdl.Service getService() {
+ return wsdlService;
+ }
+
+ /**
+ * @return Returns the wsdlPortType.
+ */
+ public PortType getPortType() {
+ return wsdlPortType;
+ }
+
+ /**
+ * @return Returns the wsdlPortType.
+ */
+ public QName getPortTypeName() {
+ return wsdlPortTypeName;
+ }
+
+ /**
+ * @return Returns the wsdlBinding.
+ */
+ public Binding getBinding() {
+ return wsdlBinding;
+ }
+
+ /**
+ * @return Returns the wsdlPortName.
+ */
+ public QName getPortName() {
+ return wsdlPortName;
+ }
+
+ /**
+ * Returns the endpoint of a given port.
+ */
+ public String getEndpoint() {
+
+ // Return the specified endpoint
+ if (endpoint != null) {
+ return endpoint;
+ }
+
+ // Find the target endpoint on the port
+ if (wsdlPort != null) {
+ final List wsdlPortExtensions = wsdlPort.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the SOAP binding style.
+ */
+ public String getStyle() {
+
+ // Find the binding style
+ String style = null;
+ if (wsdlBinding != null) {
+ final List wsdlBindingExtensions = wsdlBinding.getExtensibilityElements();
+ SOAPBinding soapBinding = getExtensibilityElement(wsdlBindingExtensions, SOAPBinding.class);
+ if (soapBinding != null) {
+ style = soapBinding.getStyle();
+ }
+ }
+
+ // Default to document
+ return (style == null) ? "document" : style;
+ }
+
+ /**
+ * Returns the use attribute
+ */
+ public String getUse() {
+ List<WebServiceOperationMetaData> list = getAllOperationMetaData();
+ return list.get(0).getUse();
+ }
+
+ /**
+ * Returns the encoding attribute
+ */
+ public String getEncoding() {
+ List<WebServiceOperationMetaData> list = getAllOperationMetaData();
+ return list.get(0).getEncoding();
+ }
+
+ /**
+ * @return Returns true if this is a managed web service.
+ */
+ public boolean isManaged() {
+ return managed;
+ }
+
+ /**
+ * Returns the first extensibility element of the given type.
+ *
+ * @param elements
+ * @param type
+ */
+ public static <T> T getExtensibilityElement(List elements, Class<T> type) {
+ for (Object element : elements) {
+ if (type.isInstance(element)) {
+ return type.cast(element);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the extensibility elements of the given type.
+ *
+ * @param elements
+ * @param type
+ * @return List
+ */
+ public static <T> List<T> getExtensibilityElements(List elements, Class<T> type) {
+ List<T> result = new ArrayList<T>();
+ for (Object element : elements) {
+ if (type.isInstance(element)) {
+ result.add(type.cast(element));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the operation signature from the SOAP Body
+ *
+ * @return A list of QNames
+ */
+ // public static List getOperationSignature(javax.xml.soap.SOAPBody body) {
+ // List signature = new ArrayList();
+ // for (Iterator i = body.getChildElements(); i.hasNext();) {
+ // Object child = i.next();
+ // if (child instanceof SOAPBodyElement) {
+ // Name name = ((SOAPBodyElement) child).getElementName();
+ // QName qname = new QName(name.getURI(), name.getLocalName(), name.getPrefix());
+ // signature.add(qname);
+ // }
+ // }
+ // return signature;
+ // }
+ // public static List getRPCOperationSignature(javax.xml.soap.SOAPBody body) {
+ // List signature = new ArrayList();
+ // for (Iterator i = body.getChildElements(); i.hasNext();) {
+ // Object child = i.next();
+ // if (child instanceof SOAPBodyElement) {
+ // SOAPBodyElement op = ((SOAPBodyElement) child);
+ // for (Iterator j = op.getChildElements(); j.hasNext();) {
+ // Object part = i.next();
+ // if (part instanceof SOAPElement) {
+ // SOAPElement p = (SOAPElement) part;
+ // signature.add(p.getLocalName());
+ // }
+ // }
+ // }
+ // }
+ // return signature;
+ // }
+ // public WebServiceOperationMetaData getOperationMetaData(javax.xml.soap.SOAPBody body) {
+ // List s1 = getOperationSignature(body);
+ // // List rpcParts = getRPCOperationSignature(body);
+ // for (Iterator it = getAllOperationMetaData().iterator(); it.hasNext();) {
+ // WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) it.next();
+ //
+ // String style = descriptor.getStyle();
+ //
+ // if (style.equals("document")) {
+ // List s2 = descriptor.getOperationSignature();
+ // if (s1.equals(s2))
+ // return descriptor;
+ // } else {
+ // QName op1 = (QName) s1.get(0);
+ // QName op2 = descriptor.getRPCOperationName();
+ // if (op1.equals(op2)) {
+ // /*
+ // * // FIXME: [rfeng] We don't support method overloading
+ // * List partNames = getOperationSignature(binding,
+ // * bindingOperation); if (rpcParts.equals(partNames))
+ // */
+ // return descriptor;
+ // }
+ // }
+ // }
+ // return null;
+ // }
+ public List<WebServiceOperationMetaData> getAllOperationMetaData() {
+ if (allOperationMetaData == null) {
+ allOperationMetaData = new ArrayList<WebServiceOperationMetaData>();
+ for (Iterator it = wsdlBinding.getBindingOperations().iterator(); it.hasNext();) {
+ final BindingOperation bindingOperation = (BindingOperation) it.next();
+ if (bindingOperation.getOperation() != null) {
+ allOperationMetaData.add(new WebServiceOperationMetaData(wsdlBinding, bindingOperation));
+ }
+ }
+ }
+ return allOperationMetaData;
+ }
+
+ public WebServiceOperationMetaData getOperationMetaData(String operationName) {
+ StringBuilder sb = new StringBuilder(operationName);
+ sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
+ String capatalizedOpName = sb.toString();
+
+ for (WebServiceOperationMetaData webServiceOperationMetaData : getAllOperationMetaData()) {
+ WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) webServiceOperationMetaData;
+ String opName = descriptor.getBindingOperation().getOperation().getName();
+
+ if (opName.equals(operationName) || opName.equals(capatalizedOpName)) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the WSDL service contract
+ *
+ * @return WSDLServiceContract
+ */
+ public WSDLServiceContract getInterfaceType() {
+ return interfaceType;
+ }
+
+ /**
+ * Get the WSDL operation name for a Java method name
+ */
+ public String getWSDLOperationName(String methodName) {
+ StringBuilder sb = new StringBuilder(methodName);
+ sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
+ String capatalizedOpName = sb.toString();
+ for (Object o : wsdlPortType.getOperations()) {
+ Operation operation = (Operation) o;
+ String wsdlOpName = operation.getName();
+ if (wsdlOpName.equals(methodName)) {
+ return wsdlOpName;
+ }
+ if (wsdlOpName.equals(capatalizedOpName)) {
+ return wsdlOpName;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl
new file mode 100644
index 0000000000..0eb56942f8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Axis2 based WebService binding extension -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.axis2.include">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.bindings</group>
+ <name>axis2</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="webservice.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader" />
+ </component>
+
+ <component name="webservice.axis2.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder" />
+ </component>
+
+ <!-- A workaround to handle inter-extension dependencies -->
+ <include name="idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl" />
+ <include name="databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl" />
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..d14e850caf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- Axis2 based WebService binding extension -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.axis2.WebServiceBinding">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.bindings</group>
+ <name>axis2</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="webservice.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader"/>
+ </component>
+
+ <component name="webservice.axis2.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder"/>
+ </component>
+
+ <!-- A workaround to handle inter-extension dependencies -->
+ <include name="idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl"/>
+ <include name="databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl"/>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml
new file mode 100755
index 0000000000..84c86d6dfb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml
@@ -0,0 +1,302 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">false</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">false</parameter>
+ <parameter name="enableSwA" locked="false">false</parameter>
+
+ <!--Uncomment if you want to enable file caching for attachments -->
+ <!--parameter name="cacheAttachments" locked="false">true</parameter>
+ <parameter name="attachmentDIR" locked="false"></parameter>
+ <parameter name="sizeThreshold" locked="false">4000</parameter-->
+
+ <!--This will give out the timout of the configuration contexts, in seconds-->
+ <parameter name="ConfigContextTimeoutInterval" locked="false">30</parameter>
+
+ <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+ <!--that behaviour.-->
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!--If there aren't any information available to find out the fault reason, we set the message of the expcetion-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason" locked="false">false</parameter>
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
+ <!--<parameter name="contextRoot" locked="false">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distingiush those endpoints-->
+ <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+ <!--context path to proper Axis2 servlets-->
+ <!--<parameter name="servicePath" locked="false">services</parameter>-->
+ <!--<parameter name="restPath" locked="false">rest</parameter>-->
+
+
+ <!--Set the flag to true if you want to enable transport level session mangment-->
+ <parameter name="manageTransportSession" locked="false">false</parameter>
+
+ <!--Following two parameters will be used to handle REST in Axis2. The default settings will make Axis2 to have two-->
+ <!--different endpoints, one for REST (AxisRESTServlet) one for SOAP message handling (AxisServlet). But following-->
+ <!--parameters help to tweak the message handling of two main servlets. -->
+
+ <!-- If the enableRESTInAxis2MainServlet is true, then Axis2MainServlet will handle both SOAP and REST messages -->
+ <parameter name="enableRESTInAxis2MainServlet" locked="true">false</parameter>
+
+ <!-- Following parameter will completely disable REST handling in both the servlets-->
+ <parameter name="disableREST" locked="true">false</parameter>
+
+ <!-- This will disable the separate servlet we have for REST handling. -->
+ <parameter name="disableSeparateEndpointForREST" locked="true">false</parameter>
+
+ <!-- If you have a frontend host which exposes this webservice using a different public URL -->
+ <!-- use this parameter to override autodetected url -->
+ <!--<parameter name="httpFrontendHostUrl" locked="false">https://someotherhost/context</parameter>-->
+
+
+ <!-- The way of adding listener to the system-->
+ <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
+ <!-- <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+ <!-- </listener>-->
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.tuscany.binding.axis2.Axis2ServiceInMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.tuscany.binding.axis2.Axis2ServiceInOutAsyncMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.tuscany.binding.axis2.Axis2ServiceInOutSyncMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!-- Here is the complete list of supported parameters (see example settings further below):
+ port: the port to listen on (default 6060)
+ hostname: if non-null, url prefix used in reply-to endpoint references (default null)
+ originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
+ requestTimeout: value in millis of time that requests can wait for data (default 20000)
+ requestTcpNoDelay: true to maximize performance and minimize latency (default true)
+ false to minimize bandwidth consumption by combining segments
+ requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
+ requestMaxThreadPoolSize: number of threads available for request processing if queue fills us (default 150)
+ note that default queue never fills up: see HttpFactory
+ threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
+ note that no such threads can exist with default unbounded request queue
+ threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
+ -->
+ <!-- <parameter name="hostname" locked="false">http://www.myApp.com/ws</parameter> -->
+ <!-- <parameter name="originServer" locked="false">My-Server/1.1</parameter> -->
+ <!-- <parameter name="requestTimeout" locked="false">10000</parameter> -->
+ <!-- <parameter name="requestTcpNoDelay" locked="false">false</parameter> -->
+ <!-- <parameter name="requestCoreThreadPoolSize" locked="false">50</parameter> -->
+ <!-- <parameter name="RequestMaxThreadPoolSize" locked="false">100</parameter> -->
+ <!-- <parameter name="threadKeepAliveTime" locked="false">240000</parameter> -->
+ <!-- <parameter name="threadKeepAliveTimeUnit" locked="false">MILLISECONDS</parameter> -->
+ </transportReceiver>
+
+ <!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)
+ <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
+ <parameter name="myTopicConnectionFactory" locked="false">
+ <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
+ </parameter>
+
+ <parameter name="myQueueConnectionFactory" locked="false">
+ <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+ </parameter>
+
+ <parameter name="default" locked="false">
+ <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+ </parameter>
+ </transportReceiver>-->
+
+ <!--Uncomment if you want to have SMTP transport support-->
+ <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
+ <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
+ <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
+ <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
+ <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
+ <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
+ <!--</transportReceiver>-->
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- Commented out by Tuscany
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ -->
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+ <parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+ <parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+ </transportSender>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Comment this to disable Addressing -->
+ <!-- Commented out by Tuscany
+ <module ref="addressing"/>
+ -->
+
+ <!--Configuring module , providing parameters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="InFlow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+ <phaseOrder type="InFaultFlow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFaultFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java
new file mode 100755
index 0000000000..9605c50c51
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+import org.easymock.EasyMock;
+import org.xml.sax.InputSource;
+
+public class Axis2ReferenceTestCase extends TestCase {
+
+ public void testInvokeService() throws Exception {
+ Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+ Operation operation = new Operation<Type>("sayHi", null, null, null, false, null);
+ TargetInvoker targetInvoker = axis2Reference.createTargetInvoker(null, operation);
+ assertNotNull(targetInvoker);
+ }
+
+ public void testAsyncTargetInvoker() throws Exception {
+ Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+ //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
+ InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+ contract.setCallbackClass(GreetingCallback.class);
+ Operation<Type> callbackOp = new Operation<Type>("sayHiCallback", null, null, null, true, null);
+ HashMap<String,Operation<Type>> callbackOps = new HashMap<String,Operation<Type>>();
+ callbackOps.put("sayHiCallback", callbackOp);
+ contract.setCallbackOperations(callbackOps);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.replay(inboundWire);
+
+ axis2Reference.setInboundWire(inboundWire);
+ Operation operation = new Operation<Type>("sayHi", null, null, null, true, null);
+ TargetInvoker asyncTargetInvoker = axis2Reference.createAsyncTargetInvoker(null, operation);
+ assertNotNull(asyncTargetInvoker);
+ }
+
+ private Axis2Reference createAxis2Reference(String webAppName, String serviceName) throws Exception {
+ //Create WebServiceBinding
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+ "SOAPService"));
+ Port port = wsdlService.getPort("SoapPort");
+ WebServiceBinding wsBinding = new WebServiceBinding(wsdlDef, port, "uri", "portURI", wsdlService);
+ //Create a mocked WireService, make the call of ServiceExtension.getServiceInstance() returns a proxy instance.
+ WireService wireService = EasyMock.createNiceMock(WireService.class);
+ EasyMock.replay(wireService);
+ CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
+ // TODO figure out what to do with the service contract
+ ServiceContract<?> contract = new WSDLServiceContract();
+ contract.setInterfaceClass(Greeter.class);
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ return new Axis2Reference(serviceName,
+ parent,
+ wireService,
+ wsBinding,
+ contract,
+ workContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
new file mode 100755
index 0000000000..6669226547
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.Servlet;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.xml.sax.InputSource;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+public class Axis2ServiceTestCase extends TestCase {
+
+ public void testInvokeService() throws Exception {
+ TestServletHost tomcatHost = new TestServletHost();
+ Axis2Service axis2Service = createAxis2Service("testServiceName", tomcatHost, false);
+ axis2Service.start();
+
+ if (true) return;
+ Servlet servlet = tomcatHost.getMapping("testWebAppName/services/testServiceName");
+ assertNotNull(servlet);
+
+ //Create mocked HttpRequest and HttpResponse object to test the Axis2Servlet
+ //To be done:
+
+ }
+
+ public void testAsyncMessageReceiver() throws Exception {
+
+ TestServletHost tomcatHost = new TestServletHost();
+ Axis2Service axis2Service = createAxis2Service("testServiceName", tomcatHost, true);
+ axis2Service.start();
+ }
+
+ private Axis2Service createAxis2Service(String serviceName, ServletHost tomcatHost, boolean callback)
+ throws Exception {
+ //Create WebServiceBinding
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+ "SOAPService"));
+ Port port = wsdlService.getPort("SoapPort");
+ WebServiceBinding wsBinding = new WebServiceBinding(wsdlDef, port, "uri", "portURI", wsdlService);
+
+ //Create a mocked WireService, make the call of ServiceExtension.getServiceInstance() returns a proxy instance.
+ WireService wireService = EasyMock.createNiceMock(WireService.class);
+ wireService.createProxy(EasyMock.isA(InboundWire.class));
+ EasyMock.expectLastCall().andReturn(null);
+ EasyMock.replay(wireService);
+
+ //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
+ InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+ Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>();
+ for(Method m: Greeter.class.getMethods()) {
+ opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null));
+ }
+ contract.setOperations(opMap);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ if (callback) {
+ contract.setCallbackName("");
+ }
+ EasyMock.replay(inboundWire);
+
+ OutboundWire outboundWire = EasyMock.createNiceMock(OutboundWire.class);
+ Map<Operation<?>, OutboundInvocationChain> map = new HashMap<Operation<?>, OutboundInvocationChain>();
+ EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once();
+ EasyMock.replay(outboundWire);
+
+ TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+ ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ Axis2Service axis2Service =
+ new Axis2Service(serviceName,
+ contract,
+ null,
+ wireService,
+ wsBinding,
+ tomcatHost,
+ configurationContext,
+ workContext);
+ axis2Service.setInboundWire(inboundWire);
+ axis2Service.setOutboundWire(outboundWire);
+
+ return axis2Service;
+ }
+
+ protected class TestServletHost implements ServletHost {
+ private Map<String, Servlet> mappings = new HashMap<String, Servlet>();
+
+ public void registerMapping(String mapping, Servlet servlet) {
+ mappings.put(mapping, servlet);
+ }
+
+ public void unregisterMapping(String mapping) {
+ }
+
+ public Servlet getMapping(String mapping) {
+ return mappings.get(mapping);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java
new file mode 100755
index 0000000000..39fccdadd3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+public interface Greeter {
+
+ String sayHi();
+
+ String greetMe(String requestType);
+
+ void greetMeOneWay(String requestType);
+
+ void greetMeWithCallback(String requestType);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java
new file mode 100644
index 0000000000..4c3b3304ea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+public interface GreetingCallback {
+
+ void greetMeCallback(String greetMeResponse);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl
new file mode 100755
index 0000000000..2f56217f88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeWithCallback">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeWithCallback">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle
new file mode 100644
index 0000000000..a2af63613f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd
new file mode 100644
index 0000000000..3e1ff77730
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd>
+ <useProjectRuleSet>true</useProjectRuleSet>
+ <rules/>
+</pmd>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset
new file mode 100644
index 0000000000..0933c1569c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt
new file mode 100644
index 0000000000..9b26d1690a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml
new file mode 100644
index 0000000000..0a71a1e338
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>celtix</artifactId>
+ <name>Apache Tuscany Binding for Celtix</name>
+ <description>Implementation of the SCA Web Services binding using Celtix.</description>
+
+ <properties>
+ <celtix.version>1.0</celtix.version>
+ <checkstyle.properties>checkstyle.severity=error</checkstyle.properties>
+ <sourcechecks.force>true</sourcechecks.force>
+ </properties>
+ <repositories>
+ <repository>
+ <id>objectweb</id>
+ <name>ObjectWeb repo</name>
+ <url>http://maven.objectweb.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Celtix -->
+ <dependency>
+ <groupId>org.objectweb.celtix</groupId>
+ <artifactId>celtix-rt</artifactId>
+ <version>${celtix.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java
new file mode 100644
index 0000000000..238fbe97b0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import org.objectweb.celtix.Bus;
+
+/**
+ * A system service that returns the active Celtix <code>Bus</code> for the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BusService {
+
+ /**
+ * Returns the active bus
+ */
+ Bus getBus();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java
new file mode 100644
index 0000000000..3a1c95c95e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.BusException;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * The default implementation of the Celtix Bus system service
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class BusServiceImpl implements BusService {
+
+ protected WSDLDefinitionRegistry wsdlRegistry;
+ private Bus bus;
+
+ public Bus getBus() {
+ return bus;
+ }
+
+ /**
+ * FIXME the annotation processing framework must inject this
+ * @param wsdlReg
+ */
+ @Property (override = "must")
+ public void setWsdlRegistry(WSDLDefinitionRegistry wsdlReg) {
+ wsdlRegistry = wsdlReg;
+ }
+
+ /**
+ * Initializes the bus, set to be called when the runtime initializes the Celtix system composite
+ * @throws BusException
+ */
+ @Init(eager = true)
+ public void init() throws BusException {
+ Map<String, Object> properties = new WeakHashMap<String, Object>();
+ properties.put("celtix.WSDLManager", new TuscanyWSDLManager(wsdlRegistry));
+ bus = Bus.init(new String[0], properties);
+ }
+
+ /**
+ * Shuts down the bus, called when the runtime stops the Celtix system composite
+ * @throws BusException
+ */
+ @Destroy
+ public void stop() throws BusException {
+ bus.shutdown(true);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java
new file mode 100644
index 0000000000..ec1a71b19d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.objectweb.celtix.Bus;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Builds a {@link org.apache.tuscany.spi.component.Service} or {@link org.apache.tuscany.spi.component.Reference}
+ * configured with the Celtix binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixBindingBuilder extends BindingBuilderExtension<WebServiceBinding> {
+
+ private Bus bus;
+
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<WebServiceBinding> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+ WebServiceBinding wsBinding = boundServiceDefinition.getBinding();
+ TypeHelper typeHelper = (TypeHelper) deploymentContext.getExtension(TypeHelper.class.getName());
+ if (typeHelper == null) {
+ typeHelper = TypeHelper.INSTANCE;
+ }
+ if (bus == null) {
+ bus = getBus(wsBinding.getWSDLDefinitionRegistry());
+ }
+ return new CeltixService(
+ boundServiceDefinition.getName(),
+ boundServiceDefinition.getServiceContract().getInterfaceClass(),
+ parent,
+ wireService,
+ wsBinding,
+ bus,
+ typeHelper);
+ }
+
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<WebServiceBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ WebServiceBinding wsBinding = boundReferenceDefinition.getBinding();
+ TypeHelper typeHelper = (TypeHelper) deploymentContext.getExtension(TypeHelper.class.getName());
+ if (typeHelper == null) {
+ typeHelper = TypeHelper.INSTANCE;
+ }
+ if (bus == null) {
+ bus = getBus(wsBinding.getWSDLDefinitionRegistry());
+ }
+ return new CeltixReference(
+ boundReferenceDefinition.getName(),
+ boundReferenceDefinition.getServiceContract().getInterfaceClass(),
+ parent,
+ wireService,
+ wsBinding,
+ bus,
+ typeHelper);
+ }
+
+ protected Class<WebServiceBinding> getBindingType() {
+ return WebServiceBinding.class;
+ }
+
+ private Bus getBus(WSDLDefinitionRegistry wsdlDefinitionRegistry) {
+ Bus celtixBus = null;
+ try {
+ Map<String, Object> properties = new WeakHashMap<String, Object>();
+ properties.put("celtix.WSDLManager", new TuscanyWSDLManager(wsdlDefinitionRegistry));
+ celtixBus = Bus.init(new String[0], properties);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return celtixBus;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java
new file mode 100644
index 0000000000..aba5fd5984
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import javax.jws.WebParam;
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import commonj.sdo.helper.TypeHelper;
+import org.apache.tuscany.binding.celtix.io.SCADataBindingCallback;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.BusException;
+import org.objectweb.celtix.bindings.ClientBinding;
+import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLMetaDataCache;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+
+/**
+ * Responsible for dispatching a service operation invocation on a reference to the active Celtix <code>Bus</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixInvoker implements TargetInvoker {
+
+ private WSDLMetaDataCache wsdlCache;
+
+ private ClientBinding clientBinding;
+
+ private String operationName;
+
+ private TypeHelper typeHelper;
+
+ public CeltixInvoker(String operationName,
+ Bus bus,
+ Port port,
+ Service wsdlService,
+ Definition wsdlDef,
+ TypeHelper theTypeHelper) throws BuilderException {
+ this.wsdlCache = new WSDLMetaDataCache(wsdlDef, port);
+ this.operationName = operationName;
+ this.typeHelper = theTypeHelper;
+ // Definition wsdlDef = wsBinding.getWSDLDefinition();
+ // wsdlCache = new WSDLMetaDataCache(wsdlDef, wsBinding.getWSDLPort());
+
+ try {
+ String key = wsdlDef.getDocumentBaseURI();
+ URL url = new URL(key);
+
+ QName qName = wsdlService.getQName();
+ EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(url, qName, port.getName());
+
+ String bindingId = null;
+ Binding binding = port.getBinding();
+ if (null != binding) {
+ List list = binding.getExtensibilityElements();
+ if (!list.isEmpty()) {
+ bindingId = ((ExtensibilityElement) list.get(0)).getElementType().getNamespaceURI();
+ }
+ }
+ if (bindingId == null) {
+ List<?> list = port.getExtensibilityElements();
+ for (Object ep : list) {
+ ExtensibilityElement ext = (ExtensibilityElement) ep;
+ if (ext instanceof SOAPAddress) {
+ bindingId = ((SOAPAddress) ext).getLocationURI();
+ }
+ if (ext instanceof AddressType) {
+ bindingId = ((AddressType) ext).getLocation();
+ }
+ }
+
+ }
+ clientBinding = bus.getBindingManager().getBindingFactory(bindingId).createClientBinding(reference);
+ } catch (MalformedURLException e) {
+ throw new InvokerCreationException(e);
+ } catch (BusException e) {
+ throw new InvokerCreationException(e);
+ } catch (WSDLException e) {
+ throw new InvokerCreationException(e);
+ } catch (IOException e) {
+ throw new InvokerCreationException(e);
+ }
+ }
+
+ /**
+ * Invoke an operation on the external Web service.
+ *
+ * @param args the Java object arguments to the WS operation
+ * @return the response from the WS as a Java object
+ */
+ public Object invokeTarget(final Object args) throws InvocationTargetException {
+ WSDLOperationInfo opInfo = wsdlCache.getOperationInfo(operationName);
+ if (opInfo == null) {
+ // REVISIT - really map the operation name to a WSDL operation
+ for (String opName : wsdlCache.getAllOperationInfo().keySet()) {
+ if (operationName.equalsIgnoreCase(opName)) {
+ opInfo = wsdlCache.getOperationInfo(opName);
+ break;
+ }
+ }
+ }
+
+ ObjectMessageContext objMsgContext = clientBinding.createObjectContext();
+
+ boolean hasInOut = false;
+ int inOutCount = 0;
+ Object realArgs[];
+ Object argsArray[];
+ if (args.getClass().isArray()) {
+ argsArray = (Object[]) args;
+ realArgs = new Object[Array.getLength(args)];
+ } else {
+ argsArray = new Object[0];
+ realArgs = new Object[0];
+ }
+
+ if (opInfo.getParamsLength() == 0) {
+ // REVISIT - opInfo doesn't return the needed info for the wrapped doc/lit case.
+ // Bug in Celtix
+ realArgs = argsArray;
+ } else {
+ for (int x = 0; x < argsArray.length; x++) {
+ if (opInfo.getWebParam(x).mode() == WebParam.Mode.IN) {
+ realArgs[x] = argsArray[x];
+ } else {
+ realArgs[x] = new Holder<Object>(argsArray[x]);
+ inOutCount++;
+ hasInOut = true;
+ }
+ }
+ }
+ objMsgContext.setMessageObjects(realArgs);
+ boolean isOneway = opInfo.isOneWay();
+ DataBindingCallback callback = new SCADataBindingCallback(opInfo, hasInOut, typeHelper);
+ try {
+ if (isOneway) {
+ clientBinding.invokeOneWay(objMsgContext, callback);
+ } else {
+ objMsgContext = clientBinding.invoke(objMsgContext, callback);
+ }
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
+ }
+
+ if (objMsgContext.getException() != null) {
+ // REVISIT - Exceptions
+ /*
+ * if (isValidException(objMsgContext)) { throw
+ * (Exception)objMsgContext.getException(); } else { throw new
+ * ProtocolException(objMsgContext.getException()); }
+ */
+ throw new InvocationTargetException(objMsgContext.getException());
+ }
+
+ if (hasInOut) {
+ Object ret[] = new Object[inOutCount + 1];
+ ret[0] = objMsgContext.getReturn();
+ inOutCount = 1;
+ for (int x = 0; x < argsArray.length; x++) {
+ if (opInfo.getWebParam(x).mode() != WebParam.Mode.IN) {
+ Holder<?> holder = (Holder<?>) realArgs[x];
+ ret[inOutCount] = holder.value;
+ inOutCount++;
+ }
+ }
+ return ret;
+ }
+ return objMsgContext.getReturn();
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new UnsupportedOperationException();
+ }
+
+ public CeltixInvoker clone() throws CloneNotSupportedException {
+ try {
+ return (CeltixInvoker) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java
new file mode 100644
index 0000000000..c32f332d4b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import commonj.sdo.helper.TypeHelper;
+import org.objectweb.celtix.Bus;
+
+/**
+ * The implementation of a {@link org.apache.tuscany.spi.component.Reference} configured with the Celtix binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixReference<T> extends ReferenceExtension {
+
+ private Bus bus;
+ private Port port;
+ private Definition wsdlDef;
+ private Service wsdlService;
+ private TypeHelper typeHelper;
+
+ public CeltixReference(String name,
+ Class<T> interfaze,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding binding,
+ Bus theBus,
+ TypeHelper theTypeHelper) {
+ super(name, interfaze, parent, wireService);
+ this.wsdlDef = binding.getWSDLDefinition();
+ this.port = binding.getWSDLPort();
+ this.wsdlService = binding.getWSDLService();
+ this.bus = theBus;
+ this.typeHelper = theTypeHelper;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return new CeltixInvoker(operation.getName(), bus, port, wsdlService, wsdlDef, typeHelper);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java
new file mode 100644
index 0000000000..097f0ac050
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java
@@ -0,0 +1,270 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+import javax.jws.soap.SOAPBinding;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceProvider;
+
+import org.osoa.sca.annotations.Destroy;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+import commonj.sdo.helper.TypeHelper;
+import org.apache.tuscany.binding.celtix.io.SCAServerDataBindingCallback;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.BindingFactory;
+import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bindings.ServerBinding;
+import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLMetaDataCache;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+import org.objectweb.celtix.ws.addressing.AttributedURIType;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+
+/**
+ * An implementation of a {@link Service} configured with the Celtix binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixService extends ServiceExtension implements ServerBindingEndpointCallback {
+
+ private Bus bus;
+ private Port port;
+ private Definition wsdlDef;
+ private Service wsdlService;
+ private WSDLMetaDataCache wsdlCache;
+ private TypeHelper typeHelper;
+
+ private Map<QName, ServerDataBindingCallback> opMap =
+ new ConcurrentHashMap<QName, ServerDataBindingCallback>();
+
+
+ public CeltixService(String theName,
+ Class<?> interfaze,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding binding,
+ Bus bus,
+ TypeHelper theTypeHelper) {
+ super(theName, interfaze, parent, wireService);
+ this.wsdlDef = binding.getWSDLDefinition();
+ this.port = binding.getWSDLPort();
+ this.wsdlService = binding.getWSDLService();
+ this.bus = bus;
+ this.wsdlCache = new WSDLMetaDataCache(wsdlDef, port);
+ this.typeHelper = theTypeHelper;
+ }
+
+ public void start() {
+ super.start();
+ initOperationMap();
+ startServerBinding();
+ }
+
+ private void startServerBinding() {
+ String key = wsdlDef.getDocumentBaseURI();
+ URL url;
+ try {
+ url = new URL(key);
+ } catch (MalformedURLException e) {
+ throw new CeltixServiceInitException(e);
+ }
+
+ QName qName = wsdlService.getQName();
+ String portName = port.getName();
+ EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(url,qName,portName);
+
+ AttributedURIType address = new AttributedURIType();
+
+ String bindingId = null;
+ Binding binding = port.getBinding();
+ if (null != binding) {
+ List list = binding.getExtensibilityElements();
+ if (!list.isEmpty()) {
+ bindingId = ((ExtensibilityElement) list.get(0)).getElementType().getNamespaceURI();
+ }
+ }
+ List<?> list = port.getExtensibilityElements();
+ for (Object ep : list) {
+ ExtensibilityElement ext = (ExtensibilityElement) ep;
+ if (ext instanceof SOAPAddress) {
+ if (bindingId == null) {
+ bindingId = ((SOAPAddress) ext).getLocationURI();
+ }
+ address.setValue(((SOAPAddress) ext).getLocationURI());
+ }
+ if (ext instanceof AddressType) {
+ if (bindingId == null) {
+ bindingId = ((AddressType) ext).getLocation();
+ }
+ address.setValue(((AddressType) ext).getLocation());
+ }
+ }
+ if (reference.getAddress() == null) {
+ //REVIST - bug in Celtix that the HTTP transport won't find the address correctly
+ reference.setAddress(address);
+ }
+ ClassLoader previousLoader = null;
+ try {
+ //FIXME: This hack is because SAAJImpl uses Thread.currentThread().getContextClassLoader(),
+ //this classloader is different from current classLoader.
+ previousLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ BindingFactory bindingFactory = bus.getBindingManager().getBindingFactory(bindingId);
+ ServerBinding serverBinding = bindingFactory.createServerBinding(reference, this);
+ serverBinding.activate();
+ } catch (Exception e) {
+ throw new CeltixServiceInitException(e);
+ } finally {
+ if (previousLoader != null) {
+ Thread.currentThread().setContextClassLoader(previousLoader);
+ }
+ }
+ }
+
+ private void initOperationMap() {
+ List ops = port.getBinding().getBindingOperations();
+ for (Object op1 : ops) {
+ BindingOperation op = (BindingOperation) op1;
+ BindingInput bindingInput = op.getBindingInput();
+ List elements = bindingInput.getExtensibilityElements();
+ QName qn = new QName(wsdlDef.getTargetNamespace(), op.getName());
+
+ //In case soap:body namespace is different from targetNamespace
+ for (Object element : elements) {
+ if (SOAPBody.class.isInstance(element)) {
+ SOAPBody body = (SOAPBody) element;
+ if (body.getNamespaceURI() != null) {
+ qn = new QName(body.getNamespaceURI(), op.getName());
+ }
+ }
+ }
+
+ ServerDataBindingCallback cb = getDataBindingCallback(qn, null, DataBindingCallback.Mode.PARTS);
+ opMap.put(qn, cb);
+ if (!"".equals(cb.getRequestWrapperQName().getLocalPart())) {
+ opMap.put(cb.getRequestWrapperQName(), cb);
+ }
+ }
+ }
+
+ @Destroy
+ public void stop() throws CoreRuntimeException {
+ super.stop();
+ }
+
+ public ServerDataBindingCallback getDataBindingCallback(QName operationName,
+ ObjectMessageContext objContext,
+ DataBindingCallback.Mode mode) {
+ if (opMap.containsKey(operationName)) {
+ return opMap.get(operationName);
+ }
+ WSDLOperationInfo opInfo = wsdlCache.getOperationInfo(operationName.getLocalPart());
+ if (opInfo == null) {
+ //REVISIT - really map the operation name to a WSDL operation
+ for (String opName : wsdlCache.getAllOperationInfo().keySet()) {
+ if (operationName.getLocalPart().equalsIgnoreCase(opName)) {
+ opInfo = wsdlCache.getOperationInfo(opName);
+ break;
+ }
+ }
+ }
+ boolean inout = false;
+
+ Class<?> serviceInterface = this.getInterface();
+ Method meth = getMethod(serviceInterface, operationName.getLocalPart());
+
+ Object proxy = this.getServiceInstance();
+
+ return new SCAServerDataBindingCallback(opInfo, inout, meth, proxy, typeHelper);
+ }
+
+ protected Method getMethod(Class<?> serviceInterface, String operationName) {
+ // Note: this doesn't support overloaded operations
+ Method[] methods = serviceInterface.getMethods();
+ for (Method m : methods) {
+ if (m.getName().equals(operationName)) {
+ return m;
+ }
+ // tolerate WSDL with capatalized operation name
+ StringBuilder sb = new StringBuilder(operationName);
+ sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+ if (m.getName().equals(sb.toString())) {
+ return m;
+ }
+ }
+ throw new BuilderConfigException("no operation named " + operationName
+ + " found on service interface: " + serviceInterface.getName());
+ }
+
+ public DataBindingCallback getFaultDataBindingCallback(ObjectMessageContext objContext) {
+ // REVISIT - what to do about faults
+ return null;
+ }
+
+ public Map<QName, ? extends DataBindingCallback> getOperations() {
+ return opMap;
+ }
+
+ public SOAPBinding.Style getStyle() {
+ return wsdlCache.getStyle();
+ }
+
+ public DataBindingCallback.Mode getServiceMode() {
+ return DataBindingCallback.Mode.PARTS;
+ }
+
+ public WebServiceProvider getWebServiceProvider() {
+ //not needed I think
+ return null;
+ }
+
+ public Executor getExecutor() {
+ //Let the transport handle it (or it goes to the Bus default wq
+ //if the transport cannot handle it
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java
new file mode 100644
index 0000000000..4eca4a3bd1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes an exception starting a {@link CeltixService} instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixServiceInitException extends CoreRuntimeException {
+ public CeltixServiceInitException() {
+ }
+
+ public CeltixServiceInitException(String message) {
+ super(message);
+ }
+
+ public CeltixServiceInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CeltixServiceInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java
new file mode 100644
index 0000000000..e08a3193d8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+
+/**
+ * Thrown when an error is encountered creating a {@link CeltixInvoker}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvokerCreationException extends BuilderException {
+ public InvokerCreationException() {
+ }
+
+ public InvokerCreationException(String message) {
+ super(message);
+ }
+
+ public InvokerCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvokerCreationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java
new file mode 100644
index 0000000000..18efe80da5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.w3c.dom.Element;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+
+import org.objectweb.celtix.wsdl.WSDLManager;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyWSDLManager implements WSDLManager {
+ WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ public TuscanyWSDLManager(WSDLDefinitionRegistry w) {
+ wsdlDefinitionRegistry = w;
+ }
+
+ public WSDLFactory getWSDLFactory() {
+ //Not supported
+ return null;
+ }
+
+ public ExtensionRegistry getExtenstionRegistry() {
+ return wsdlDefinitionRegistry.getExtensionRegistry();
+ }
+
+ public Definition getDefinition(URL url) throws WSDLException {
+ try {
+ return wsdlDefinitionRegistry.loadDefinition(null, url);
+ } catch (IOException e) {
+ //FIXME
+ throw new WSDLException("", "", e);
+ }
+ }
+
+ public Definition getDefinition(String url) throws WSDLException {
+ try {
+ //The namespace is the wsdl targetNamesapce, it is only used
+ //when the wsdl is created into cache. we are ok here to set it to null.
+ //FIXME pass the current ResourceLoader
+ return wsdlDefinitionRegistry.loadDefinition(null, new URL(url));
+ } catch (IOException e) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, e.getMessage());
+ }
+ }
+
+ public Definition getDefinition(Element el) throws WSDLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Definition getDefinition(Class<?> sei) throws WSDLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addDefinition(Object key, Definition wsdl) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void shutdown() {
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java
new file mode 100644
index 0000000000..49df9a6e28
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a Celtix binding configuration in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBinding extends Binding {
+
+ private Definition definition;
+ private Port port;
+ private Service service;
+ //private String portURI;
+ private String uri;
+ //We have to use WebServiceBinding to pass WSDLDefinitionRegistry to BindingBuilder
+ private WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ public WebServiceBinding(Definition definition, Port port, String uri, String portURI, Service service) {
+ this.definition = definition;
+ this.port = port;
+ this.uri = uri;
+ //this.portURI = portURI;
+ this.service = service;
+ }
+
+ public Port getWSDLPort() {
+ return port;
+ }
+
+ public Service getWSDLService() {
+ return service;
+ }
+
+ public void setWSDLPort(Port value) {
+ port = value;
+ }
+
+ public Definition getWSDLDefinition() {
+ return definition;
+ }
+
+ public void setWSDLDefinition(Definition def) {
+ definition = def;
+ }
+
+ public WSDLDefinitionRegistry getWSDLDefinitionRegistry() {
+ return wsdlDefinitionRegistry;
+ }
+
+ public void setWSDLDefinitionRegistry(WSDLDefinitionRegistry theWsdlDefinitionRegistry) {
+ wsdlDefinitionRegistry = theWsdlDefinitionRegistry;
+ }
+
+// public void setPortURI(String uri) {
+// portURI = uri;
+// }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String theUri) {
+ this.uri = theUri;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java
new file mode 100644
index 0000000000..5b11d02931
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.xml.sax.InputSource;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl.Monitor;
+
+/**
+ * Parses a <code>WebServiceBinding</code> entry in an assembly XML file
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class WebServiceBindingLoader extends LoaderExtension<WebServiceBinding> {
+ public static final QName BINDING_WS = new QName(XML_NAMESPACE_1_0, "binding.ws");
+
+ protected WSDLDefinitionRegistry wsdlRegistry;
+
+ @Constructor({"registry"})
+ public WebServiceBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+
+ //FIXME: this is a hack, WSDLDefinitionRegistry should not be created here
+ if (wsdlRegistry == null) {
+ try {
+ wsdlRegistry = new WSDLDefinitionRegistryImpl();
+ Monitor monitor = new Monitor() {
+ public void readingWSDL(String namespace, URL location) {
+ }
+
+ public void cachingDefinition(String namespace, URL location) {
+ }
+ };
+
+ ((WSDLDefinitionRegistryImpl) wsdlRegistry).setMonitor(monitor);
+ } catch (javax.wsdl.WSDLException e) {
+ //do nothing
+ }
+ }
+ }
+
+ public QName getXMLType() {
+ return BINDING_WS;
+ }
+
+ public WebServiceBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ // not sure what uri was here ? String uri = reader.getAttributeValue(null, "uri");
+ String uri = null;
+ String endpointAttribute = reader.getAttributeValue(null, "endpoint");
+ //String portURI = reader.getAttributeValue(null, "port");
+ String wsdlLocation = reader.getAttributeValue(null, "location");
+ try {
+ return createBinding(uri, endpointAttribute, wsdlLocation, deploymentContext);
+ } catch (Exception e) {
+
+ throw new LoaderException(e);
+ }
+ }
+
+ private WebServiceBinding createBinding(String port, String portURI, String wsdlLocation,
+ DeploymentContext deploymentContext)
+ throws WSDLException, IOException {
+ List<Definition> definitions = null;
+ // FIXME wsdlRegistry.getDefinitionsForNamespace(portNamespace,
+ // resourceLoader);
+ // Get the WSDL port namespace and name
+ if (port == null && portURI != null) {
+ int h = portURI.indexOf('#');
+ String portNamespace = portURI.substring(0, h);
+ String serviceName;
+ String portName;
+
+ String fragment = portURI.substring(h + 1);
+ if (fragment.startsWith("wsdl.endpoint(") && fragment.endsWith(")")) {
+ fragment = fragment.substring(14, fragment.length() - 1);
+ int slash = fragment.indexOf('/');
+ if (slash != -1) {
+ serviceName = fragment.substring(0, slash);
+ portName = fragment.substring(slash + 1);
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+
+ // FIXME need to find out how to get wsdl and what context to use --- terrible hack attack!
+ // URL wsdlurl = Thread.currentThread().getContextClassLoader().getResource(wsdlLocation);
+ if (null == wsdlLocation) {
+ throw new RuntimeException("Failed to determin wsdl location on binding. "
+ + "Try specifying 'location' attribute on binding.");
+ }
+ URL wsdlurl = deploymentContext.getClassLoader().getResource(wsdlLocation);
+ if (wsdlurl == null) {
+ throw new RuntimeException("Failed to load wsdl from '" + wsdlLocation + "'");
+ }
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(wsdlurl.openStream());
+ Definition wsdlDef = reader.readWSDL(wsdlurl.toString(), input);
+ definitions = new LinkedList<Definition>();
+ definitions.add(wsdlDef);
+ // FIXME all the above needs to better addressed.
+
+ //FIXME: if a global wsdl cached is used, we need to do a registration here
+ String namespace = wsdlDef.getTargetNamespace();
+ wsdlRegistry.loadDefinition(namespace, wsdlurl);
+
+ Definition definition = null;
+ Port thePort = null;
+ Service service = null;
+ for (Definition def : definitions) {
+
+ // Find the port with the given name
+ for (Service serv : (Collection<Service>) def.getServices().values()) {
+ QName sqn = serv.getQName();
+ if (serviceName != null
+ && !serviceName.equals(sqn.getLocalPart())) {
+ continue;
+ }
+
+ Port p = serv.getPort(portName);
+ if (p != null) {
+ service = serv;
+ definition = def;
+ thePort = p;
+ break;
+ }
+ }
+ }
+ if (thePort == null) {
+ throw new IllegalArgumentException("Cannot find WSDL port " + portURI);
+
+ }
+ WebServiceBinding wsBinding = new WebServiceBinding(definition, thePort, port, portURI, service);
+ wsBinding.setWSDLDefinitionRegistry(wsdlRegistry);
+ return wsBinding;
+ }
+ // FIXME - return a broken binding for now
+ return new WebServiceBinding(null, null, null, portURI, null);
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java
new file mode 100644
index 0000000000..7a14ab33fc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import static org.w3c.dom.bootstrap.DOMImplementationRegistry.PROPERTY;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+
+import org.apache.tuscany.core.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument;
+import org.objectweb.celtix.bindings.DataReader;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+public class NodeDataReader implements DataReader<Node> {
+
+ private SCADataBindingCallback callback;
+
+ public NodeDataReader(SCADataBindingCallback cb) {
+ callback = cb;
+ }
+
+ public Object read(int idx, Node input) {
+ return read(null, idx, input);
+ }
+
+ public Object read(QName name, int idx, Node input) {
+ try {
+ InputStream in = getNodeStream(input);
+ XMLInputFactory staxFactory = XMLInputFactory.newInstance();
+ XMLStreamReader reader = staxFactory.createXMLStreamReader(in);
+
+ XMLStreamReader2XMLDocument transformer = new XMLStreamReader2XMLDocument();
+ TransformationContext context = new TransformationContextImpl();
+ DataType<QName> binding = new DataType<QName>(DataObject.class, null);
+ binding.setMetadata(TypeHelper.class.getName(), callback.getTypeHelper());
+ context.setTargetDataType(binding);
+ XMLDocument document = transformer.transform(reader, context);
+
+ boolean isWrapped = false;
+ return toObjects(document, isWrapped);
+ } catch (Exception e) {
+ //REVISIT: better handling of exceptions
+ }
+ return null;
+ }
+
+ public void readWrapper(ObjectMessageContext objCtx, boolean isOutBound, Node input) {
+ try {
+ QName wrapperName;
+ if (isOutBound) {
+ wrapperName = callback.getOperationInfo().getResponseWrapperQName();
+ } else {
+ wrapperName = callback.getOperationInfo().getRequestWrapperQName();
+ }
+
+ Node nd = input.getFirstChild();
+ while (nd != null
+ && !wrapperName.getNamespaceURI().equals(nd.getNamespaceURI())
+ && !wrapperName.getLocalPart().equals(nd.getLocalName())) {
+ nd = nd.getNextSibling();
+ }
+
+ //REVISIT - This is SUCH a HACK. This needs to be done with StAX or something
+ //a bit better than streaming and reparsing
+ InputStream in = getNodeStream(nd);
+ XMLInputFactory staxFactory = XMLInputFactory.newInstance(
+ "javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
+ XMLStreamReader reader = staxFactory.createXMLStreamReader(in);
+
+ XMLStreamReader2XMLDocument transformer = new XMLStreamReader2XMLDocument();
+ TransformationContext context = new TransformationContextImpl();
+ DataType<QName> binding = new DataType<QName>(DataObject.class, null);
+ binding.setMetadata(TypeHelper.class.getName(), callback.getTypeHelper());
+ context.setTargetDataType(binding);
+ XMLDocument document = transformer.transform(reader, context);
+
+ //boolean isWrapped = true;
+ Object[] objects = toObjects(document, true);
+
+ if (callback.hasInOut()) {
+ //REVISIT - inOuts
+ } else {
+ if (isOutBound) {
+ objCtx.setReturn(objects[0]);
+ } else {
+ objCtx.setMessageObjects(objects);
+ }
+ }
+ } catch (Exception e) {
+ //REVISIT: better handling of exceptions
+ }
+ }
+
+ /**
+ * Convert a typed DataObject to Java objects
+ *
+ * @param document
+ * @param isWrapped
+ * @return the array of Objects from the DataObject
+ */
+ public static Object[] toObjects(XMLDocument document, boolean isWrapped) {
+ DataObject dataObject = document.getRootObject();
+ if (isWrapped) {
+ List ips = dataObject.getInstanceProperties();
+ Object[] os = new Object[ips.size()];
+ for (int i = 0; i < ips.size(); i++) {
+ os[i] = dataObject.get((Property) ips.get(i));
+ }
+ return os;
+ } else {
+ Object object = dataObject;
+ Type type = dataObject.getType();
+ if (type.isSequenced()) {
+ object = dataObject.getSequence().getValue(0);
+ }
+ return new Object[]{object};
+ }
+ }
+
+ byte[] getNodeBytes(Node node)
+ throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+ //This is also a hack, the JDK should already have this set, but it doesn't
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ if (registry == null) {
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ }
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ if (impl == null) {
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ }
+ LSOutput output = impl.createLSOutput();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ output.setByteStream(bout);
+ LSSerializer writer = impl.createLSSerializer();
+ writer.write(node, output);
+
+ return bout.toByteArray();
+ }
+
+ InputStream getNodeStream(Node node)
+ throws ClassCastException, ClassNotFoundException,
+ InstantiationException, IllegalAccessException {
+
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ if (registry == null) {
+ //This is also a hack, the JDK should already have this set, but it doesn't
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ }
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ if (impl == null) {
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ }
+ LSOutput output = impl.createLSOutput();
+ RawByteArrayOutputStream bout = new RawByteArrayOutputStream();
+ output.setByteStream(bout);
+ LSSerializer writer = impl.createLSSerializer();
+ writer.write(node, output);
+
+ return new ByteArrayInputStream(bout.getBytes(), 0, bout.size());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java
new file mode 100644
index 0000000000..d870cafa87
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java
@@ -0,0 +1,322 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix.io;
+
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.objectweb.celtix.bindings.DataWriter;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+public class NodeDataWriter implements DataWriter<Node> {
+ private static final String XML_NS = "http://www.w3.org/2000/xmlns/";
+ private SCADataBindingCallback callback;
+
+ public NodeDataWriter(SCADataBindingCallback cb) {
+ callback = cb;
+ }
+
+ public void write(Object obj, Node output) {
+ write(obj, null, output);
+ }
+
+ public void write(Object obj, QName elName, Node output) {
+ boolean isWrapped = false;
+
+ XMLDocument document = toXMLDocument(callback.getTypeHelper(), new Object[]{obj}, elName, isWrapped);
+ // HACK: [rfeng] We should use the transformer in an interceptor
+ XMLDocument2XMLStreamReader transformer = new XMLDocument2XMLStreamReader();
+ XMLStreamReader reader = transformer.transform(document, null);
+
+ try {
+ //CeltixFire supports Stax, we should not need to do following anymore.
+ readDocElements(output, reader, true, null);
+ } catch (XMLStreamException e) {
+ throw new InvocationRuntimeException(e.getMessage());
+ }
+ }
+
+ public void writeWrapper(ObjectMessageContext objCtx, boolean isOutbound, Node output) {
+ boolean isWrapped = true;
+ QName wrapperName;
+ if (isOutbound) {
+ wrapperName = callback.getOperationInfo().getResponseWrapperQName();
+ } else {
+ wrapperName = callback.getOperationInfo().getRequestWrapperQName();
+ }
+
+ XMLDocument document = toXMLDocument(
+ callback.getTypeHelper(), objCtx.getMessageObjects(), wrapperName, isWrapped);
+ // HACK: [rfeng] We should use the transformer in an interceptor
+ XMLDocument2XMLStreamReader transformer = new XMLDocument2XMLStreamReader();
+ XMLStreamReader reader = transformer.transform(document, null);
+
+ try {
+ readDocElements(output, reader, true, null);
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ throw new InvocationRuntimeException(e.getMessage());
+ }
+ }
+/*
+ private DataObject toWrappedDataObject(TypeHelper typeHelper,
+ Object ret,
+ Object[] os,
+ QName typeQN) {
+ XSDHelper xsdHelper = new XSDHelperImpl(typeHelper);
+ Property property = xsdHelper.getGlobalProperty(typeQN.getNamespaceURI(),
+ typeQN.getLocalPart(), true);
+ DataObject dataObject = new DataFactoryImpl(typeHelper).create(property.getType());
+ List ips = dataObject.getInstanceProperties();
+ int offset = 0;
+ if (ret != null) {
+ dataObject.set(0, ret);
+ offset = 1;
+ }
+ for (int i = offset; i < ips.size(); i++) {
+ if (os[i - offset] instanceof Holder) {
+ Holder<?> holder = (Holder<?>)os[i - offset];
+ dataObject.set(i, holder.value);
+ } else {
+ dataObject.set(i, os[i - offset]);
+ }
+ }
+ return dataObject;
+ }
+*/
+
+ /**
+ * Convert objects to typed DataObject
+ *
+ * @param typeHelper
+ * @param os
+ * @param elementQName
+ * @param isWrapped
+ * @return the DataObject
+ */
+ private static XMLDocument toXMLDocument(TypeHelper typeHelper,
+ Object[] os,
+ QName elementQName,
+ boolean isWrapped) {
+ XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+
+ Property property = xsdHelper.getGlobalProperty(
+ elementQName.getNamespaceURI(), elementQName.getLocalPart(), true);
+ if (null == property) {
+ throw new InvocationRuntimeException(
+ "Type '" + elementQName.toString() + "' not found in registered SDO types.");
+ }
+ DataObject dataObject;
+ if (isWrapped) {
+ DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper);
+ dataObject = dataFactory.create(property.getType());
+ List ips = dataObject.getInstanceProperties();
+ for (int i = 0; i < ips.size(); i++) {
+ dataObject.set(i, os[i]);
+ }
+ } else {
+ Object value = os[0];
+ Type type = property.getType();
+ if (!type.isDataType()) {
+ dataObject = (DataObject) value;
+ } else {
+ dataObject = SDOUtil.createDataTypeWrapper(type, value);
+ }
+ }
+
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ return xmlHelper.createDocument(dataObject, elementQName.getNamespaceURI(), elementQName.getLocalPart());
+
+ }
+
+ //REVISIT: We should not need to do following anymore with CeltixFire.
+ //As CeltixFire supports stax directly.
+
+ /**
+ * @param parent
+ * @param reader
+ * @param repairing
+ * @param stopAt: stop at the specified element
+ * @throws XMLStreamException
+ */
+ public static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing, QName stopAt)
+ throws XMLStreamException {
+ Document doc = getDocument(parent);
+
+ int event = reader.getEventType();
+
+ while (reader.hasNext()) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ if (startElement(parent, reader, repairing, stopAt) == null) {
+ return;
+ }
+ if (parent instanceof Document && stopAt != null) {
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ return;
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ return;
+ case XMLStreamConstants.NAMESPACE:
+ break;
+ case XMLStreamConstants.ATTRIBUTE:
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ if (parent != null) {
+ parent.appendChild(doc.createTextNode(reader.getText()));
+ }
+
+ break;
+ case XMLStreamConstants.COMMENT:
+ if (parent != null) {
+ parent.appendChild(doc.createComment(reader.getText()));
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ parent.appendChild(doc.createCDATASection(reader.getText()));
+
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
+
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
+
+ break;
+ default:
+ break;
+ }
+
+ if (reader.hasNext()) {
+ event = reader.next();
+ }
+ }
+ }
+
+ private static Document getDocument(Node parent) {
+ return (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument();
+ }
+
+ /**
+ * @param parent
+ * @param reader
+ * @return
+ * @throws XMLStreamException
+ */
+ private static Element startElement(Node parent, XMLStreamReader reader, boolean repairing, QName stopAt)
+ throws XMLStreamException {
+ Document doc = getDocument(parent);
+
+ if (stopAt != null && stopAt.getNamespaceURI().equals(reader.getNamespaceURI())
+ && stopAt.getLocalPart().equals(reader.getLocalName())) {
+ return null;
+ }
+
+ Element e = doc.createElementNS(reader.getNamespaceURI(), reader.getLocalName());
+
+ if (reader.getPrefix() != null) {
+ e.setPrefix(reader.getPrefix());
+ }
+
+ parent.appendChild(e);
+
+ for (int ns = 0; ns < reader.getNamespaceCount(); ns++) {
+ String uri = reader.getNamespaceURI(ns);
+ String prefix = reader.getNamespacePrefix(ns);
+
+ declare(e, uri, prefix);
+ }
+
+ for (int att = 0; att < reader.getAttributeCount(); att++) {
+ String name = reader.getAttributeLocalName(att);
+ String prefix = reader.getAttributePrefix(att);
+ if (prefix != null && prefix.length() > 0) {
+ name = prefix + ":" + name;
+ }
+
+ Attr attr = doc.createAttributeNS(reader.getAttributeNamespace(att), name);
+ attr.setValue(reader.getAttributeValue(att));
+ e.setAttributeNode(attr);
+ }
+
+ reader.next();
+
+ readDocElements(e, reader, repairing, stopAt);
+
+ if (repairing && !isDeclared(e, reader.getNamespaceURI(), reader.getPrefix())) {
+ declare(e, reader.getNamespaceURI(), reader.getPrefix());
+ }
+
+ return e;
+ }
+
+ private static void declare(Element node, String uri, String prefix) {
+ if (prefix != null && prefix.length() > 0) {
+ node.setAttributeNS(XML_NS, "xmlns:" + prefix, uri);
+ } else {
+ if (uri != null /* && uri.length() > 0 */) {
+ node.setAttributeNS(XML_NS, "xmlns", uri);
+ }
+ }
+ }
+
+ private static boolean isDeclared(Element e, String namespaceURI, String prefix) {
+ Attr att;
+ if (prefix != null && prefix.length() > 0) {
+ att = e.getAttributeNodeNS(XML_NS, "xmlns:" + prefix);
+ } else {
+ att = e.getAttributeNode("xmlns");
+ }
+
+ if (att != null && att.getNodeValue().equals(namespaceURI)) {
+ return true;
+ }
+
+ if (e.getParentNode() instanceof Element) {
+ return isDeclared((Element) e.getParentNode(), namespaceURI, prefix);
+ }
+
+ return false;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java
new file mode 100644
index 0000000000..057481041b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix.io;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Just to allow raw access to the byte[] to avoid a copy
+ */
+class RawByteArrayOutputStream extends ByteArrayOutputStream {
+ public byte[] getBytes() {
+ return buf;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java
new file mode 100644
index 0000000000..47d130383f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix.io;
+
+import org.w3c.dom.Node;
+
+import commonj.sdo.helper.TypeHelper;
+import org.objectweb.celtix.bindings.DataReader;
+import org.objectweb.celtix.bindings.DataWriter;
+import org.objectweb.celtix.bus.bindings.AbstractWSDLOperationDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCADataBindingCallback extends AbstractWSDLOperationDataBindingCallback {
+
+ protected boolean hasInOut;
+ protected TypeHelper typeHelper;
+
+ public SCADataBindingCallback(WSDLOperationInfo op, boolean inout, TypeHelper theTypeHelper) {
+ super(op);
+ this.hasInOut = inout;
+ this.typeHelper = theTypeHelper;
+ }
+
+ public boolean hasInOut() {
+ return hasInOut;
+ }
+
+ public Mode getMode() {
+ return Mode.PARTS;
+ }
+
+ public Class<?>[] getSupportedFormats() {
+ return new Class<?>[]{Node.class};
+ }
+
+ public TypeHelper getTypeHelper() {
+ return typeHelper;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataWriter<T> createWriter(Class<T> cls) {
+ if (cls == Node.class) {
+ return (DataWriter<T>) new NodeDataWriter(this);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataReader<T> createReader(Class<T> cls) {
+ if (cls == Node.class) {
+ return (DataReader<T>) new NodeDataReader(this);
+ }
+ //REVISIT - need to figure out what to do with Faults
+ return null;
+ }
+
+ public void initObjectContext(ObjectMessageContext octx) {
+ //REVISIT - is this even used?
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java
new file mode 100644
index 0000000000..db9c624bd4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix.io;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import commonj.sdo.helper.TypeHelper;
+
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAServerDataBindingCallback extends SCADataBindingCallback
+ implements ServerDataBindingCallback {
+ Method method;
+ Object targetObject;
+
+ public SCAServerDataBindingCallback(WSDLOperationInfo op,
+ boolean inout,
+ Method meth,
+ Object target,
+ TypeHelper theTypeHelper) {
+ super(op, inout, theTypeHelper);
+ method = meth;
+ targetObject = target;
+ }
+
+
+ public void invoke(ObjectMessageContext octx) throws InvocationTargetException {
+ Object ret;
+ try {
+ ret = method.invoke(targetObject, octx.getMessageObjects());
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ octx.setReturn(ret);
+ }
+
+ public void initObjectContext(ObjectMessageContext octx) {
+ Object o[] = new Object[method.getParameterTypes().length];
+ //REVIST - holders?
+ octx.setMessageObjects(o);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..b6a5334903
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.celtix.WebServiceBinding">
+
+ <component name="ws.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.celtix.WebServiceBindingLoader" />
+ </component>
+
+ <component name="ws.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.celtix.CeltixBindingBuilder" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java
new file mode 100644
index 0000000000..cba83a7792
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BootstrapTestCase extends TestCase {
+
+ public void testReference() throws Exception {
+// BusServiceImpl busService = new BusServiceImpl();
+// WSDLDefinitionRegistry wsdlRegistry = new WSDLDefinitionRegistryImpl();
+// busService.setWsdlRegistry(wsdlRegistry);
+// busService.init();
+// CeltixReference reference = new CeltixReference("reference",);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java
new file mode 100644
index 0000000000..5440fc22ce
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.xml.sax.InputSource;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.binding.celtix.io.SCADataBindingCallback;
+import org.easymock.classextension.EasyMock;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.BindingManager;
+import org.objectweb.celtix.bus.bindings.soap.SOAPBindingFactory;
+import org.objectweb.celtix.bus.bindings.soap.SOAPClientBinding;
+import org.objectweb.celtix.context.ObjectMessageContextImpl;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CeltixInvokerTestCase extends TestCase {
+
+ public void testProcessingInputWithoutInOut() throws Exception {
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ String operationName = "greetMe";
+ ObjectMessageContextImpl inputCtx = new ObjectMessageContextImpl();
+ CeltixInvoker invoker = createCeltixInvoker(wsdlLocation,
+ operationName, inputCtx);
+
+ Object[] args = new Object[1];
+ args[0] = new String("hello");
+ invoker.invokeTarget(args);
+
+ // Check the input object after processing is correct
+ // Should be no change for input if only IN parameters involved
+ Object[] myrtn = (Object[]) inputCtx.getMessageObjects();
+
+ assertEquals("hello", myrtn[0]);
+ }
+
+ public void testProcessingInputWithInOut() throws Exception {
+ String wsdlLocation = "/wsdl/hello_world_doc_lit_inout.wsdl";
+ String operationName = "greetMe";
+ ObjectMessageContextImpl inputCtx = new ObjectMessageContextImpl();
+ CeltixInvoker invoker = createCeltixInvoker(wsdlLocation,
+ operationName, inputCtx);
+
+ Object[] args = new Object[1];
+ String inputvalue = new String("hello");
+ args[0] = inputvalue;
+ Object result = invoker.invokeTarget(args);
+
+ // Check the input object after processing is correct
+ // input should be wrapped as Holder type if it is INOUT parameter
+ Object[] myrtn = (Object[]) inputCtx.getMessageObjects();
+
+ //FIXME: this does not work for the wrapped doc/lit case due to a bug in Celtix
+ //assertTrue("input is not Holder type", myrtn[0] instanceof Holder);
+ }
+
+ // NOTE: For convenience this method presumes the soap service name is
+ // SOAPService and port name is SoapPort
+ private CeltixInvoker createCeltixInvoker(String wsdlLocation,
+ String operationName,
+ ObjectMessageContextImpl inputCtx)
+ throws Exception {
+
+ // Make following call to return a mocked SOAPClientBinding:
+ // bus.getBindingManager().getBindingFactory(bindingId).createClientBinding(reference)
+ SOAPClientBinding clientBinding = EasyMock
+ .createMock(SOAPClientBinding.class);
+ clientBinding.createObjectContext();
+ EasyMock.expectLastCall().andReturn(inputCtx);
+ clientBinding.invoke(EasyMock.isA(ObjectMessageContextImpl.class),
+ EasyMock.isA(SCADataBindingCallback.class));
+ EasyMock.expectLastCall().andReturn(new ObjectMessageContextImpl());
+ EasyMock.replay(clientBinding);
+
+ SOAPBindingFactory bindingFactory = EasyMock.createNiceMock(SOAPBindingFactory.class);
+ bindingFactory.createClientBinding(EasyMock.isA(EndpointReferenceType.class));
+ EasyMock.expectLastCall().andReturn(clientBinding);
+ EasyMock.replay(bindingFactory);
+
+ BindingManager bindingManager = EasyMock.createNiceMock(BindingManager.class);
+ String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
+ bindingManager.getBindingFactory(bindingId);
+ EasyMock.expectLastCall().andReturn(bindingFactory);
+
+ Bus bus = EasyMock.createNiceMock(Bus.class);
+ bus.getBindingManager();
+ EasyMock.expectLastCall().andReturn(bindingManager);
+ EasyMock.replay(bindingManager);
+ EasyMock.replay(bus);
+
+ // Create WSDL Definition
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ QName qName = new QName("http://objectweb.org/hello_world_soap_http", "SOAPService");
+ Service wsdlService = wsdlDef.getService(qName);
+ Port port = wsdlService.getPort("SoapPort");
+
+ return new CeltixInvoker(operationName, bus, port, wsdlService, wsdlDef, null);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java
new file mode 100644
index 0000000000..1a66aa4eb5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.xml.sax.InputSource;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.easymock.classextension.EasyMock;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.BindingManager;
+import static org.objectweb.celtix.bindings.DataBindingCallback.Mode.PARTS;
+import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.soap.SOAPBindingFactory;
+import org.objectweb.celtix.bus.bindings.soap.SOAPServerBinding;
+import org.objectweb.celtix.context.ObjectMessageContextImpl;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CeltixServiceTestCase extends TestCase {
+
+ public void testGetDataBindingCallback() throws Exception {
+ CeltixService celtixService = createCeltixService();
+
+ QName operationName = new QName("greetMe");
+ ObjectMessageContextImpl ctx = new ObjectMessageContextImpl();
+ ctx.setMessageObjects(new String[]{"Celtix"});
+ ServerDataBindingCallback callback1 = celtixService.getDataBindingCallback(operationName, ctx, PARTS);
+ assertNotNull(callback1);
+
+ callback1.invoke(ctx);
+ Object rtn = (String) ctx.getReturn();
+ assertEquals("Hello Celtix", rtn);
+
+ }
+
+ private CeltixService createCeltixService() throws Exception {
+ //Make following call to return a mocked SOAPClientBinding:
+ //bus.getBindingManager().getBindingFactory(bindingId).createClientBinding(reference)
+ SOAPServerBinding serverBinding = EasyMock.createMock(SOAPServerBinding.class);
+ serverBinding.activate();
+ EasyMock.replay(serverBinding);
+
+ //ServerBindingEndpointCallback callback = EasyMock.createNiceMock(ServerBindingEndpointCallback.class);
+
+ SOAPBindingFactory bindingFactory = EasyMock.createNiceMock(SOAPBindingFactory.class);
+ bindingFactory.createServerBinding(EasyMock.isA(EndpointReferenceType.class),
+ EasyMock.isA(ServerBindingEndpointCallback.class));
+ EasyMock.expectLastCall().andReturn(serverBinding);
+ EasyMock.replay(bindingFactory);
+
+ BindingManager bindingManager = EasyMock.createNiceMock(BindingManager.class);
+ String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
+ bindingManager.getBindingFactory(bindingId);
+ EasyMock.expectLastCall().andReturn(bindingFactory);
+
+ Bus bus = EasyMock.createNiceMock(Bus.class);
+ bus.getBindingManager();
+ EasyMock.expectLastCall().andReturn(bindingManager);
+ EasyMock.replay(bindingManager);
+ EasyMock.replay(bus);
+
+ //Create WSDL Definition
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+ "SOAPService"));
+ Port port = wsdlService.getPort("SoapPort");
+
+ WebServiceBinding wsBinding = new WebServiceBinding(wsdlDef, port, "uri", "portURI", wsdlService);
+
+ //Create mocked InboundWire, for ServiceExtension.getInterface()
+ InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.replay(inboundWire);
+
+ //Create mocked WireService, for ServiceExtension.getServiceInstance()
+ WireService wireService = EasyMock.createNiceMock(WireService.class);
+ wireService.createProxy(EasyMock.isA(InboundWire.class));
+ EasyMock.expectLastCall().andReturn(new GreeterImpl()).anyTimes();
+ EasyMock.replay(wireService);
+
+ CeltixService celtixService = new CeltixService("name", Greeter.class, null, wireService, wsBinding, bus, null);
+ //Not sure how InboundWire is set to CeltixService, is the following way correct?
+ celtixService.setInboundWire(inboundWire);
+ celtixService.start();
+
+ return celtixService;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java
new file mode 100644
index 0000000000..56de472774
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+public interface Greeter {
+ java.lang.String sayHi();
+
+ java.lang.String greetMe(
+ java.lang.String requestType
+ );
+
+ void greetMeOneWay(
+ java.lang.String requestType
+ );
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java
new file mode 100644
index 0000000000..38237ad81a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+public class GreeterImpl implements Greeter {
+ public java.lang.String sayHi() {
+ return "sayHi";
+ }
+
+ public java.lang.String greetMe(String requestType) {
+ return "Hello " + requestType;
+ }
+
+ public void greetMeOneWay(String requestType) {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl
new file mode 100644
index 0000000000..e8767988f3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeRequest">
+ <wsdl:part name="in" element="x1:pingMe"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeResponse">
+ <wsdl:part name="out" element="x1:pingMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeFault">
+ <wsdl:part name="faultDetail" element="x1:faultDetail"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+ <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+ <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="pingMeFault">
+ <soap:fault name="pingMeFault" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:serviceDefinition name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:serviceDefinition>
+</wsdl:definitions>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl
new file mode 100644
index 0000000000..db625cb129
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl
new file mode 100644
index 0000000000..90634709ba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMe" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeRequest">
+ <wsdl:part name="in" element="x1:pingMe"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeResponse">
+ <wsdl:part name="out" element="x1:pingMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeFault">
+ <wsdl:part name="faultDetail" element="x1:faultDetail"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+ <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+ <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="pingMeFault">
+ <soap:fault name="pingMeFault" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml
new file mode 100644
index 0000000000..df8a9483d5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml
@@ -0,0 +1,288 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<!--
+Checks to make sure the code meets the Tuscany coding guidelines
+http://java.sun.com/docs/codeconv/index.html
+
+It also enforces aa bunch of other "BestPractices like method
+lengths, if/try depths, etc...
+
+-->
+
+<module name="Checker">
+ <property name="severity"
+ value="${checkstyle.severity}"
+ default="warning"/>
+
+ <!-- Checks whether files end with a new line. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+ <!--
+ <module name="NewlineAtEndOfFile"/>
+ -->
+
+ <!-- Checks that property files contain the same keys. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+ <module name="Translation"/>
+
+ <!--<module name="StrictDuplicateCode"/>-->
+
+ <module name="TreeWalker">
+
+ <!-- Checks for Javadoc comments. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!--
+ <module name="PackageHtml"/>
+ <module name="JavadocMethod"/>
+ <module name="JavadocType"/>
+ <module name="JavadocVariable"/>
+ <module name="JavadocStyle"/>
+ -->
+
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <module name="AbstractClassName">
+ <property name="format"
+ value="^Abstract.*$|^.*Factory$|^.*Bus$|^.*ConfigurationRepository$|^.*Base$|^Exception$|^.*Builder$"/>
+ </module>
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+ <module name="TypeName"/>
+
+ <!-- Header checks -->
+ <!-- <module name="Header"/> -->
+ <!-- <module name="RegexpHeader"/> -->
+
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="AvoidStarImport">
+ <property name="excludes"
+ value="java.io,java.util,java.net,java.nio,java.nio.channels,java.lang.reflect,org.w3c.dom,org.xml.sax,java.awt,javax.swing,junit.framework"/>
+ </module>
+ <module name="IllegalImport"/>
+ <!-- defaults to sun.* packages -->
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="ImportOrder">
+ <property name="groups" value="java,javax,org.w3c,org.xml,w3c"/>
+ <property name="ordered" value="true"/>
+ </module>
+ <!--
+ <module name="ImportControl">
+ <property name="file" value="etc/import-control.xml"/>
+ </module>
+ -->
+
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <module name="AnonInnerLength">
+ <property name="max" value="40"/>
+ </module>
+ <module name="ExecutableStatementCount">
+ <property name="max" value="50"/>
+ </module>
+ <module name="FileLength"/>
+ <module name="LineLength">
+ <property name="max" value="115"/>
+ </module>
+ <module name="MethodLength">
+ <property name="max" value="150"/>
+ <property name="countEmpty" value="false"/>
+ </module>
+ <module name="ParameterNumber">
+ <property name="max" value="7"/>
+ </module>
+
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="EmptyForIteratorPad"/>
+ <module name="EmptyForInitializerPad"/>
+ <module name="MethodParamPad"/>
+ <module name="NoWhitespaceAfter">
+ <property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
+ </module>
+ <module name="NoWhitespaceBefore"/>
+ <module name="OperatorWrap"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ <module name="TabCharacter"/>
+ <module name="WhitespaceAfter">
+ <property name="tokens" value="COMMA, SEMI"/>
+ </module>
+ <module name="WhitespaceAround">
+ <property name="tokens"
+ value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND"/>
+ </module>
+
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <module name="AvoidNestedBlocks">
+ <property name="allowInSwitchCase" value="true"/>
+ </module>
+ <module name="EmptyBlock">
+ <property name="option" value="text"/>
+ </module>
+ <module name="LeftCurly"/>
+ <module name="NeedBraces"/>
+ <module name="RightCurly"/>
+
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!--<module name="ArrayTrailingComma"/>-->
+ <!--<module name="AvoidInlineConditionals"/>-->
+ <module name="CovariantEquals"/>
+ <module name="DoubleCheckedLocking"/>
+ <module name="EmptyStatement"/>
+ <module name="EqualsHashCode"/>
+ <!--<module name="FinalLocalVariable"/>-->
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true"/>
+ <property name="ignoreSetter" value="true"/>
+ <property name="ignoreAbstractMethods" value="true"/>
+ </module>
+ <module name="IllegalInstantiation"/>
+ <!--<module name="IllegalToken"/>-->
+ <!--<module name="IllegalTokenText"/>-->
+ <!--<module name="InnerAssignment"/>-->
+ <!--<module name="MagicNumber"/>-->
+ <module name="MissingSwitchDefault"/>
+ <module name="ModifiedControlVariable"/>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+ <module name="StringLiteralEquality"/>
+ <module name="NestedIfDepth">
+ <property name="max" value="3"/>
+ </module>
+ <module name="NestedTryDepth">
+ <property name="max" value="3"/>
+ </module>
+ <module name="SuperClone"/>
+ <module name="SuperFinalize"/>
+ <!--<module name="IllegalCatch"/>-->
+ <module name="IllegalThrows">
+ <property name="illegalClassNames" value="java.lang.Error,java.lang.RuntimeException"/>
+ </module>
+ <!--<module name="RedundantThrows"/>-->
+ <module name="PackageDeclaration"/>
+ <module name="JUnitTestCase"/>
+ <module name="ReturnCount">
+ <property name="max" value="6"/>
+ </module>
+
+ <module name="IllegalType">
+ <property name="format" value="^xxx$"/>
+ </module>
+ <module name="DeclarationOrder"/>
+ <!--<module name="ParameterAssignment"/>-->
+ <module name="ExplicitInitialization"/>
+ <module name="DefaultComesLast"/>
+ <!--<module name="MissingCtor"/>-->
+ <module name="FallThrough"/>
+ <!--<module name="MultipleStringLiterals"/>-->
+ <module name="MultipleVariableDeclarations"/>
+ <!--<module name="RequireThis"/>-->
+ <module name="UnnecessaryParentheses"/>
+
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!--<module name="DesignForExtension"/>-->
+ <module name="FinalClass"/>
+ <module name="HideUtilityClassConstructor"/>
+ <module name="InterfaceIsType"/>
+ <module name="MutableException"/>
+ <module name="ThrowsCount">
+ <property name="max" value="5"/>
+ </module>
+ <module name="VisibilityModifier">
+ <property name="protectedAllowed" value="true"/>
+ <property name="packageAllowed" value="true"/>
+ </module>
+
+
+ <!-- Metrics checks. -->
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <module name="BooleanExpressionComplexity">
+ <property name="max" value="6"/>
+ </module>
+ <!--<module name="ClassDataAbstractionCoupling"/>-->
+ <!--<module name="ClassFanOutComplexity"/>-->
+ <!--<module name="CyclomaticComplexity"/>-->
+ <!--<module name="NPathComplexity"/>-->
+ <module name="JavaNCSS">
+ <property name="methodMaximum" value="75"/>
+ </module>
+
+
+ <!-- Miscellaneous other checks. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!--
+ <module name="ArrayTypeStyle"/>
+ <module name="FinalParameters"/>
+ -->
+ <!--
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+ -->
+ <module name="TodoComment">
+ <property name="format" value="WARNING"/>
+ </module>
+
+ <module name="UpperEll"/>
+
+ <!--Assert statement may have side effects:-->
+ <module name="DescendantToken">
+ <property name="tokens" value="LITERAL_ASSERT"/>
+ <property name="limitedTokens"
+ value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN"/>
+ <property name="maximumNumber" value="0"/>
+ </module>
+
+ <!--<module name="UncommentedMain"/>-->
+ <module name="TrailingComment"/>
+ <module name="Indentation">
+ <property name="caseIndent" value="0"/>
+ </module>
+ <!--<module name="RequiredRegexp">-->
+ </module>
+
+</module>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset
new file mode 100644
index 0000000000..ac8671859d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml
new file mode 100644
index 0000000000..4fede9927d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>binding-jsonrpc</artifactId>
+ <name>Apache Tuscany Binding for JSON-RPC</name>
+ <description>Implementation of the SCA JSON-RPC Binding</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.metaparadigm</groupId>
+ <artifactId>json-rpc</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java
new file mode 100644
index 0000000000..101bfde6c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.jsonrpc;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBinding extends Binding {
+ private String uri;
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java
new file mode 100644
index 0000000000..85654f1104
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.jsonrpc;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+/**
+ * Builds a Service for JSON-RPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingBuilder extends BindingBuilderExtension<JSONRPCBinding> {
+
+ private ServletHost servletHost;
+
+ @Autowire()
+ public void setServletHost(ServletHost servletHost) {
+ this.servletHost = servletHost;
+ }
+
+ protected Class<JSONRPCBinding> getBindingType() {
+ return JSONRPCBinding.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<JSONRPCBinding> serviceDefinition,
+ DeploymentContext deploymentContext) {
+ Class<?> interfaze = serviceDefinition.getServiceContract().getInterfaceClass();
+
+ return new JSONRPCService(serviceDefinition.getName(), interfaze, parent, wireService, servletHost);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java
new file mode 100644
index 0000000000..9f2a35d912
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.jsonrpc;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Loader for handling <binding.jsonrpc> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class JSONRPCBindingLoader extends LoaderExtension<JSONRPCBinding> {
+ public static final QName BINDING_JSON = new QName(XML_NAMESPACE_1_0, "binding.jsonrpc");
+
+ public JSONRPCBindingLoader(@Autowire
+ LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_JSON;
+ }
+
+ public JSONRPCBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException,
+ LoaderException {
+
+ return new JSONRPCBinding();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java
new file mode 100644
index 0000000000..c7afc4742e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.jsonrpc;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import com.metaparadigm.jsonrpc.JSONRPCBridge;
+import com.metaparadigm.jsonrpc.JSONRPCServlet;
+
+/**
+ *
+ *
+ */
+public class JSONRPCEntryPointServlet extends JSONRPCServlet {
+ private static final long serialVersionUID = 1L;
+
+ String serviceName;
+
+ Object serviceInstance;
+
+ public JSONRPCEntryPointServlet(String serviceName, Object serviceInstance) {
+ this.serviceName = serviceName;
+ this.serviceInstance = serviceInstance;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.metaparadigm.jsonrpc.JSONRPCServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassCastException {
+
+ /*
+ * Create a new bridge for every request to aviod all the problems with JSON-RPC-Java storing the bridge in the session
+ */
+ HttpSession session = request.getSession();
+ try {
+
+ JSONRPCBridge jsonrpcBridge = new JSONRPCBridge();
+ jsonrpcBridge.registerObject(serviceName, serviceInstance);
+ session.setAttribute("JSONRPCBridge", jsonrpcBridge);
+
+ super.service(request, response);
+
+ } finally {
+ session.removeAttribute("JSONRPCBridge");
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java
new file mode 100644
index 0000000000..58d1d087ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.jsonrpc;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.wire.WireService;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCService extends ServiceExtension {
+ private ServletHost servletHost;
+
+ public JSONRPCService(String theName, Class<?> interfaze, CompositeComponent parent, WireService wireService, ServletHost servletHost) {
+
+ super(theName, interfaze, parent, wireService);
+
+ this.servletHost = servletHost;
+ }
+
+ public void start() {
+ super.start();
+
+ JSONRPCEntryPointServlet servlet = new JSONRPCEntryPointServlet(getName(), this.getServiceInstance());
+ servletHost.registerMapping("/" + getName(), servlet);
+ servletHost.registerMapping("/SCA/scripts", new ScriptGetterServlet());
+ }
+
+ @Destroy
+ public void stop() {
+ servletHost.unregisterMapping("/" + getName());
+ servletHost.unregisterMapping("/SCA/scripts");
+
+ super.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java
new file mode 100644
index 0000000000..8f8a96df20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.jsonrpc;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ScriptGetterServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ // private static final String SCA_INIT_JS = "SCA = new JSONRpcClient(\"services/HelloWorldService\");";
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ URL url = getClass().getResource("jsonrpc.js");
+ InputStream is = url.openStream();
+ writeToStream(response, is);
+
+ // writeToStream(response, new ByteArrayInputStream(SCA_INIT_JS.getBytes()));
+ }
+
+ private void writeToStream(HttpServletResponse response, InputStream is) throws IOException {
+ ServletOutputStream os = response.getOutputStream();
+ int i;
+ while ((i = is.read()) != -1) { // NOPMD
+ os.write(i);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl
new file mode 100644
index 0000000000..4081d437c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.jsonrpc">
+
+ <!-- dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <groupId>com.metaparadigm</groupId>
+ <name>json-rpc</name>
+ <version>1.0</version>
+ </dependency -->
+
+ <component name="binding.jsonrpc.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingLoader"/>
+ </component>
+
+ <component name="binding.jsonrpc.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingBuilder"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..aec9bb440b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.jsonrpc">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>com.metaparadigm</group>
+ <name>json-rpc</name>
+ <version>1.0</version>
+ </dependency>
+
+ <component name="binding.jsonrpc.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingLoader"/>
+ </component>
+
+ <component name="binding.jsonrpc.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl
new file mode 100644
index 0000000000..4081d437c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.jsonrpc">
+
+ <!-- dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <groupId>com.metaparadigm</groupId>
+ <name>json-rpc</name>
+ <version>1.0</version>
+ </dependency -->
+
+ <component name="binding.jsonrpc.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingLoader"/>
+ </component>
+
+ <component name="binding.jsonrpc.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingBuilder"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js
new file mode 100644
index 0000000000..2b9efbb55c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js
@@ -0,0 +1,484 @@
+/*
+ * JSON-RPC JavaScript client
+ *
+ * $Id: jsonrpc.js,v 1.36.2.3 2006/03/08 15:09:37 mclark Exp $
+ *
+ * Copyright (c) 2003-2004 Jan-Klaas Kollhof
+ * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
+ *
+ * This code is based on Jan-Klaas' JavaScript o lait library (jsolait).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/* escape a character */
+
+escapeJSONChar =
+function escapeJSONChar(c)
+{
+ if(c == "\"" || c == "\\") return "\\" + c;
+ else if (c == "\b") return "\\b";
+ else if (c == "\f") return "\\f";
+ else if (c == "\n") return "\\n";
+ else if (c == "\r") return "\\r";
+ else if (c == "\t") return "\\t";
+ var hex = c.charCodeAt(0).toString(16);
+ if(hex.length == 1) return "\\u000" + hex;
+ else if(hex.length == 2) return "\\u00" + hex;
+ else if(hex.length == 3) return "\\u0" + hex;
+ else return "\\u" + hex;
+};
+
+
+/* encode a string into JSON format */
+
+escapeJSONString =
+function escapeJSONString(s)
+{
+ /* The following should suffice but Safari's regex is b0rken
+ (doesn't support callback substitutions)
+ return "\"" + s.replace(/([^\u0020-\u007f]|[\\\"])/g,
+ escapeJSONChar) + "\"";
+ */
+
+ /* Rather inefficient way to do it */
+ var parts = s.split("");
+ for(var i=0; i < parts.length; i++) {
+ var c =parts[i];
+ if(c == '"' ||
+ c == '\\' ||
+ c.charCodeAt(0) < 32 ||
+ c.charCodeAt(0) >= 128)
+ parts[i] = escapeJSONChar(parts[i]);
+ }
+ return "\"" + parts.join("") + "\"";
+};
+
+
+/* Marshall objects to JSON format */
+
+toJSON = function toJSON(o)
+{
+ if(o == null) {
+ return "null";
+ } else if(o.constructor == String) {
+ return escapeJSONString(o);
+ } else if(o.constructor == Number) {
+ return o.toString();
+ } else if(o.constructor == Boolean) {
+ return o.toString();
+ } else if(o.constructor == Date) {
+ return '{javaClass: "java.util.Date", time: ' + o.valueOf() +'}';
+ } else if(o.constructor == Array) {
+ var v = [];
+ for(var i = 0; i < o.length; i++) v.push(toJSON(o[i]));
+ return "[" + v.join(", ") + "]";
+ } else {
+ var v = [];
+ for(attr in o) {
+ if(o[attr] == null) v.push("\"" + attr + "\": null");
+ else if(typeof o[attr] == "function"); /* skip */
+ else v.push(escapeJSONString(attr) + ": " + toJSON(o[attr]));
+ }
+ return "{" + v.join(", ") + "}";
+ }
+};
+
+
+/* JSONRpcClient constructor */
+
+JSONRpcClient =
+function JSONRpcClient_ctor(serverURL, user, pass, objectID)
+{
+ this.serverURL = serverURL;
+ this.user = user;
+ this.pass = pass;
+ this.objectID = objectID;
+
+ /* Add standard methods */
+ if(this.objectID) {
+ this._addMethods(["listMethods"]);
+ var req = this._makeRequest("listMethods", []);
+ } else {
+ this._addMethods(["system.listMethods"]);
+ var req = this._makeRequest("system.listMethods", []);
+ }
+ var m = this._sendRequest(req);
+ this._addMethods(m);
+};
+
+
+/* JSONRpcCLient.Exception */
+
+JSONRpcClient.Exception =
+function JSONRpcClient_Exception_ctor(code, message, javaStack)
+{
+ this.code = code;
+ var name;
+ if(javaStack) {
+ this.javaStack = javaStack;
+ var m = javaStack.match(/^([^:]*)/);
+ if(m) name = m[0];
+ }
+ if(name) this.name = name;
+ else this.name = "JSONRpcClientException";
+ this.message = message;
+};
+
+JSONRpcClient.Exception.CODE_REMOTE_EXCEPTION = 490;
+JSONRpcClient.Exception.CODE_ERR_CLIENT = 550;
+JSONRpcClient.Exception.CODE_ERR_PARSE = 590;
+JSONRpcClient.Exception.CODE_ERR_NOMETHOD = 591;
+JSONRpcClient.Exception.CODE_ERR_UNMARSHALL = 592;
+JSONRpcClient.Exception.CODE_ERR_MARSHALL = 593;
+
+JSONRpcClient.Exception.prototype = new Error();
+
+JSONRpcClient.Exception.prototype.toString =
+function JSONRpcClient_Exception_toString(code, msg)
+{
+ return this.name + ": " + this.message;
+};
+
+
+/* Default top level exception handler */
+
+JSONRpcClient.default_ex_handler =
+function JSONRpcClient_default_ex_handler(e) { alert(e); };
+
+
+/* Client settable variables */
+
+JSONRpcClient.toplevel_ex_handler = JSONRpcClient.default_ex_handler;
+JSONRpcClient.profile_async = false;
+JSONRpcClient.max_req_active = 1;
+JSONRpcClient.requestId = 1;
+
+
+/* JSONRpcClient implementation */
+
+JSONRpcClient.prototype._createMethod =
+function JSONRpcClient_createMethod(methodName)
+{
+ var fn=function()
+ {
+ var args = [];
+ var callback = null;
+ for(var i=0;i<arguments.length;i++) args.push(arguments[i]);
+ if(typeof args[0] == "function") callback = args.shift();
+ var req = fn.client._makeRequest.call(fn.client, fn.methodName,
+ args, callback);
+ if(callback == null) {
+ return fn.client._sendRequest.call(fn.client, req);
+ } else {
+ JSONRpcClient.async_requests.push(req);
+ JSONRpcClient.kick_async();
+ return req.requestId;
+ }
+ };
+ fn.client = this;
+ fn.methodName = methodName;
+ return fn;
+};
+
+JSONRpcClient.prototype._addMethods =
+function JSONRpcClient_addMethods(methodNames)
+{
+ for(var i=0; i<methodNames.length; i++) {
+ var obj = this;
+ var names = methodNames[i].split(".");
+ for(var n=0; n<names.length-1; n++) {
+ var name = names[n];
+ if(obj[name]) {
+ obj = obj[name];
+ } else {
+ obj[name] = new Object();
+ obj = obj[name];
+ }
+ }
+ var name = names[names.length-1];
+ if(!obj[name]) {
+ var method = this._createMethod(methodNames[i]);
+ obj[name] = method;
+ }
+ }
+};
+
+JSONRpcClient._getCharsetFromHeaders =
+function JSONRpcClient_getCharsetFromHeaders(http)
+{
+ try {
+ var contentType = http.getResponseHeader("Content-type");
+ var parts = contentType.split(/\s*;\s*/);
+ for(var i =0; i < parts.length; i++) {
+ if(parts[i].substring(0, 8) == "charset=")
+ return parts[i].substring(8, parts[i].length);
+ }
+ } catch (e) {}
+ return "UTF-8"; /* default */
+};
+
+/* Async queue globals */
+JSONRpcClient.async_requests = [];
+JSONRpcClient.async_inflight = {};
+JSONRpcClient.async_responses = [];
+JSONRpcClient.async_timeout = null;
+JSONRpcClient.num_req_active = 0;
+
+JSONRpcClient._async_handler =
+function JSONRpcClient_async_handler()
+{
+ JSONRpcClient.async_timeout = null;
+
+ while(JSONRpcClient.async_responses.length > 0) {
+ var res = JSONRpcClient.async_responses.shift();
+ if(res.canceled) continue;
+ if(res.profile) res.profile.dispatch = new Date();
+ try {
+ res.cb(res.result, res.ex, res.profile);
+ } catch(e) {
+ JSONRpcClient.toplevel_ex_handler(e);
+ }
+ }
+
+ while(JSONRpcClient.async_requests.length > 0 &&
+ JSONRpcClient.num_req_active < JSONRpcClient.max_req_active) {
+ var req = JSONRpcClient.async_requests.shift();
+ if(req.canceled) continue;
+ req.client._sendRequest.call(req.client, req);
+ }
+};
+
+JSONRpcClient.kick_async =
+function JSONRpcClient_kick_async()
+{
+ if(JSONRpcClient.async_timeout == null)
+ JSONRpcClient.async_timeout =
+ setTimeout(JSONRpcClient._async_handler, 0);
+};
+
+JSONRpcClient.cancelRequest =
+function JSONRpcClient_cancelRequest(requestId)
+{
+ /* If it is in flight then mark it as canceled in the inflight map
+ and the XMLHttpRequest callback will discard the reply. */
+ if(JSONRpcClient.async_inflight[requestId]) {
+ JSONRpcClient.async_inflight[requestId].canceled = true;
+ return true;
+ }
+
+ /* If its not in flight yet then we can just mark it as canceled in
+ the the request queue and it will get discarded before being sent. */
+ for(var i in JSONRpcClient.async_requests) {
+ if(JSONRpcClient.async_requests[i].requestId == requestId) {
+ JSONRpcClient.async_requests[i].canceled = true;
+ return true;
+ }
+ }
+
+ /* It may have returned from the network and be waiting for its callback
+ to be dispatched, so mark it as canceled in the response queue
+ and the response will get discarded before calling the callback. */
+ for(var i in JSONRpcClient.async_responses) {
+ if(JSONRpcClient.async_responses[i].requestId == requestId) {
+ JSONRpcClient.async_responses[i].canceled = true;
+ return true;
+ }
+ }
+
+ return false;
+};
+
+JSONRpcClient.prototype._makeRequest =
+function JSONRpcClient_makeRequest(methodName, args, cb)
+{
+ var req = {};
+ req.client = this;
+ req.requestId = JSONRpcClient.requestId++;
+
+ var obj = {};
+ obj.id = req.requestId;
+ if (this.objectID)
+ obj.method = ".obj#" + this.objectID + "." + methodName;
+ else
+ obj.method = methodName;
+ obj.params = args;
+
+ if (cb) req.cb = cb;
+ if (JSONRpcClient.profile_async)
+ req.profile = { "submit": new Date() };
+ req.data = toJSON(obj);
+
+ return req;
+};
+
+JSONRpcClient.prototype._sendRequest =
+function JSONRpcClient_sendRequest(req)
+{
+ if(req.profile) req.profile.start = new Date();
+
+ /* Get free http object from the pool */
+ var http = JSONRpcClient.poolGetHTTPRequest();
+ JSONRpcClient.num_req_active++;
+
+ /* Send the request */
+ if (typeof(this.user) == "undefined") {
+ http.open("POST", this.serverURL, (req.cb != null));
+ } else {
+ http.open("POST", this.serverURL, (req.cb != null), this.user, this.pass);
+ }
+
+ /* setRequestHeader is missing in Opera 8 Beta */
+ try { http.setRequestHeader("Content-type", "text/plain"); } catch(e) {}
+
+ /* Construct call back if we have one */
+ if(req.cb) {
+ var self = this;
+ http.onreadystatechange = function() {
+ if(http.readyState == 4) {
+ http.onreadystatechange = function () {};
+ var res = { "cb": req.cb, "result": null, "ex": null};
+ if (req.profile) {
+ res.profile = req.profile;
+ res.profile.end = new Date();
+ }
+ try { res.result = self._handleResponse(http); }
+ catch(e) { res.ex = e; }
+ if(!JSONRpcClient.async_inflight[req.requestId].canceled)
+ JSONRpcClient.async_responses.push(res);
+ delete JSONRpcClient.async_inflight[req.requestId];
+ JSONRpcClient.kick_async();
+ }
+ };
+ } else {
+ http.onreadystatechange = function() {};
+ }
+
+ JSONRpcClient.async_inflight[req.requestId] = req;
+
+ try {
+ http.send(req.data);
+ } catch(e) {
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+ throw new JSONRpcClient.Exception
+ (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed");
+ }
+
+ if(!req.cb) return this._handleResponse(http);
+};
+
+JSONRpcClient.prototype._handleResponse =
+function JSONRpcClient_handleResponse(http)
+{
+ /* Get the charset */
+ if(!this.charset) {
+ this.charset = JSONRpcClient._getCharsetFromHeaders(http);
+ }
+
+ /* Get request results */
+ var status, statusText, data;
+ try {
+ status = http.status;
+ statusText = http.statusText;
+ data = http.responseText;
+ } catch(e) {
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+ JSONRpcClient.kick_async();
+ throw new JSONRpcClient.Exception
+ (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed");
+ }
+
+ /* Return http object to the pool; */
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+
+ /* Unmarshall the response */
+ if(status != 200) {
+ throw new JSONRpcClient.Exception(status, statusText);
+ }
+ var obj;
+ try {
+ eval("obj = " + data);
+ } catch(e) {
+ throw new JSONRpcClient.Exception(550, "error parsing result");
+ }
+ if(obj.error)
+ throw new JSONRpcClient.Exception(obj.error.code, obj.error.msg,
+ obj.error.trace);
+ var res = obj.result;
+
+ /* Handle CallableProxy */
+ if(res && res.objectID && res.JSONRPCType == "CallableReference")
+ return new JSONRpcClient(this.serverURL, this.user,
+ this.pass, res.objectID);
+
+ return res;
+};
+
+
+/* XMLHttpRequest wrapper code */
+
+/* XMLHttpRequest pool globals */
+JSONRpcClient.http_spare = [];
+JSONRpcClient.http_max_spare = 8;
+
+JSONRpcClient.poolGetHTTPRequest =
+function JSONRpcClient_pool_getHTTPRequest()
+{
+ if(JSONRpcClient.http_spare.length > 0) {
+ return JSONRpcClient.http_spare.pop();
+ }
+ return JSONRpcClient.getHTTPRequest();
+};
+
+JSONRpcClient.poolReturnHTTPRequest =
+function JSONRpcClient_poolReturnHTTPRequest(http)
+{
+ if(JSONRpcClient.http_spare.length >= JSONRpcClient.http_max_spare)
+ delete http;
+ else
+ JSONRpcClient.http_spare.push(http);
+};
+
+JSONRpcClient.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+ "MSXML2.XMLHTTP.4.0",
+ "MSXML2.XMLHTTP.3.0",
+ "MSXML2.XMLHTTP",
+ "Microsoft.XMLHTTP" ];
+
+JSONRpcClient.getHTTPRequest =
+function JSONRpcClient_getHTTPRequest()
+{
+ /* Mozilla XMLHttpRequest */
+ try {
+ JSONRpcClient.httpObjectName = "XMLHttpRequest";
+ return new XMLHttpRequest();
+ } catch(e) {}
+
+ /* Microsoft MSXML ActiveX */
+ for (var i=0;i < JSONRpcClient.msxmlNames.length; i++) {
+ try {
+ JSONRpcClient.httpObjectName = JSONRpcClient.msxmlNames[i];
+ return new ActiveXObject(JSONRpcClient.msxmlNames[i]);
+ } catch (e) {}
+ }
+
+ /* None found */
+ JSONRpcClient.httpObjectName = null;
+ throw new JSONRpcClient.Exception(0, "Can't create XMLHttpRequest object");
+};
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml
new file mode 100755
index 0000000000..31ef8047d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>rmi</artifactId>
+ <name>Apache Tuscany Binding for Java RMI</name>
+ <description>Implementation of the SCA RMI Binding</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
new file mode 100644
index 0000000000..45404f087e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NoRemoteMethodException extends RMIRuntimeException {
+ public NoRemoteMethodException() {
+ }
+
+ public NoRemoteMethodException(String message) {
+ super(message);
+ }
+
+ public NoRemoteMethodException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoRemoteMethodException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
new file mode 100644
index 0000000000..af2d2fd582
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NoRemoteServiceException extends RMIRuntimeException {
+ public NoRemoteServiceException() {
+ }
+
+ public NoRemoteServiceException(String message) {
+ super(message);
+ }
+
+ public NoRemoteServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoRemoteServiceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
new file mode 100644
index 0000000000..bc8c69851e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBinding extends Binding {
+ private String host;
+
+ private String port;
+
+ private String serviceName;
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
new file mode 100644
index 0000000000..1e2eb9633a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.rmi.Remote;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Builds a Service or Reference for an RMI binding.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class RMIBindingBuilder extends BindingBuilderExtension<RMIBinding> {
+
+ private RMIHost rmiHost;
+
+ @Constructor({"rmiHost"})
+ public RMIBindingBuilder(@Autowire RMIHost rHost) {
+ this.rmiHost = rHost;
+ }
+
+ protected Class<RMIBinding> getBindingType() {
+ return RMIBinding.class;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<RMIBinding> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+
+ Class intf = boundServiceDefinition.getServiceContract().getInterfaceClass();
+
+ return new RMIService<Remote>(boundServiceDefinition.getName(), parent, wireService, rmiHost,
+ boundServiceDefinition.getBinding().getHost(), boundServiceDefinition.getBinding().getPort(),
+ boundServiceDefinition.getBinding().getServiceName(), intf);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<RMIBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ String name = boundReferenceDefinition.getName();
+ String host = boundReferenceDefinition.getBinding().getHost();
+ String port = boundReferenceDefinition.getBinding().getPort();
+ String svcName = boundReferenceDefinition.getBinding().getServiceName();
+ // Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
+
+ return new RMIReference(name, parent, wireService, rmiHost, host, port, svcName,
+ boundReferenceDefinition.getServiceContract().getInterfaceClass());
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
new file mode 100755
index 0000000000..bd9b165b6d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+
+/**
+ * Loader for handling <binding.rmi> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class RMIBindingLoader extends LoaderExtension<RMIBinding> {
+ public static final QName BINDING_RMI = new QName(
+ "http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2", "binding.rmi");
+
+ public RMIBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_RMI;
+ }
+
+ public RMIBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ String host = reader.getAttributeValue(null, "host");
+ String port = reader.getAttributeValue(null, "port");
+ String svcName = reader.getAttributeValue(null, "serviceName");
+ LoaderUtil.skipToEndElement(reader);
+ RMIBinding binding = new RMIBinding();
+ binding.setHost(host);
+ binding.setPort(port);
+ binding.setServiceName(svcName);
+ return binding;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
new file mode 100644
index 0000000000..afd1992d20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Invoke an RMI reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIInvoker extends TargetInvokerExtension {
+ private Method remoteMethod;
+ private String host;
+ private String port;
+ private String svcName;
+ private RMIHost rmiHost;
+ private Remote proxy;
+
+ public RMIInvoker(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) {
+ // assert remoteMethod.isAccessible();
+ this.remoteMethod = remoteMethod;
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ if (proxy == null) {
+ proxy = rmiHost.findService(host, port, svcName);
+ // proxy = Naming.lookup(serviceURI);
+ }
+ return remoteMethod.invoke(proxy, (Object[]) payload);
+ } catch (RMIHostException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java
new file mode 100644
index 0000000000..5e810892d9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java
@@ -0,0 +1,87 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RMIReference<T> extends ReferenceExtension {
+ private final String host;
+
+ private final String port;
+
+ private final String svcName;
+
+ private RMIHost rmiHost;
+
+ public RMIReference(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ RMIHost rmiHost,
+ String host,
+ String port,
+ String svcName,
+ Class<T> service) {
+ super(name, service, parent, wireService);
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ try {
+ /*Remote proxy = getProxy();
+ Method remoteMethod = proxy.getClass().getMethod(operation.getName(),
+ (Class[]) operation.getParameterTypes());
+ return new RMIInvoker(proxy, remoteMethod);
+ */
+ Method method = findMethod(operation, contract.getInterfaceClass().getMethods());
+ Method remoteMethod =
+ getInterface().getMethod(operation.getName(), (Class[]) method.getParameterTypes());
+ return new RMIInvoker(rmiHost, host, port, svcName, remoteMethod);
+ } catch (NoSuchMethodException e) {
+ throw new NoRemoteMethodException(operation.toString(), e);
+ }
+ }
+
+ /*protected Remote getProxy() {
+ try {
+ // todo do we need to cache this result?
+ return Naming.lookup(uri);
+ } catch (NotBoundException e) {
+ throw new NoRemoteServiceException(uri);
+ } catch (MalformedURLException e) {
+ throw new NoRemoteServiceException(uri);
+ } catch (RemoteException e) {
+ throw new NoRemoteServiceException(uri);
+ }
+ }*/
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
new file mode 100644
index 0000000000..c36dec4531
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class RMIRuntimeException extends TuscanyRuntimeException {
+ protected RMIRuntimeException() {
+ }
+
+ protected RMIRuntimeException(String message) {
+ super(message);
+ }
+
+ protected RMIRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected RMIRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java
new file mode 100644
index 0000000000..0de833801f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java
@@ -0,0 +1,160 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.server.UnicastRemoteObject;
+
+import net.sf.cglib.asm.ClassWriter;
+import net.sf.cglib.asm.Constants;
+import net.sf.cglib.asm.Type;
+import net.sf.cglib.proxy.Enhancer;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RMIService<T extends Remote> extends ServiceExtension {
+
+ public static final String URI_PREFIX = "//localhost";
+ public static final String SLASH = "/";
+ public static final String COLON = ":";
+ //private final String host;
+ private final String port;
+ private final String serviceName;
+ private RMIHost rmiHost;
+
+ // need this member to morph the service interface to extend from Remote if it does not
+ // the base class's member variable interfaze is to be maintained to enable the connection
+ // of the service outbound to the component's inbound wire which requires that the service
+ // and the component match in their service contracts.
+ private Class serviceInterface;
+
+ public RMIService(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ RMIHost rHost,
+ String host,
+ String port,
+ String svcName,
+ Class<T> service) {
+ super(name, service, parent, wireService);
+
+ this.serviceInterface = service;
+ this.rmiHost = rHost;
+ //this.host = host;
+ this.port = port;
+ this.serviceName = svcName;
+ }
+
+ public void start() {
+ super.start();
+ Remote rmiProxy = createRmiService();
+
+ try {
+ // startRMIRegistry();
+ rmiHost.registerService(serviceName,
+ getPort(port),
+ rmiProxy);
+ // bindRmiService(uri,rmiProxy);
+ } catch (RMIHostException e) {
+ throw new NoRemoteServiceException(e);
+ }
+ }
+
+ public void stop() {
+ try {
+ rmiHost.unregisterService(serviceName, getPort(port));
+ } catch (RMIHostException e) {
+ throw new NoRemoteServiceException(e.getMessage());
+ }
+ super.stop();
+ }
+
+ protected Remote createRmiService() {
+ Enhancer enhancer = new Enhancer();
+ enhancer.setSuperclass(UnicastRemoteObject.class);
+ enhancer.setCallback(new RemoteMethodHandler(getHandler(), interfaze));
+
+ if (!Remote.class.isAssignableFrom(serviceInterface)) {
+ RMIServiceClassLoader classloader =
+ new RMIServiceClassLoader(getClass().getClassLoader());
+ final byte[] byteCode = generateRemoteInterface(serviceInterface);
+ serviceInterface = classloader.defineClass(byteCode);
+ enhancer.setClassLoader(classloader);
+ }
+ enhancer.setInterfaces(new Class[]{serviceInterface});
+ return (Remote) enhancer.create();
+ }
+
+ protected int getPort(String port) {
+ int portNumber = RMIHost.RMI_DEFAULT_PORT;
+ if (port != null && port.length() > 0) {
+ portNumber = Integer.decode(port);
+ }
+
+ return portNumber;
+ }
+
+ // if the interface of the component whose services must be exposed as RMI Service, does not
+ // implement java.rmi.Remote, then generate such an interface. This method will stop with
+ // just generating the bytecode. Defining the class from the byte code must tbe the responsibility
+ // of the caller of this method, since it requires a classloader to be created to define and load
+ // this interface.
+ protected byte[] generateRemoteInterface(Class serviceInterface) {
+ String interfazeName = serviceInterface.getCanonicalName();
+ ClassWriter cw = new ClassWriter(false);
+
+ String simpleName = serviceInterface.getSimpleName();
+ cw.visit(Constants.V1_5, Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE,
+ interfazeName.replace('.', '/'), "java/lang/Object", new String[]{"java/rmi/Remote"}, simpleName + ".java");
+
+ StringBuffer argsAndReturn = null;
+ Method[] methods = serviceInterface.getMethods();
+ for (Method method : methods) {
+ argsAndReturn = new StringBuffer("(");
+ Class[] paramTypes = method.getParameterTypes();
+ Class returnType = method.getReturnType();
+
+ for (Class paramType : paramTypes) {
+ argsAndReturn.append(Type.getType(paramType));
+ }
+ argsAndReturn.append(")");
+ argsAndReturn.append(Type.getType(returnType));
+
+ cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT, method.getName(), argsAndReturn.toString(),
+ new String[]{"java/rmi/RemoteException"}, null);
+ }
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ private class RMIServiceClassLoader extends ClassLoader {
+ public RMIServiceClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+ public Class defineClass(byte[] byteArray) {
+ return defineClass(null, byteArray, 0, byteArray.length);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
new file mode 100644
index 0000000000..b27c87b510
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+public class RemoteMethodHandler implements MethodInterceptor {
+ public static final String FINALIZE_METHOD = "finalize";
+
+ private WireInvocationHandler wireHandler;
+
+ private Class compSvcIntf;
+
+ public RemoteMethodHandler(WireInvocationHandler handler, Class intf) {
+ this.wireHandler = handler;
+ compSvcIntf = intf;
+ }
+
+ public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
+ // since incoming method signatures have 'remotemethod invocation' it will not match with the
+ // wired component's method signatures. Hence need to pull in the corresponding method from the
+ // component's service contract interface to make this invocation.
+ return wireHandler.invoke(compSvcIntf.getMethod(method.getName(),
+ (Class[]) method.getParameterTypes()),
+ args);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java
new file mode 100644
index 0000000000..9355cf642e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java
@@ -0,0 +1,136 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi.host;
+
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * This class provides an implementation for the RMI Host SPIs
+ */
+@Scope("MODULE")
+public class RMIHostImpl implements RMIHost {
+
+ // map of RMI registries started and running
+ private Map<String, Registry> rmiRegistries;
+
+ public RMIHostImpl() {
+ rmiRegistries = new ConcurrentHashMap<String, Registry>();
+ /*
+ * if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); }
+ */
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+ try {
+ registry = rmiRegistries.get(Integer.toString(port));
+ if (registry == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.bind(serviceName,
+ serviceObject);
+ } catch (AlreadyBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ }
+
+ }
+
+ public void registerService(String serviceName, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException {
+ registerService(serviceName,
+ RMI_DEFAULT_PORT,
+ serviceObject);
+ }
+
+ public void unregisterService(String serviceName, int port) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+
+ try {
+ registry = rmiRegistries.get(Integer.toString(port));
+ if (registry == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.unbind(serviceName);
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ }
+
+ public void unregisterService(String serviceName) throws RMIHostException,
+ RMIHostRuntimeException {
+ unregisterService(serviceName,
+ RMI_DEFAULT_PORT);
+
+ }
+
+ public Remote findService(String host, String port, String svcName) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+ Remote remoteService = null;
+ host = (host == null || host.length() <= 0) ? "localhost" : host;
+ int portNumber = (port == null || port.length() <= 0) ? RMI_DEFAULT_PORT : Integer
+ .decode(port);
+
+ try {
+ registry = LocateRegistry.getRegistry(host,
+ portNumber);
+
+ if (registry != null) {
+ remoteService = registry.lookup(svcName);
+ }
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ return remoteService;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..61d6523472
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ xmlns:tuscany="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.rmi">
+
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.bindings</group>
+ <name>rmi</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.kernel</group>
+ <name>tuscany-api</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="binding.rmi.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingLoader"/>
+ </component>
+
+ <component name="binding.rmi.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingBuilder"/>
+ </component>
+
+ <!-- RMI Host service -->
+ <component name="rmiHost">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.host.RMIHostImpl"/>
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl
new file mode 100644
index 0000000000..9417a1d5ad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ xmlns:tuscany="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.rmi">
+
+ <component name="binding.rmi.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingLoader"/>
+ </component>
+
+ <component name="binding.rmi.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingBuilder"/>
+ </component>
+
+ <!-- RMI Host service -->
+ <component name="rmiHost">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.host.RMIHostImpl"/>
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..ef17df1e9d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello from the RMI Service to - " + name;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
new file mode 100644
index 0000000000..a63d8d162c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldRmiService.class)
+public class HelloWorldRmiImpl implements HelloWorldRmiService {
+ @Reference
+ private HelloWorldService extService;
+
+ public HelloWorldService getExtService() {
+ return extService;
+ }
+
+ @Reference
+ public void setExtService(HelloWorldService extService) {
+ this.extService = extService;
+ }
+
+ public String sayRmiHello(String name) {
+ return extService.sayHello(name) + " thro the RMI Reference";
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java
new file mode 100644
index 0000000000..b6b99f45e3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldRmiService {
+
+ String sayRmiHello(String name);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..25f2b1da31
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
new file mode 100644
index 0000000000..7ebee2af66
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import helloworld.HelloWorldRmiService;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+// TODO: renamed to XXX as it doesn't work for me
+public class BindingTestCase extends SCATestCase {
+ private HelloWorldRmiService helloWorldRmiService;
+
+ public void testRmiService() {
+ System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!"));
+ assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference",
+ helloWorldRmiService.sayRmiHello("Tuscany World!"));
+ }
+
+ protected void setUp() throws Exception {
+ addExtension("rmi.binding",
+ getClass().getClassLoader().getResource("META-INF/sca/rmi_extension.scdl"));
+ setApplicationSCDL(getClass().getClassLoader().getResource("META-INF/sca/default.scdl"));
+
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ helloWorldRmiService = context.locateService(HelloWorldRmiService.class,
+ "HelloWorldRmiServiceComponent");
+ }
+
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java
new file mode 100644
index 0000000000..cb4911a0a5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import junit.framework.TestCase;
+
+public class NoRemoteMethodExceptionTestCase extends TestCase {
+
+ public void testNoArgs() {
+ assertNotNull(new NoRemoteMethodException());
+ }
+
+ public void testMsgArg() {
+ NoRemoteMethodException e = new NoRemoteMethodException("foo");
+ assertEquals("foo", e.getMessage());
+ }
+
+ public void test2Args() {
+ Exception cause = new Exception();
+ NoRemoteMethodException e = new NoRemoteMethodException("foo", cause);
+ assertEquals("foo", e.getMessage());
+ assertEquals(cause, e.getCause());
+ }
+
+ public void testCauseArgs() {
+ Exception cause = new Exception();
+ NoRemoteMethodException e = new NoRemoteMethodException(cause);
+ assertEquals(cause, e.getCause());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java
new file mode 100644
index 0000000000..a5da001ad9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import junit.framework.TestCase;
+
+public class NoRemoteServiceExceptionTestCase extends TestCase {
+
+ public void testNoArgs() {
+ assertNotNull(new NoRemoteServiceException());
+ }
+
+ public void testMsgArg() {
+ NoRemoteServiceException e = new NoRemoteServiceException("foo");
+ assertEquals("foo", e.getMessage());
+ }
+
+ public void test2Args() {
+ Exception cause = new Exception();
+ NoRemoteServiceException e = new NoRemoteServiceException("foo", cause);
+ assertEquals("foo", e.getMessage());
+ assertEquals(cause, e.getCause());
+ }
+
+ public void testCauseArgs() {
+ Exception cause = new Exception();
+ NoRemoteServiceException e = new NoRemoteServiceException(cause);
+ assertEquals(cause, e.getCause());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java
new file mode 100644
index 0000000000..b74be6d78b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+public class RMIBindingBuilderTestCase extends TestCase {
+
+ public void testGetBindingType() {
+ assertEquals(RMIBinding.class, new RMIBindingBuilder(null).getBindingType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuildService() {
+ RMIBindingBuilder builder = new RMIBindingBuilder(null);
+ BoundReferenceDefinition<RMIBinding> def = createMock(BoundReferenceDefinition.class);
+ expect(def.getName()).andReturn("petra");
+ RMIBinding binding = new RMIBinding();
+ expect(def.getBinding()).andReturn(binding );
+ expect(def.getBinding()).andReturn(binding );
+ expect(def.getBinding()).andReturn(binding );
+ ServiceContract sc = createMock(ServiceContract.class);
+ expect(def.getServiceContract()).andReturn(sc);
+ replay(def);
+ Object ref = builder.build(null, def, null);
+ assertTrue(ref instanceof RMIReference);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java
new file mode 100644
index 0000000000..160ca19b8a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+public class RMIBindingLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private LoaderRegistry registry;
+
+ private RMIBindingLoader loader;
+
+ public void testLoad() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "host")).andReturn("host");
+ expect(reader.getAttributeValue(null, "port")).andReturn("0");
+ expect(reader.getAttributeValue(null, "serviceName")).andReturn("servicename");
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ RMIBindingLoader mockLoader = new RMIBindingLoader(registry);
+ mockLoader.load(parent, reader, deploymentContext);
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals(RMIBindingLoader.BINDING_RMI, loader.getXMLType());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new RMIBindingLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java
new file mode 100644
index 0000000000..6dbb81437f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import junit.framework.TestCase;
+
+public class RMIBindingTestCase extends TestCase {
+
+ public void testHost() {
+ RMIBinding binding = new RMIBinding();
+ binding.setHost("foo");
+ assertEquals("foo", binding.getHost());
+ }
+
+ public void testPort() {
+ RMIBinding binding = new RMIBinding();
+ binding.setPort("foo");
+ assertEquals("foo", binding.getPort());
+ }
+
+ public void testServiceName() {
+ RMIBinding binding = new RMIBinding();
+ binding.setServiceName("foo");
+ assertEquals("foo", binding.getServiceName());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java
new file mode 100644
index 0000000000..72c0acacc4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java
@@ -0,0 +1,84 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+
+public class RMIInvokerTestCase extends TestCase {
+
+ public void testInvokeTarget() throws InvocationTargetException, RMIHostRuntimeException, RMIHostException, IllegalArgumentException,
+ IllegalAccessException, SecurityException, NoSuchMethodException {
+ Method method = Object.class.getDeclaredMethod("toString", new Class[] {});
+ RMIHost host = createMock(RMIHost.class);
+ expect(host.findService(null, null, null)).andReturn(new Remote() {
+ });
+ replay(host);
+ RMIInvoker invoker = new RMIInvoker(host, null, null, null, method);
+ assertNotNull(invoker.invokeTarget(new Object[] {}));
+ }
+
+// TODO: these don't seem to work
+// public void testInvokeTargetRMIHostException() throws InvocationTargetException, RMIHostRuntimeException, RMIHostException,
+// IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchMethodException {
+// Method method = foo.class.getDeclaredMethod("bang", new Class[] {});
+// RMIHost host = createMock(RMIHost.class);
+// expect(host.findService(null, null, null)).andReturn(new foo());
+// replay(host);
+// try {
+// new RMIInvoker(host, null, null, null, method).invokeTarget(new Object[] {});
+// fail();
+// } catch (InvocationTargetException e) {
+// // expected
+// }
+// }
+//
+// public void testInvokeTargetIllegalAccessException() throws InvocationTargetException, RMIHostRuntimeException, RMIHostException,
+// IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchMethodException {
+// Method method = foo.class.getDeclaredMethod("crash", new Class[] {});
+// RMIHost host = createMock(RMIHost.class);
+// expect(host.findService(null, null, null)).andReturn(new foo());
+// replay(host);
+// try {
+// new RMIInvoker(host, null, null, null, method).invokeTarget(new Object[] {});
+// fail();
+// } catch (InvocationTargetException e) {
+// // expected
+// }
+// }
+//
+// class foo implements Remote {
+// void crash() throws IllegalAccessException {
+// throw new IllegalAccessException();
+// }
+//
+// void bang() throws RMIHostException {
+// throw new RMIHostException();
+// }
+// }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java
new file mode 100644
index 0000000000..5c935ec38a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+public class RMIReferenceTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testCreateTargetInvoker() {
+ // TODO: this doesn't really test anything yet
+ RMIReference ref = new RMIReference(null, null, null, null, null, null, null, null);
+ ServiceContract contract = new JavaServiceContract();
+ contract.setInterfaceClass(String.class);
+ List l = new ArrayList();
+ l.add(new DataType(null, null));
+ DataType in = new DataType(null, l);
+ Operation operation = new Operation(null, in, null, null);
+ try {
+ ref.createTargetInvoker(contract, operation);
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java
new file mode 100644
index 0000000000..1386cf2c72
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.binding.rmi.host.RMIHostImpl;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+public class RMIServiceTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testGetPort() {
+ RMIService s = new RMIService(null, null, null, null, null, null, null, null);
+ assertEquals(0, s.getPort("0"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGenerateRemoteInterface() {
+ RMIService s = new RMIService("foo27", null, null, null, null, null, null, null);
+ s.generateRemoteInterface(Runnable.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateRmiService() {
+ RMIService s = new RMIService("bla023", null, null, new RMIHostImpl(), null, "9996", "bla", Runnable.class) {
+ public WireInvocationHandler getHandler() {
+ return null;
+ }
+ };
+ s.start();
+ try {
+ s.stop();
+ } catch (RMIHostRuntimeException e) {
+ // expected
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java
new file mode 100644
index 0000000000..f5c9595aa3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+public class RemoteMethodHandlerTestCase extends TestCase {
+
+ public void testIntercept() throws SecurityException, NoSuchMethodException, Throwable {
+ WireInvocationHandler h2 = createMock(WireInvocationHandler.class);
+ Method method = Runnable.class.getDeclaredMethod("run", new Class[]{});
+ Object[] noArgs = new Object[]{};
+ expect(h2.invoke(method, noArgs)).andReturn("foo");
+ replay(h2);
+ RemoteMethodHandler handler = new RemoteMethodHandler(h2, Runnable.class);
+ Object o = handler.intercept(null, method, noArgs, null);
+ assertEquals("foo", o);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java
new file mode 100644
index 0000000000..08f6172f3d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.binding.rmi.host;
+
+import java.rmi.Remote;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+
+public class RMIHostImplTestCase extends TestCase {
+
+ public void testInit() {
+ new RMIHostImpl().init();
+ }
+
+ public void testFindServiceBadHost() throws RMIHostRuntimeException, RMIHostException {
+ try {
+ new RMIHostImpl().findService(null, "0", null);
+ fail();
+ } catch (RMIHostRuntimeException e) {
+ // expected
+ }
+ }
+
+ public void testRegisterService1() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ host.registerService("foo1", new MockRemote());
+ host.unregisterService("foo1");
+ }
+
+ public void testRegisterService2() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ host.registerService("bar1", 9999, new MockRemote());
+ host.unregisterService("bar1", 9999);
+ }
+
+ public void testRegisterServiceAlreadyBound() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ host.registerService("bar2", 9997, new MockRemote());
+ try {
+ host.registerService("bar2", 9997, new MockRemote());
+ } catch (RMIHostException e) {
+ // expected
+ host.unregisterService("bar2", 9997);
+ }
+ }
+
+ public void testUnRegisterService() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ try {
+ host.unregisterService("bar3", 9998);
+ fail();
+ } catch (RMIHostException e) {
+ // expected
+ }
+ }
+
+ private static class MockRemote implements Remote {
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..a0beb4403d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType
@@ -0,0 +1,27 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType
new file mode 100644
index 0000000000..b0e0b007a6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType
@@ -0,0 +1,29 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldRmiService">
+ <interface.java interface="helloworld.HelloWorldRmiService"/>
+ </service>
+ <reference name="extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..25d78feeac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt
@@ -0,0 +1,1277 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+APACHE TUSCANY SUBCOMPONENTS:
+
+The Apache Tuscany distribution includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+For the Eclipse Modeling Framework component and the Celtix binding:
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and
+are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program by such
+Contributor itself or anyone acting on such Contributor's behalf.
+Contributions do not include additions to the Program which: (i) are
+separate modules of software distributed in conjunction with the
+Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and
+object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor, if
+any, in source code and object code form. This patent license shall
+apply to the combination of the Contribution and the Program if, at
+the time the Contribution is added by the Contributor, such addition
+of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the
+licenses to its Contributions set forth herein, no assurances are
+provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow
+Recipient to distribute the Program, it is Recipient's responsibility
+to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental and
+consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are
+offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable
+manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the
+Program.
+
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a
+commercial product offering should do so in a manner which does not
+create potential liability for other Contributors. Therefore, if a
+Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend
+and indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the acts
+or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement.
+In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b)
+allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such
+claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable
+laws, damage to or loss of data, programs or equipment, and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+the Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of
+the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign
+the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions)
+may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives
+no rights or licenses to the intellectual property of any Contributor
+under this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+For the Rhino JavaScript container component:
+
+Mozilla Public License 1.1 (MPL 1.1)
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original Code,
+prior Modifications used by a Contributor, and the Modifications made by that
+particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+combination of the Original Code and Modifications, in each case including
+portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+accepted in the software development community for the electronic transfer of
+data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified as
+the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+extent possible, whether at the time of the initial grant or subsequently
+acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+substance or structure of either the Original Code or any previous
+Modifications. When Covered Code is released as a series of files, a
+Modification is:
+ A. Any addition to or deletion from the contents of a file
+containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+which is described in the Source Code notice required by Exhibit A as Original
+Code, and which, at the time of its release under this License is not already
+Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+hereafter acquired, including without limitation, method, process, and
+apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+making modifications to it, including all modules it contains, plus any
+associated interface definition files, scripts used to control compilation and
+installation of an Executable, or source code differential comparisons against
+either the Original Code or another well known, available Covered Code of the
+Contributor's choice. The Source Code can be in a compressed or archival form,
+provided the appropriate decompression or de-archiving software is widely
+available for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+exercising rights under, and complying with all of the terms of, this License
+or a future version of this License issued under Section 6.1. For legal
+entities, "You" includes any entity which controls, is controlled by, or is
+under common control with You. For purposes of this definition, "control"
+means (a) the power, direct or indirect, to cause the direction or management
+of such entity, whether by contract or otherwise, or (b) ownership of more
+than fifty percent (50%) of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+non-exclusive license, subject to third party intellectual property claims:
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Initial Developer to use, reproduce, modify, display,
+perform, sublicense and distribute the Original Code (or portions thereof)
+with or without Modifications, and/or as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or selling
+of Original Code, to make, have made, use, practice, sell, and offer for sale,
+and/or otherwise dispose of the Original Code (or portions thereof).
+ (c) the licenses granted in this Section 2.1(a) and
+(b) are effective on the date Initial Developer first distributes Original
+Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+granted: 1) for code that You delete from the Original Code; 2) separate from
+the Original Code; or 3) for infringements caused by: i) the modification of
+the Original Code or ii) the combination of the Original Code with other
+software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Contributor, to use, reproduce, modify, display,
+perform, sublicense and distribute the Modifications created by such
+Contributor (or portions thereof) either on an unmodified basis, with other
+Modifications, as Covered Code and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or selling
+of Modifications made by that Contributor either alone and/or in combination
+with its Contributor Version (or portions of such combination), to make, use,
+sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications
+made by that Contributor (or portions thereof); and 2) the combination of
+Modifications made by that Contributor with its Contributor Version (or
+portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+effective on the date Contributor first makes Commercial Use of the Covered
+Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+granted: 1) for any code that Contributor has deleted from the Contributor
+Version; 2) separate from the Contributor Version; 3) for infringements
+caused by: i) third party modifications of Contributor Version or ii) the
+combination of Modifications made by that Contributor with other software
+(except as part of the Contributor Version) or other devices; or 4) under
+Patent Claims infringed by Covered Code in the absence of Modifications made
+by that Contributor.
+
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+governed by the terms of this License, including without limitation Section
+2.2. The Source Code version of Covered Code may be distributed only under the
+terms of this License or a future version of this License released under
+Section 6.1, and You must include a copy of this License with every copy of
+the Source Code You distribute. You may not offer or impose any terms on any
+Source Code version that alters or restricts the applicable version of this
+License or the recipients' rights hereunder. However, You may include an
+additional document offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+made available in Source Code form under the terms of this License either on
+the same media as an Executable version or via an accepted Electronic
+Distribution Mechanism to anyone to whom you made an Executable version
+available; and if made available via Electronic Distribution Mechanism, must
+remain available for at least twelve (12) months after the date it initially
+became available, or at least six (6) months after a subsequent version of
+that particular Modification has been made available to such recipients. You
+are responsible for ensuring that the Source Code version remains available
+even if the Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+file documenting the changes You made to create that Covered Code and the date
+of any change. You must include a prominent statement that the Modification is
+derived, directly or indirectly, from Original Code provided by the Initial
+Developer and including the name of the Initial Developer in (a) the Source
+Code, and (b) in any notice in an Executable version or related documentation
+in which You describe the origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+intellectual property rights is required to exercise the rights granted by
+such Contributor under Sections 2.1 or 2.2, Contributor must include a text
+file with the Source Code distribution titled "LEGAL" which describes the
+claim and the party making the claim in sufficient detail that a recipient
+will know whom to contact. If Contributor obtains such knowledge after the
+Modification is made available as described in Section 3.2, Contributor shall
+promptly modify the LEGAL file in all copies Contributor makes available
+thereafter and shall take other steps (such as notifying appropriate mailing
+lists or newsgroups) reasonably calculated to inform those who received the
+Covered Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+interface and Contributor has knowledge of patent licenses which are
+reasonably necessary to implement that API, Contributor must also include this
+information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+Section 3.4(a) above, Contributor believes that Contributor's Modifications
+are Contributor's original creation(s) and/or Contributor has sufficient
+rights to grant the rights conveyed by this License.
+
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+Code. If it is not possible to put such notice in a particular Source Code
+file due to its structure, then You must include such notice in a location
+(such as a relevant directory) where a user would be likely to look for such a
+notice. If You created one or more Modification(s) You may add your name as a
+Contributor to the notice described in Exhibit A. You must also duplicate
+this License in any documentation for the Source Code where You describe
+recipients' rights or ownership rights relating to Covered Code. You may
+choose to offer, and to charge a fee for, warranty, support, indemnity or
+liability obligations to one or more recipients of Covered Code. However, You
+may do so only on Your own behalf, and not on behalf of the Initial Developer
+or any Contributor. You must make it absolutely clear than any such warranty,
+support, indemnity or liability obligation is offered by You alone, and You
+hereby agree to indemnify the Initial Developer and every Contributor for any
+liability incurred by the Initial Developer or such Contributor as a result of
+warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+requirements of Section 3.1-3.5 have been met for that Covered Code, and if
+You include a notice stating that the Source Code version of the Covered Code
+is available under the terms of this License, including a description of how
+and where You have fulfilled the obligations of Section 3.2. The notice must
+be conspicuously included in any notice in an Executable version, related
+documentation or collateral in which You describe recipients' rights relating
+to the Covered Code. You may distribute the Executable version of Covered Code
+or ownership rights under a license of Your choice, which may contain terms
+different from this License, provided that You are in compliance with the
+terms of this License and that the license for the Executable version does not
+attempt to limit or alter the recipient's rights in the Source Code version
+from the rights set forth in this License. If You distribute the Executable
+version under a different license You must make it absolutely clear that any
+terms which differ from this License are offered by You alone, not by the
+Initial Developer or any Contributor. You hereby agree to indemnify the
+Initial Developer and every Contributor for any liability incurred by the
+Initial Developer or such Contributor as a result of any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+not governed by the terms of this License and distribute the Larger Work as a
+single product. In such a case, You must make sure the requirements of this
+License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Code due to statute,
+judicial order, or regulation then You must: (a) comply with the terms of this
+License to the maximum extent possible; and (b) describe the limitations and
+the code they affect. Such description must be included in the LEGAL file
+described in Section 3.4 and must be included with all distributions of the
+Source Code. Except to the extent prohibited by statute or regulation, such
+description must be sufficiently detailed for a recipient of ordinary skill to
+be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has attached
+the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+and/or new versions of the License from time to time. Each version will be
+given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+License, You may always continue to use it under the terms of that version.
+You may also choose to use such Covered Code under the terms of any subsequent
+version of the License published by Netscape. No one other than Netscape has
+the right to modify the terms applicable to Covered Code created under this
+License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+only do in order to apply it to code which is not already Covered Code
+governed by this License), You must (a) rename Your license so that the
+phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or
+any confusingly similar phrase do not appear in your license (except to note
+that your license differs from this License) and (b) otherwise make it clear
+that Your version of the license contains terms which differ from the Mozilla
+Public License and Netscape Public License. (Filling in the name of the
+Initial Developer, Original Code or Contributor in the notice described in
+Exhibit A shall not of themselves be deemed to be modifications of this
+License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE,
+FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE
+QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED
+CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR
+CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
+LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+automatically if You fail to comply with terms herein and fail to cure such
+breach within 30 days of becoming aware of the breach. All sublicenses to the
+Covered Code which are properly granted shall survive any termination of this
+License. Provisions which, by their nature, must remain in effect beyond the
+termination of this License shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+claim (excluding declatory judgment actions) against Initial Developer or a
+Contributor (the Initial Developer or Contributor against whom You file such
+action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+infringes any patent, then any and all rights granted by such Participant to
+You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice
+from Participant terminate prospectively, unless if within 60 days after
+receipt of notice You either: (i) agree in writing to pay Participant a
+mutually agreeable reasonable royalty for Your past and future use of
+Modifications made by such Participant, or (ii) withdraw Your litigation claim
+with respect to the Contributor Version against such Participant. If within
+60 days of notice, a reasonable royalty and payment arrangement are not
+mutually agreed upon in writing by the parties or the litigation claim is not
+withdrawn, the rights granted by Participant to You under Sections 2.1 and/or
+2.2 automatically terminate at the expiration of the 60 day notice period
+specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+Contributor Version, directly or indirectly infringes any patent, then any
+rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are
+revoked effective as of the date You first made, used, sold, distributed, or
+had made, Modifications made by that Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+alleging that such Participant's Contributor Version directly or indirectly
+infringes any patent where such claim is resolved (such as by license or
+settlement) prior to the initiation of patent infringement litigation, then
+the reasonable value of the licenses granted by such Participant under
+Sections 2.1 or 2.2 shall be taken into account in determining the amount or
+value of any payment or license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above, all
+end user license agreements (excluding distributors and resellers) which have
+been validly granted by You or any distributor hereunder prior to termination
+shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY
+SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING,
+WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
+FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH
+DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH
+OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
+EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in 48
+C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and
+"commercial computer software documentation," as such terms are used in 48
+C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R.
+227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users
+acquire Covered Code with only those rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it
+enforceable. This License shall be governed by California law provisions
+(except to the extent applicable law, if any, provides otherwise), excluding
+its conflict-of-law provisions. With respect to disputes in which at least one
+party is a citizen of, or an entity chartered or registered to do business in
+the United States of America, any litigation relating to this License shall be
+subject to the jurisdiction of the Federal Courts of the Northern District of
+California, with venue lying in Santa Clara County, California, with the
+losing party responsible for costs, including without limitation, court costs
+and reasonable attorneys' fees and expenses. The application of the United
+Nations Convention on Contracts for the International Sale of Goods is
+expressly excluded. Any law or regulation which provides that the language of
+a contract shall be construed against the drafter shall not apply to this
+License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+responsible for claims and damages arising, directly or indirectly, out of its
+utilization of rights under this License and You agree to work with Initial
+Developer and Contributors to distribute such responsibility on an equitable
+basis. Nothing herein is intended or shall be deemed to constitute any
+admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits
+you to utilize portions of the Covered Code under Your choice of the MPL or
+the alternative licenses, if any, specified by the Initial Developer in the
+file described in Exhibit A.
+
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+language governing rights and
+ limitations under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+Portions created by
+ ______________________ are Copyright (C) ______
+_______________________. All Rights
+ Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms of
+the _____ license (the [___] License), in which case the provisions of
+[______] License are applicable instead of those above. If you wish to allow
+use of your version of this file only under the terms of the [____] License
+and not to allow others to use your version of this file under the MPL,
+indicate your decision by deleting the provisions above and replace them
+with the notice and other provisions required by the [___] License. If you do
+not delete the provisions above, a recipient may use your version of this file
+under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+the notices in the Source Code files of the Original Code. You should use the
+text of this Exhibit A rather than the text found in the Original Code Source
+Code for Your Modifications.]
+
+
+===============================================================================
+
+For the JAX-WS Reference Implementation component:
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+
+ 1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that
+ creates or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the
+ Original Software, prior Modifications used by a
+ Contributor (if any), and the Modifications made by that
+ particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or
+ (b) Modifications, or (c) the combination of files
+ containing Original Software with files containing
+ Modifications, in each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form
+ other than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity
+ that first makes Original Software available under this
+ License.
+
+ 1.6. "Larger Work" means a work which combines Covered
+ Software or portions thereof with code not governed by the
+ terms of this License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the
+ maximum extent possible, whether at the time of the initial
+ grant or subsequently acquired, any and all of the rights
+ conveyed herein.
+
+ 1.9. "Modifications" means the Source Code and Executable
+ form of any of the following:
+
+ A. Any file that results from an addition to,
+ deletion from or modification of the contents of a
+ file containing Original Software or previous
+ Modifications;
+
+ B. Any new file that contains any part of the
+ Original Software or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and
+ Executable form of computer software code that is
+ originally released under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned
+ or hereafter acquired, including without limitation,
+ method, process, and apparatus claims, in any patent
+ Licensable by grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer
+ software code in which modifications are made and (b)
+ associated documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal
+ entity exercising rights under, and complying with all of
+ the terms of, this License. For legal entities, "You"
+ includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or
+ indirect, to cause the direction or management of such
+ entity, whether by contract or otherwise, or (b) ownership
+ of more than fifty percent (50%) of the outstanding shares
+ or beneficial ownership of such entity.
+
+ 2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the
+ Initial Developer hereby grants You a world-wide,
+ royalty-free, non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Initial Developer,
+ to use, reproduce, modify, display, perform,
+ sublicense and distribute the Original Software (or
+ portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making,
+ using or selling of Original Software, to make, have
+ made, use, practice, sell, and offer for sale, and/or
+ otherwise dispose of the Original Software (or
+ portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b)
+ are effective on the date Initial Developer first
+ distributes or otherwise makes the Original Software
+ available to a third party under the terms of this
+ License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent
+ license is granted: (1) for code that You delete from
+ the Original Software, or (2) for infringements
+ caused by: (i) the modification of the Original
+ Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Contributor to
+ use, reproduce, modify, display, perform, sublicense
+ and distribute the Modifications created by such
+ Contributor (or portions thereof), either on an
+ unmodified basis, with other Modifications, as
+ Covered Software and/or as part of a Larger Work; and
+
+
+ (b) under Patent Claims infringed by the making,
+ using, or selling of Modifications made by that
+ Contributor either alone and/or in combination with
+ its Contributor Version (or portions of such
+ combination), to make, use, sell, offer for sale,
+ have made, and/or otherwise dispose of: (1)
+ Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications
+ made by that Contributor with its Contributor Version
+ (or portions of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and
+ 2.2(b) are effective on the date Contributor first
+ distributes or otherwise makes the Modifications
+ available to a third party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent
+ license is granted: (1) for any code that Contributor
+ has deleted from the Contributor Version; (2) for
+ infringements caused by: (i) third party
+ modifications of Contributor Version, or (ii) the
+ combination of Modifications made by that Contributor
+ with other software (except as part of the
+ Contributor Version) or other devices; or (3) under
+ Patent Claims infringed by Covered Software in the
+ absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be
+ distributed only under the terms of this License. You must
+ include a copy of this License with every copy of the
+ Source Code form of the Covered Software You distribute or
+ otherwise make available. You must inform recipients of any
+ such Covered Software in Executable form as to how they can
+ obtain such Covered Software in Source Code form in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You
+ contribute are governed by the terms of this License. You
+ represent that You believe Your Modifications are Your
+ original creation(s) and/or You have sufficient rights to
+ grant the rights conveyed by this License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications
+ that identifies You as the Contributor of the Modification.
+ You may not remove or alter any copyright, patent or
+ trademark notices contained within the Covered Software, or
+ any notices of licensing or any descriptive text giving
+ attribution to any Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered
+ Software in Source Code form that alters or restricts the
+ applicable version of this License or the recipients'
+ rights hereunder. You may choose to offer, and to charge a
+ fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Software.
+ However, you may do so only on Your own behalf, and not on
+ behalf of the Initial Developer or any Contributor. You
+ must make it absolutely clear that any such warranty,
+ support, indemnity or liability obligation is offered by
+ You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered
+ Software under the terms of this License or under the terms
+ of a license of Your choice, which may contain terms
+ different from this License, provided that You are in
+ compliance with the terms of this License and that the
+ license for the Executable form does not attempt to limit
+ or alter the recipient's rights in the Source Code form
+ from the rights set forth in this License. If You
+ distribute the Covered Software in Executable form under a
+ different license, You must make it absolutely clear that
+ any terms which differ from this License are offered by You
+ alone, not by the Initial Developer or Contributor. You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial
+ Developer or such Contributor as a result of any such terms
+ You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software
+ with other code not governed by the terms of this License
+ and distribute the Larger Work as a single product. In such
+ a case, You must make sure the requirements of this License
+ are fulfilled for the Covered Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and
+ may publish revised and/or new versions of this License
+ from time to time. Each version will be given a
+ distinguishing version number. Except as provided in
+ Section 4.3, no one other than the license steward has the
+ right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. If the Initial Developer includes a
+ notice in the Original Software prohibiting it from being
+ distributed or otherwise made available under any
+ subsequent version of the License, You must distribute and
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software
+ available under the terms of any subsequent version of the
+ License published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a
+ new license for Your Original Software, You may create and
+ use a modified version of this License if You: (a) rename
+ the license and remove any references to the name of the
+ license steward (except to note that the license differs
+ from this License); and (b) otherwise make it clear that
+ the license contains terms which differ from this License.
+
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will
+ terminate automatically if You fail to comply with terms
+ herein and fail to cure such breach within 30 days of
+ becoming aware of the breach. Provisions which, by their
+ nature, must remain in effect beyond the termination of
+ this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or
+ a Contributor (the Initial Developer or Contributor against
+ whom You assert such claim is referred to as "Participant")
+ alleging that the Participant Software (meaning the
+ Contributor Version where the Participant is a Contributor
+ or the Original Software where the Participant is the
+ Initial Developer) directly or indirectly infringes any
+ patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant)
+ and all Contributors under Sections 2.1 and/or 2.2 of this
+ License shall, upon 60 days notice from Participant
+ terminate prospectively and automatically at the expiration
+ of such 60 day notice period, unless if within such 60 day
+ period You withdraw Your claim with respect to the
+ Participant Software against such Participant either
+ unilaterally or pursuant to a written agreement with
+ Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2
+ above, all end user licenses that have been validly granted
+ by You or any distributor hereunder prior to termination
+ (excluding licenses granted to You by any distributor)
+ shall survive termination.
+
+ 7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48 C.F.R.
+ 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
+ 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+ through 227.7202-4 (June 1995), all U.S. Government End Users
+ acquire Covered Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the
+ extent necessary to make it enforceable. This License shall be
+ governed by the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, with the losing
+ party responsible for costs, including, without limitation, court
+ costs and reasonable attorneys' fees and expenses. The
+ application of the United Nations Convention on Contracts for the
+ International Sale of Goods is expressly excluded. Any law or
+ regulation which provides that the language of a contract shall
+ be construed against the drafter shall not apply to this License.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..5bb55f2405
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rmi="http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2"
+ name="HelloWorldRmiComposite">
+
+ <service name="HelloWorldRmiService" target="HelloWorldServiceComponent">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <rmi:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
+ <reference>HelloWorldServiceComponent</reference>
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+ <component name="HelloWorldRmiServiceComponent">
+ <implementation.java class="helloworld.HelloWorldRmiImpl"/>
+ <reference name="extService" target="HelloWorldRmiReference">HelloWorldRmiReference</reference>
+ </component>
+
+ <reference name="HelloWorldRmiReference" target="Nothing">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <rmi:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
+ </reference>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml
new file mode 100644
index 0000000000..fcb4b086c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>binding-servicemix</artifactId>
+ <name>Apache Tuscany Binding for ServiceMix</name>
+ <description>Implementation of the SCA JBI Binding</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-common</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java
new file mode 100644
index 0000000000..ad407553b4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Base class for components bootstrap.
+ *
+ * @author Guillaume Nodet
+ * @version $Revision$
+ * @since 3.0
+ */
+public class ScaBootstrap implements Bootstrap {
+
+ protected final transient Log logger = LogFactory.getLog(getClass());
+
+ protected InstallationContext context;
+ protected ObjectName mbeanName;
+
+ public ScaBootstrap() {
+ }
+
+ public ObjectName getExtensionMBeanName() {
+ return mbeanName;
+ }
+
+ protected Object getExtensionMBean() throws Exception {
+ return null;
+ }
+
+ protected ObjectName createExtensionMBeanName() throws Exception {
+ return this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
+ */
+ public void init(InstallationContext installContext) throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Initializing bootstrap");
+ }
+ this.context = installContext;
+ doInit();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap initialized");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling init", e);
+ }
+ }
+
+ protected void doInit() throws Exception {
+ Object mbean = getExtensionMBean();
+ if (mbean != null) {
+ this.mbeanName = createExtensionMBeanName();
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ server.registerMBean(mbean, this.mbeanName);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#cleanUp()
+ */
+ public void cleanUp() throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up bootstrap");
+ }
+ doCleanUp();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap cleaned up");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling cleanUp", e);
+ }
+ }
+
+ protected void doCleanUp() throws Exception {
+ if (this.mbeanName != null) {
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onInstall()
+ */
+ public void onInstall() throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onInstall");
+ }
+ doOnInstall();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onInstall done");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onInstall", e);
+ }
+ }
+
+ protected void doOnInstall() throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onUninstall()
+ */
+ public void onUninstall() throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onUninstall");
+ }
+ doOnUninstall();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onUninstall done");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onUninstall", e);
+ }
+ }
+
+ protected void doOnUninstall() throws Exception {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java
new file mode 100644
index 0000000000..93470e0707
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.Deployer;
+
+public class ScaComponent extends BaseComponent {
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createLifeCycle()
+ */
+ protected BaseLifeCycle createLifeCycle() {
+ return new ScaLifeCycle(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
+ */
+ public BaseServiceUnitManager createServiceUnitManager() {
+ Deployer[] deployers = new Deployer[] { new ScaDeployer(this) };
+ return new BaseServiceUnitManager(this, deployers);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java
new file mode 100644
index 0000000000..199721cb88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import java.io.File;
+
+import javax.jbi.management.DeploymentException;
+
+import org.apache.servicemix.common.AbstractDeployer;
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.ServiceUnit;
+
+public class ScaDeployer extends AbstractDeployer {
+
+ public static final String SCA_MODULE_FILE = "sca.module";
+
+ public ScaDeployer(BaseComponent component) {
+ super(component);
+ }
+
+ public boolean canDeploy(String serviceUnitName, String serviceUnitRootPath) {
+ File module = new File(serviceUnitRootPath, SCA_MODULE_FILE);
+ return module.exists() && module.isFile();
+ }
+
+ public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath)
+ throws DeploymentException {
+ File module = new File(serviceUnitRootPath, SCA_MODULE_FILE);
+ if (!module.exists() || !module.isFile()) {
+ throw failure("deploy", "No sca.module found", null);
+ }
+ try {
+ ScaServiceUnit su = new ScaServiceUnit();
+ su.setComponent(component);
+ su.setName(serviceUnitName);
+ su.setRootPath(serviceUnitRootPath);
+ su.init();
+ return su;
+ } catch (Exception e) {
+ throw failure("deploy", "Error loading sca module", e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
new file mode 100644
index 0000000000..8da798d26f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import java.io.StringWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+
+/**
+ *
+ * @author gnodet
+ * @version $Revision$
+ * @org.apache.xbean.XBean element="endpoint" description="A sca endpoint"
+ *
+ */
+public class ScaEndpoint extends Endpoint implements ExchangeProcessor {
+
+ protected ServiceEndpoint activated;
+
+ protected EntryPoint entryPoint;
+
+ protected Map<Class, Method> methodMap;
+
+ protected JAXBContext jaxbContext;
+
+ protected DeliveryChannel channel;
+
+ public ScaEndpoint(EntryPoint entryPoint) {
+ this.entryPoint = entryPoint;
+ }
+
+ public Role getRole() {
+ return Role.PROVIDER;
+ }
+
+ public void activate() throws Exception {
+ logger = this.serviceUnit.getComponent().getLogger();
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
+ activated = ctx.activateEndpoint(service, endpoint);
+ channel = ctx.getDeliveryChannel();
+ // Get the target service
+ ConfiguredReference referenceValue = entryPoint.getConfiguredReference();
+ ConfiguredService targetServiceEndpoint = referenceValue.getTargetConfiguredServices().get(0);
+ // Get the business interface
+ Class serviceInterface = targetServiceEndpoint.getService().getServiceContract().getInterface();
+ List<Class> classes = new ArrayList<Class>();
+ methodMap = new HashMap<Class, Method>();
+ for (Method mth : serviceInterface.getMethods()) {
+ Class[] params = mth.getParameterTypes();
+ if (params.length != 1) {
+ throw new IllegalStateException("Supports only methods with one parameter");
+ }
+ methodMap.put(params[0], mth);
+ classes.add(mth.getReturnType());
+ classes.add(params[0]);
+ }
+ jaxbContext = JAXBContext.newInstance(classes.toArray(new Class[0]));
+ }
+
+ public void deactivate() throws Exception {
+ ServiceEndpoint ep = activated;
+ activated = null;
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
+ ctx.deactivateEndpoint(ep);
+ }
+
+ public ExchangeProcessor getProcessor() {
+ return this;
+ }
+
+ public void process(MessageExchange exchange) throws Exception {
+ if (exchange.getStatus() == ExchangeStatus.DONE) {
+ return;
+ } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+ return;
+ }
+ Object input = jaxbContext.createUnmarshaller().unmarshal(exchange.getMessage("in").getContent());
+ Method method = methodMap.get(input.getClass());
+ if (method == null) {
+ throw new IllegalStateException("Could not determine invoked web method");
+ }
+ boolean oneWay = method.getReturnType() == null;
+ Object output;
+ try {
+ EntryPointContext entryPointContext = (EntryPointContext) ((ScaServiceUnit) serviceUnit)
+ .getTuscanyRuntime().getModuleContext().getContext(entryPoint.getName());
+ InvocationHandler handler = (InvocationHandler) entryPointContext.getImplementationInstance();
+ output = handler.invoke(null, method, new Object[] { input });
+ } catch (UndeclaredThrowableException e) {
+ throw e;
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Error e) {
+ throw e;
+ } catch (Exception e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ if (oneWay) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ } else {
+ NormalizedMessage msg = exchange.createMessage();
+ exchange.setMessage(msg, "out");
+ StringWriter writer = new StringWriter();
+ jaxbContext.createMarshaller().marshal(output, writer);
+ msg.setContent(new StringSource(writer.toString()));
+ channel.send(exchange);
+ }
+ }
+
+ public void start() throws Exception {
+ }
+
+ public void stop() throws Exception {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java
new file mode 100644
index 0000000000..499459dc71
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+
+public class ScaLifeCycle extends BaseLifeCycle {
+
+ public ScaLifeCycle(BaseComponent component) {
+ super(component);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
new file mode 100644
index 0000000000..e391edf071
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.tuscany.CommonsLoggingMonitorFactory;
+import org.apache.servicemix.sca.tuscany.TuscanyRuntime;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+
+public class ScaServiceUnit extends ServiceUnit {
+
+ protected static final ThreadLocal<ScaServiceUnit> SERVICE_UNIT = new ThreadLocal<ScaServiceUnit>();
+
+ public static ScaServiceUnit getCurrentScaServiceUnit() {
+ return SERVICE_UNIT.get();
+ }
+
+ protected TuscanyRuntime tuscanyRuntime;
+ protected ClassLoader classLoader;
+
+ public void init() throws Exception {
+ SERVICE_UNIT.set(this);
+ createScaRuntime();
+ createEndpoints();
+ SERVICE_UNIT.set(null);
+ }
+
+ protected void createScaRuntime() throws Exception {
+ File root = new File(getRootPath());
+ File[] files = root.listFiles(new JarFileFilter());
+ URL[] urls = new URL[files.length + 1];
+ for (int i = 0; i < files.length; i++) {
+ urls[i] = files[i].toURL();
+ }
+ urls[urls.length - 1] = root.toURL();
+ classLoader = new URLClassLoader(urls, getClass().getClassLoader());
+
+ tuscanyRuntime = new TuscanyRuntime(getName(), getRootPath(), classLoader, new CommonsLoggingMonitorFactory());
+ }
+
+ protected void createEndpoints() throws Exception {
+ Module module = tuscanyRuntime.getModuleComponent().getModuleImplementation();
+ for (Iterator i = module.getEntryPoints().iterator(); i.hasNext();) {
+ EntryPoint entryPoint = (EntryPoint) i.next();
+ Binding binding = (Binding) entryPoint.getBindings().get(0);
+ if (binding instanceof JbiBinding) {
+ JbiBinding jbiBinding = (JbiBinding) binding;
+ ScaEndpoint endpoint = new ScaEndpoint(entryPoint);
+ endpoint.setServiceUnit(this);
+ endpoint.setService(jbiBinding.getServiceName());
+ endpoint.setEndpoint(jbiBinding.getEndpointName());
+ endpoint.setInterfaceName(jbiBinding.getInterfaceName());
+ Definition definition = jbiBinding.getDefinition();
+ if (definition != null) {
+ endpoint.setDefinition(definition);
+ endpoint.setDescription(WSDLFactory.newInstance().newWSDLWriter().getDocument(definition));
+ }
+ addEndpoint(endpoint);
+ }
+ }
+ }
+
+ private static class JarFileFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ }
+
+ public TuscanyRuntime getTuscanyRuntime() {
+ return tuscanyRuntime;
+ }
+
+ @Override
+ public void start() throws Exception {
+ tuscanyRuntime.start();
+ super.start();
+ }
+
+ @Override
+ public void stop() throws Exception {
+ super.stop();
+ tuscanyRuntime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java
new file mode 100644
index 0000000000..ef7812f175
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+/**
+ * The <b>Factory</b> for the model.
+ */
+public interface JbiAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns a new JbiBinding
+ */
+ JbiBinding createJbiBinding();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java
new file mode 100644
index 0000000000..8bfbf80590
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.assembly;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.model.assembly.Binding;
+
+public interface JbiBinding extends Binding {
+
+ /**
+ * Returns the URI of the WSDL port for this binding.
+ * @return the URI of the WSDL port for this binding
+ */
+ String getPortURI();
+
+ /**
+ * Set the URI of the WSDL port for this binding.
+ * @param portURI the URI of the WSDL port
+ */
+ void setPortURI(String portURI);
+
+ /**
+ * Returns the service name.
+ * @return the service name
+ */
+ QName getServiceName();
+
+ /**
+ * Returns the endpoint name.
+ * @return the endpoint name
+ */
+ String getEndpointName();
+
+ /**
+ * Returns the interface name.
+ * @returnthe interface name
+ */
+ QName getInterfaceName();
+
+ /**
+ * Returns the WSDL definition containing the WSDL port.
+ * @return the WSDL definition containing the WSDL port
+ */
+ Definition getDefinition();
+
+ /**
+ * Returns the the WSDL service.
+ * @return the WSDL service
+ */
+ Service getService();
+
+ /**
+ * Returns the WSDL port defining this binding.
+ * @return the WSDL port defining this binding
+ */
+ Port getPort();
+
+ /**
+ * Returns the WSDL port type.
+ * @return the WSDL port type
+ */
+ PortType getPortType();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..4cd6a98689
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.assembly.impl;
+
+import org.apache.servicemix.sca.assembly.JbiAssemblyFactory;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * An implementation of the model <b>Factory</b>.
+ */
+public class JbiAssemblyFactoryImpl extends AssemblyFactoryImpl implements JbiAssemblyFactory {
+
+ /**
+ * Creates an instance of the factory.
+ */
+ public JbiAssemblyFactoryImpl() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiAssemblyFactory#createJbiBinding()
+ */
+ public JbiBinding createJbiBinding() {
+ return new JbiBindingImpl();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java
new file mode 100644
index 0000000000..e44b9c6f45
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.assembly.impl;
+
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.BindingImpl;
+
+/**
+ * An implementation of the model object '<em><b>Web Service Binding</b></em>'.
+ */
+public class JbiBindingImpl extends BindingImpl implements JbiBinding {
+
+ private String portURI;
+ private QName serviceName;
+ private String endpointName;
+ private QName interfaceName;
+ private Definition definition;
+ private Service service;
+ private PortType portType;
+ private Port port;
+
+
+ /**
+ * Constructor
+ */
+ protected JbiBindingImpl() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getPortURI()
+ */
+ public String getPortURI() {
+ return portURI;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#setPortURI(java.lang.String)
+ */
+ public void setPortURI(String portURI) {
+ this.portURI = portURI;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getServiceName()
+ */
+ public QName getServiceName() {
+ return serviceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getEndpointName()
+ */
+ public String getEndpointName() {
+ return endpointName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getInterfaceName()
+ */
+ public QName getInterfaceName() {
+ return interfaceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getDefinition()
+ */
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getService()
+ */
+ public Service getService() {
+ return service;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getPort()
+ */
+ public Port getPort() {
+ return port;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getPortType()
+ */
+ public PortType getPortType() {
+ return portType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.BindingImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Get the service name and endpoint name
+ String[] parts = split(portURI);
+ serviceName = new QName(parts[0], parts[1]);
+ endpointName = parts[2];
+
+ // Load the WSDL definitions for the given namespace
+ List<Definition> definitions = modelContext.getAssemblyLoader().loadDefinitions(parts[0]);
+ if (definitions != null) {
+ for (Definition definition : definitions) {
+ Service service = definition.getService(serviceName);
+ if (service != null) {
+ Port port = service.getPort(endpointName);
+ if (port != null) {
+ this.service = service;
+ this.port = port;
+ this.portType = port.getBinding().getPortType();
+ this.interfaceName = portType.getQName();
+ this.definition = definition;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ protected String[] split(String uri) {
+ char sep;
+ uri = uri.trim();
+ if (uri.indexOf('/') > 0) {
+ sep = '/';
+ } else {
+ sep = ':';
+ }
+ int idx1 = uri.lastIndexOf(sep);
+ int idx2 = uri.lastIndexOf(sep, idx1 - 1);
+ String epName = uri.substring(idx1 + 1);
+ String svcName = uri.substring(idx2 + 1, idx1);
+ String nsUri = uri.substring(0, idx2);
+ return new String[] { nsUri, svcName, epName };
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java
new file mode 100644
index 0000000000..e5a7b59a75
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory;
+import org.apache.servicemix.sca.handler.ExternalJbiServiceClient;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MethodHashMap;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.scdl.WebServiceBinding;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an external service configured with the {@link WebServiceBinding}
+ */
+@Scope("MODULE")
+public class ExternalJbiServiceBuilder implements ContextFactoryBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private ContextFactoryBuilder policyBuilder;
+
+ public ExternalJbiServiceBuilder() {
+ }
+
+ @Init(eager = true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ /**
+ * Sets the factory used to construct proxies implmementing the business interface required by a reference
+ */
+ @Autowire
+ public void setProxyFactoryFactory(ProxyFactoryFactory factory) {
+ this.proxyFactoryFactory = factory;
+ }
+
+ /**
+ * Sets the factory used to construct invocation messages
+ *
+ * @param msgFactory
+ */
+ @Autowire
+ public void setMessageFactory(MessageFactory msgFactory) {
+ this.messageFactory = msgFactory;
+ }
+
+ /**
+ * Sets a builder responsible for creating source-side and target-side invocation chains for a reference. The
+ * reference builder may be hierarchical, containing other child reference builders that operate on specific
+ * metadata used to construct and invocation chain.
+ *
+ * @see org.apache.tuscany.core.builder.impl.HierarchicalBuilder
+ */
+ public void setPolicyBuilder(ContextFactoryBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object) throws BuilderException {
+ if (!(object instanceof ExternalService)) {
+ return;
+ }
+ ExternalService externalService = (ExternalService) object;
+ if (externalService.getBindings().size() < 1 || !(externalService.getBindings().get(0) instanceof JbiBinding)) {
+ return;
+ }
+
+ ExternalJbiServiceClient externalJbiServiceClient = new ExternalJbiServiceClient(externalService);
+ ExternalJbiServiceContextFactory config = new ExternalJbiServiceContextFactory(externalService.getName(), new SingletonObjectFactory<ExternalJbiServiceClient>(externalJbiServiceClient));
+
+ ConfiguredService configuredService = externalService.getConfiguredService();
+ Service service = configuredService.getService();
+ ServiceContract serviceContract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
+ ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
+ Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
+ for (Method method : javaMethods) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ QualifiedName qName = new QualifiedName(externalService.getName() + "/" + service.getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
+ proxyFactory.setBusinessInterface(serviceContract.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ config.addTargetProxyFactory(service.getName(), proxyFactory);
+ configuredService.setProxyFactory(proxyFactory);
+ if (policyBuilder != null) {
+ // invoke the reference builder to handle additional policy metadata
+ policyBuilder.build(configuredService);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+
+ externalService.getConfiguredService().setContextFactory(config);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java
new file mode 100644
index 0000000000..1dc7d9f454
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.builder;
+
+import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory;
+import org.apache.servicemix.sca.handler.ExternalJbiServiceTargetInvoker;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class ExternalJbiServiceWireBuilder implements WireBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ /**
+ * Constructs a new ExternalWebServiceWireBuilder.
+ */
+ public ExternalJbiServiceWireBuilder() {
+ super();
+ }
+
+ @Autowire
+ public void setRuntimeContext(RuntimeContext context) {
+ runtimeContext = context;
+ }
+
+ @Init(eager=true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+ public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (!(ExternalJbiServiceContextFactory.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ ExternalJbiServiceTargetInvoker invoker = new ExternalJbiServiceTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext);
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ //TODO implement
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java
new file mode 100644
index 0000000000..af83c7c714
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.config.JbiServiceEntryPointContextFactory;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.impl.EntryPointContextFactory;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class JbiServiceEntryPointBuilder implements ContextFactoryBuilder<AggregateContext> {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private ContextFactoryBuilder policyBuilder;
+
+ public JbiServiceEntryPointBuilder() {
+ }
+
+ @Init(eager = true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ /**
+ * Sets the factory used to construct proxies implmementing the business interface required by a reference
+ */
+ @Autowire
+ public void setProxyFactoryFactory(ProxyFactoryFactory factory) {
+ this.proxyFactoryFactory = factory;
+ }
+
+ /**
+ * Sets the factory used to construct invocation messages
+ *
+ * @param msgFactory
+ */
+ @Autowire
+ public void setMessageFactory(MessageFactory msgFactory) {
+ this.messageFactory = msgFactory;
+ }
+
+ /**
+ * Sets a builder responsible for creating source-side and target-side invocation chains for a reference. The
+ * reference builder may be hierarchical, containing other child reference builders that operate on specific
+ * metadata used to construct and invocation chain.
+ *
+ * @see org.apache.tuscany.core.builder.impl.HierarchicalBuilder
+ */
+ public void setPolicyBuilder(ContextFactoryBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object) throws BuilderException {
+ if (!(object instanceof EntryPoint)) {
+ return;
+ }
+ EntryPoint entryPoint = (EntryPoint) object;
+ if (entryPoint.getBindings().size() < 1 || !(entryPoint.getBindings().get(0) instanceof JbiBinding)) {
+ return;
+ }
+
+ EntryPointContextFactory config = new JbiServiceEntryPointContextFactory(entryPoint.getName(), entryPoint.getConfiguredService().getService().getName(), messageFactory);
+
+ ConfiguredService configuredService = entryPoint.getConfiguredService();
+ Service service = configuredService.getService();
+ ServiceContract serviceContract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new HashMap<Method, InvocationConfiguration>();
+ ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
+ Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
+ for (Method method : javaMethods) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ QualifiedName qName = new QualifiedName(entryPoint.getConfiguredReference().getTargetConfiguredServices().get(0).getAggregatePart().getName() + "/" + service.getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
+ proxyFactory.setBusinessInterface(serviceContract.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ config.addSourceProxyFactory(service.getName(), proxyFactory);
+ configuredService.setProxyFactory(proxyFactory);
+ if (policyBuilder != null) {
+ // invoke the reference builder to handle additional policy metadata
+ policyBuilder.build(configuredService);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new EntryPointInvokerInterceptor());
+ }
+ entryPoint.getConfiguredReference().setContextFactory(config);
+ }
+
+ //FIXME same as the InvokerInterceptor except that it doesn't throw an exception in setNext
+ // For some reason another InvokerInterceptor is added after this one, need Jim to look into it
+ // and figure out why.
+ public class EntryPointInvokerInterceptor implements Interceptor {
+
+ public EntryPointInvokerInterceptor() {
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ TargetInvoker invoker = msg.getTargetInvoker();
+ if (invoker == null) {
+ throw new InvocationRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+ public void setNext(Interceptor next) {
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java
new file mode 100644
index 0000000000..93b846db8a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.config;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.impl.BaseExternalServiceContextFactory;
+
+public class ExternalJbiServiceContextFactory extends BaseExternalServiceContextFactory {
+
+ public ExternalJbiServiceContextFactory(String name, ObjectFactory objectFactory) {
+ super(name, objectFactory);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java
new file mode 100644
index 0000000000..b6adb6481d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.config;
+
+import org.apache.tuscany.core.builder.impl.EntryPointContextFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+
+public class JbiServiceEntryPointContextFactory extends EntryPointContextFactory {
+
+ public JbiServiceEntryPointContextFactory(String name, String referenceName, MessageFactory msgFactory) {
+ super(name, referenceName, msgFactory);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java
new file mode 100644
index 0000000000..22b457687f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.handler;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.sca.ScaServiceUnit;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.tuscany.model.assembly.ExternalService;
+
+public class ExternalJbiServiceClient {
+
+ private ExternalService externalService;
+
+ private JbiBinding jbiBinding;
+
+ private ScaServiceUnit serviceUnit;
+
+ /**
+ * Constructs a new ExternalWebServiceClient.
+ *
+ * @param externalService
+ * @param wsBinding
+ */
+ public ExternalJbiServiceClient(ExternalService externalService) {
+ this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit();
+ this.externalService = externalService;
+ this.jbiBinding = (JbiBinding) this.externalService.getBindings().get(0);
+ }
+
+ /**
+ * Invoke an operation on the external Web service.
+ *
+ * @param method
+ * @param args
+ * @return
+ */
+ public Object invoke(Method method, Object[] args) {
+ if (args == null || args.length != 1) {
+ throw new IllegalStateException("args should have exactly one object");
+ }
+ try {
+ Object payload = args[0];
+ Class inputClass = method.getParameterTypes()[0];
+ Class outputClass = method.getReturnType();
+ JAXBContext context = JAXBContext.newInstance(inputClass, outputClass);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ context.createMarshaller().marshal(payload, baos);
+
+ DeliveryChannel channel = serviceUnit.getComponent().getComponentContext().getDeliveryChannel();
+ // TODO: in-only case ?
+ // TODO: interface based routing ?
+ // TODO: explicit endpoint selection ?
+ InOut inout = channel.createExchangeFactory().createInOutExchange();
+ inout.setService(jbiBinding.getServiceName());
+ NormalizedMessage in = inout.createMessage();
+ inout.setInMessage(in);
+ in.setContent(new StringSource(baos.toString()));
+ boolean sent = channel.sendSync(inout);
+ // TODO: check for error ?
+ NormalizedMessage out = inout.getOutMessage();
+ Object response = context.createUnmarshaller().unmarshal(out.getContent());
+ inout.setStatus(ExchangeStatus.DONE);
+ channel.send(inout);
+ return response;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java
new file mode 100644
index 0000000000..cd0560c5b5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.handler;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+public class ExternalJbiServiceTargetInvoker implements TargetInvoker {
+
+ private QualifiedName serviceName;
+ private String esName;
+ private Method method;
+ private ScopeContext container;
+
+ private ExternalServiceContext context;
+
+ /**
+ * Constructs a new ExternalJbiServiceTargetInvoker.
+ * @param esName
+ * @param container
+ */
+ public ExternalJbiServiceTargetInvoker(QualifiedName serviceName, Method method, ScopeContext container) {
+ assert (serviceName != null) : "No service name specified";
+ assert (method != null) : "No method specified";
+ assert (container != null) : "No scope container specified";
+ this.serviceName = serviceName;
+ this.esName = serviceName.getPartName();
+ this.method = method;
+ this.container = container;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ if (context == null) {
+ InstanceContext iContext = container.getContext(esName);
+ if (!(iContext instanceof ExternalServiceContext)) {
+ TargetException te = new TargetException("Unexpected target context type");
+ te.setIdentifier(iContext.getClass().getName());
+ te.addContextName(iContext.getName());
+ throw te;
+ }
+ context = (ExternalServiceContext) iContext;
+ }
+ ExternalJbiServiceClient client = (ExternalJbiServiceClient) context.getImplementationInstance(true);
+ if (payload != null) {
+ return client.invoke(method, (Object[])payload);
+ } else {
+ return client.invoke(method, null);
+ }
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setBody(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object clone() {
+ try {
+ ExternalJbiServiceTargetInvoker invoker = (ExternalJbiServiceTargetInvoker) super.clone();
+ invoker.container = container;
+ invoker.context = this.context;
+ invoker.esName = this.esName;
+ invoker.method = this.method;
+ invoker.serviceName = this.serviceName;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java
new file mode 100644
index 0000000000..ac67433720
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.servicemix.sca.assembly.JbiAssemblyFactory;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.assembly.impl.JbiAssemblyFactoryImpl;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.loader.StAXElementLoader;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class JbiBindingLoader implements StAXElementLoader<JbiBinding>{
+
+ public static final QName BINDING_JBI = new QName("http://www.osoa.org/xmlns/sca/0.9", "binding.jbi");
+
+ private static final JbiAssemblyFactory jbiFactory = new JbiAssemblyFactoryImpl();
+
+ private StAXLoaderRegistry registry;
+
+ @Autowire
+ public void setRegistry(StAXLoaderRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void start() {
+ registry.registerLoader(this);
+ }
+
+ @Destroy
+ public void stop() {
+ registry.unregisterLoader(this);
+ }
+
+ public QName getXMLType() {
+ return BINDING_JBI;
+ }
+
+ public Class<JbiBinding> getModelType() {
+ return JbiBinding.class;
+ }
+
+ public JbiBinding load(XMLStreamReader reader, ResourceLoader resourceLoader) throws XMLStreamException, ConfigurationLoadException {
+ JbiBinding binding = jbiFactory.createJbiBinding();
+ binding.setURI(reader.getAttributeValue(null, "uri"));
+ binding.setPortURI(reader.getAttributeValue(null, "port"));
+ return binding;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java
new file mode 100644
index 0000000000..154afe4377
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.tuscany;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.config.impl.StAXModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.loader.StAXUtil;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.builder.SystemContextFactoryBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.system.loader.SystemSCDLModelLoader;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+public class BootstrapHelper {
+
+ /**
+ * Returns a default AssemblyModelContext.
+ *
+ * @param classLoader the classloader to use for application artifacts
+ * @return a default AssemblyModelContext
+ */
+ public static AssemblyModelContext getModelContext(ClassLoader classLoader) {
+ // Create an assembly model factory
+ AssemblyFactory modelFactory = new SystemAssemblyFactoryImpl();
+
+ // Create a default assembly model loader
+ List<SCDLModelLoader> scdlLoaders = new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(new SystemSCDLModelLoader());
+ AssemblyModelLoader modelLoader = new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+ // Create a resource loader from the supplied classloader
+ ResourceLoader resourceLoader = new ResourceLoaderImpl(classLoader);
+
+ // Create an assembly model context
+ return new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+ }
+
+ /**
+ * Returns a default list of configuration builders.
+ *
+ * @return a default list of configuration builders
+ */
+ public static List<ContextFactoryBuilder> getBuilders() {
+ List<ContextFactoryBuilder> configBuilders = new ArrayList<ContextFactoryBuilder>();
+ configBuilders.add((new SystemContextFactoryBuilder()));
+ configBuilders.add(new SystemEntryPointBuilder());
+ configBuilders.add(new SystemExternalServiceBuilder());
+ return configBuilders;
+ }
+
+ private static final boolean useStax = true;
+ private static final String SYSTEM_LOADER_COMPONENT = "tuscany.loader";
+
+ /**
+ * Returns the default module configuration loader.
+ *
+ * @param systemContext the runtime's system context
+ * @param modelContext the model context the loader will use
+ * @return the default module configuration loader
+ */
+ public static ModuleComponentConfigurationLoader getConfigurationLoader(SystemAggregateContext systemContext, AssemblyModelContext modelContext) throws ConfigurationException {
+ if (useStax) {
+ // Bootstrap the StAX loader module
+ bootstrapStaxLoader(systemContext, modelContext);
+ return new StAXModuleComponentConfigurationLoaderImpl(modelContext, XMLInputFactory.newInstance(), systemContext.resolveInstance(StAXLoaderRegistry.class));
+ } else {
+ return new ModuleComponentConfigurationLoaderImpl(modelContext);
+ }
+ }
+
+ private static AggregateContext bootstrapStaxLoader(SystemAggregateContext systemContext, AssemblyModelContext modelContext) throws ConfigurationException {
+ AggregateContext loaderContext = (AggregateContext) systemContext.getContext(SYSTEM_LOADER_COMPONENT);
+ if (loaderContext == null) {
+ ModuleComponent loaderComponent = StAXUtil.bootstrapLoader(SYSTEM_LOADER_COMPONENT, modelContext);
+ loaderContext = registerModule(systemContext, loaderComponent);
+ loaderContext.fireEvent(EventContext.MODULE_START, null);
+ }
+ return loaderContext;
+ }
+
+ public static AggregateContext registerModule(AggregateContext parent, ModuleComponent component) throws ConfigurationException {
+ // register the component
+ parent.registerModelObject(component);
+
+ // Get the aggregate context representing the component
+ return (AggregateContext) parent.getContext(component.getName());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java
new file mode 100644
index 0000000000..04bcc0bcea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.tuscany;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.common.monitor.MonitorFactory;
+
+public class CommonsLoggingMonitorFactory implements MonitorFactory {
+
+ private final Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap<Class<?>, WeakReference<?>>();
+
+ public CommonsLoggingMonitorFactory() {
+ }
+
+ public <T> T getMonitor(Class<T> monitorInterface) {
+ T proxy = getCachedMonitor(monitorInterface);
+ if (proxy == null) {
+ proxy = createMonitor(monitorInterface);
+ proxies.put(monitorInterface, new WeakReference<T>(proxy));
+ }
+ return proxy;
+ }
+
+ private <T>T getCachedMonitor(Class<T> monitorInterface) {
+ WeakReference<T> ref = (WeakReference<T>) proxies.get(monitorInterface);
+ return (ref != null) ? ref.get() : null;
+ }
+
+ private <T>T createMonitor(Class<T> monitorInterface) {
+ String className = monitorInterface.getName();
+ Log logger = LogFactory.getLog(className);
+ InvocationHandler handler = new LoggingHandler(logger);
+ return (T) Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, handler);
+ }
+
+ private static final class LoggingHandler implements InvocationHandler {
+ private final Log logger;
+
+ public LoggingHandler(Log logger) {
+ this.logger = logger;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String sourceMethod = method.getName();
+ if (logger.isDebugEnabled()) {
+ // if the only argument is a Throwable use the special logger for it
+ if (args != null && args.length == 1 && args[0] instanceof Throwable) {
+ logger.debug(sourceMethod, (Throwable) args[0]);
+ } else {
+ StringBuilder sb = new StringBuilder();
+ sb.append(sourceMethod);
+ sb.append("(");
+ for (int i = 0; i < args.length; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(args[i]);
+ }
+ sb.append(")");
+ logger.debug(sb.toString());
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java
new file mode 100644
index 0000000000..ee5960dfb5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.tuscany;
+
+import java.util.List;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class TuscanyRuntime extends SCA {
+ private final TuscanyRuntime.Monitor monitor;
+ private final Object sessionKey = new Object();
+
+ private final RuntimeContext runtime;
+ private final AggregateContext moduleContext;
+
+ private final ModuleComponent moduleComponent;
+
+ private static final String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system";
+
+ /**
+ * Construct a runtime using a null MonitorFactory.
+ *
+ * @param name the name of the module component
+ * @param uri the URI to assign to the module component
+ * @throws ConfigurationException if there was a problem loading the SCA configuration
+ * @see TuscanyRuntime#TuscanyRuntime(String, String, org.apache.tuscany.common.monitor.MonitorFactory)
+ */
+ public TuscanyRuntime(String name, String uri) throws ConfigurationException {
+ this(name, uri,
+ Thread.currentThread().getContextClassLoader(),
+ new NullMonitorFactory());
+ }
+
+ /**
+ * Construct a runtime containing a single module component with the
+ * specified name. The module definition is loaded from a "/sca.module"
+ * resource found on the classpath of the current Thread context classloader.
+ *
+ * @param name the name of the module component
+ * @param uri the URI to assign to the module component
+ * @param classLoader the class loader to use for the assembly
+ * @param monitorFactory the MonitorFactory for this runtime
+ * @throws ConfigurationException if there was a problem loading the SCA configuration
+ */
+ public TuscanyRuntime(String name, String uri, ClassLoader classLoader, MonitorFactory monitorFactory) throws ConfigurationException {
+ this.monitor = monitorFactory.getMonitor(TuscanyRuntime.Monitor.class);
+
+ // Create an assembly model context
+ AssemblyModelContext modelContext = BootstrapHelper.getModelContext(classLoader);
+
+ // Create a runtime context and start it
+ List<SCDLModelLoader> loaders = modelContext.getAssemblyLoader().getLoaders();
+ List<ContextFactoryBuilder> configBuilders = BootstrapHelper.getBuilders();
+ runtime = new RuntimeContextImpl(monitorFactory, loaders, configBuilders, new DefaultWireBuilder());
+ runtime.start();
+ monitor.started(runtime);
+
+ // Load and start the system configuration
+ SystemAggregateContext systemContext = runtime.getSystemContext();
+ ModuleComponentConfigurationLoader loader = BootstrapHelper.getConfigurationLoader(systemContext, modelContext);
+ ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+ AggregateContext context = BootstrapHelper.registerModule(systemContext, systemModuleComponent);
+ context.fireEvent(EventContext.MODULE_START, null);
+
+ // Load the SCDL configuration of the application module
+ AggregateContext rootContext = runtime.getRootContext();
+ moduleComponent = loader.loadModuleComponent(name, uri);
+ moduleContext = BootstrapHelper.registerModule(rootContext, moduleComponent);
+ }
+
+ public ModuleComponent getModuleComponent() {
+ return moduleComponent;
+ }
+
+ public AggregateContext getModuleContext() {
+ return moduleContext;
+ }
+
+ /**
+ * Start the runtime and associate the module context with the calling thread.
+ */
+ @Override
+ public void start() {
+ setModuleContext((ModuleContext) moduleContext);
+ try {
+ //moduleContext.start();
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ moduleContext.fireEvent(EventContext.REQUEST_START, null);
+ moduleContext.fireEvent(EventContext.SESSION_NOTIFY, sessionKey);
+ monitor.started(moduleContext);
+ } catch (CoreRuntimeException e) {
+ setModuleContext(null);
+ monitor.startFailed(moduleContext, e);
+ //FIXME throw a better exception
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Disassociate the module context from the current thread and shut down the runtime.
+ */
+ @Override
+ public void stop() {
+ setModuleContext(null);
+ moduleContext.fireEvent(EventContext.REQUEST_END, null);
+ moduleContext.fireEvent(EventContext.SESSION_END, sessionKey);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ monitor.stopped(moduleContext);
+ runtime.stop();
+ monitor.stopped(runtime);
+ }
+
+ /**
+ * Monitor interface for a TuscanyRuntime.
+ */
+ public static interface Monitor {
+ /**
+ * Event emitted after the runtime has been started.
+ *
+ * @param ctx the runtime's module component context
+ */
+ void started(AggregateContext ctx);
+
+ /**
+ * Event emitted when an attempt to start the runtime failed.
+ *
+ * @param ctx the runtime's module component context
+ * @param e the exception that caused the failure
+ */
+ void startFailed(AggregateContext ctx, CoreRuntimeException e);
+
+ /**
+ * Event emitted after the runtime has been stopped.
+ *
+ * @param ctx the runtime's module component context
+ */
+ void stopped(AggregateContext ctx);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java
new file mode 100644
index 0000000000..04781d6d69
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a JBI binding
+ */
+public class JBIBinding extends Binding {
+
+ private String uri;
+
+ private String port;
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java
new file mode 100644
index 0000000000..8b6806a731
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Loader for handling <binding.jbi> elements.
+ */
+@Scope("MODULE")
+public class JBIBindingLoader extends LoaderExtension<JBIBinding> {
+
+ public static final QName BINDING_JBI = new QName("http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT", "binding.jbi");
+
+ public JBIBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_JBI;
+ }
+
+ public JBIBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException,
+ LoaderException {
+
+ String port = reader.getAttributeValue(null, "port");
+ String uri = reader.getAttributeValue(null, "uri");
+ LoaderUtil.skipToEndElement(reader);
+
+ JBIBinding binding = new JBIBinding();
+ binding.setPort(port);
+ binding.setURI(uri);
+
+ return binding;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java
new file mode 100644
index 0000000000..227d56d0b7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing pejbissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+/**
+ * Builds a Service or Reference for a JBI binding.
+ */
+public class ServiceMixBuilder extends BindingBuilderExtension<JBIBinding> {
+
+ protected Class<JBIBinding> getBindingType() {
+ return JBIBinding.class;
+ }
+
+ @SuppressWarnings( { "unchecked" })
+ public SCAObject build(CompositeComponent parent, BoundServiceDefinition<JBIBinding> boundServiceDefinition, DeploymentContext deploymentContext) {
+
+ String name = boundServiceDefinition.getName();
+
+ ServiceMixService serviceMixService = new ServiceMixService(name, parent, wireService, null);
+
+ return serviceMixService;
+ }
+
+ @SuppressWarnings( { "unchecked" })
+ public ServiceMixReference build(CompositeComponent parent, BoundReferenceDefinition<JBIBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+
+
+ ServiceMixReference serviceMixReference = new ServiceMixReference(null, parent, wireService, null, null);
+
+ return serviceMixReference;
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java
new file mode 100644
index 0000000000..5ad2aae7b5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.sca.ScaServiceUnit;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Invoke a JBI reference.
+ */
+public class ServiceMixInvoker extends TargetInvokerExtension {
+
+ private QName serviceName;
+
+ private ScaServiceUnit serviceUnit;
+
+ public ServiceMixInvoker(QName serviceName) {
+ this.serviceName = serviceName;
+ this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit();
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ DeliveryChannel channel = serviceUnit.getComponent().getComponentContext().getDeliveryChannel();
+
+ // TODO: in-only case ?
+ // TODO: interface based routing ?
+ // TODO: explicit endpoint selection ?
+
+ InOut inout = channel.createExchangeFactory().createInOutExchange();
+ inout.setService(serviceName);
+ NormalizedMessage in = inout.createMessage();
+ inout.setInMessage(in);
+ in.setContent(new StringSource(payload.toString()));
+
+ boolean sent = channel.sendSync(inout);
+ // TODO: check for error ?
+
+ NormalizedMessage out = inout.getOutMessage();
+ Object response = out.getContent();
+ inout.setStatus(ExchangeStatus.DONE);
+ channel.send(inout);
+
+ return response;
+
+ } catch (MessagingException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java
new file mode 100644
index 0000000000..e9898f8f15
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ *
+ */
+public class ServiceMixReference<T> extends ReferenceExtension<T> {
+
+ private final String uri;
+
+ public ServiceMixReference(String name,
+ CompositeComponent<?> parent,
+ WireService wireService,
+ String uri,
+ Class<T> service)
+ {
+ super(name, service, parent, wireService);
+ setInterface(service);
+ this.uri = uri;
+ }
+
+ public TargetInvoker createTargetInvoker(Method arg0) {
+ QName serviceName = null;
+ ServiceMixInvoker invoker = new ServiceMixInvoker(serviceName);
+ return invoker;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java
new file mode 100644
index 0000000000..ae7e9e3f1b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ *
+ */
+public class ServiceMixService<T> extends ServiceExtension<T> {
+
+ public ServiceMixService(String name, CompositeComponent parent, WireService wireService, Class<T> service) {
+ super(name, service, parent, wireService);
+ }
+
+ public void start() {
+ super.start();
+ }
+
+ public void stop() {
+ super.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER
new file mode 100644
index 0000000000..14eddf5d92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER
@@ -0,0 +1,6 @@
+Apache ServiceMix is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Geronimo PMC.
+Incubation is required of all newly accepted projects until a further review indicates that the infrastructure,
+communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or stability of the code, it does
+indicate that the project has yet to be fully endorsed by the ASF.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE
new file mode 100644
index 0000000000..c035229231
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache ServiceMix distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Additional copyright notices and license terms applicable are
+ present in the licenses directory of this distribution.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java
new file mode 100644
index 0000000000..2edf9882ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.tuscany.TuscanyRuntime;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+
+/**
+ * @author delfinoj
+ */
+public class AssemblyLoaderTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+ public void testLoader() throws Exception {
+ String name = "bigbank";
+ String uri = getClass().getResource("bigbank/sca.module").toString();
+
+ URL url = getClass().getResource("bigbank/sca.module");
+ URL parentUrl = new File(url.toURI()).getParentFile().toURL();
+ ClassLoader cl = new URLClassLoader(new URL[] { parentUrl }, getClass().getClassLoader());
+
+ TuscanyRuntime rt = new TuscanyRuntime(name, uri, cl, new NullMonitorFactory());
+ assertNotNull(rt);
+
+ Module module = rt.getModuleComponent().getModuleImplementation();
+
+ Assert.assertTrue(module.getName().equals("org.apache.servicemix.sca.bigbank"));
+
+ Component component = module.getComponent("AccountServiceComponent");
+ Assert.assertTrue(component != null);
+
+ EntryPoint entryPoint = module.getEntryPoint("AccountService");
+ Assert.assertTrue(entryPoint != null);
+
+ ExternalService externalService = module.getExternalService("StockQuoteService");
+ Assert.assertTrue(externalService != null);
+
+ Binding binding = externalService.getBindings().get(0);
+ Assert.assertTrue(binding instanceof JbiBinding);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
new file mode 100644
index 0000000000..bd6c4b3e88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URL;
+
+import javax.naming.InitialContext;
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.components.util.MockServiceComponent;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse;
+import org.w3c.dom.Node;
+
+public class ScaComponentTest extends TestCase {
+
+ private static Log log = LogFactory.getLog(ScaComponentTest.class);
+
+ protected JBIContainer container;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setMonitorInstallationDirectory(false);
+ container.setNamingContext(new InitialContext());
+ container.setEmbedded(true);
+ container.init();
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ public void testDeploy() throws Exception {
+ ScaComponent component = new ScaComponent();
+ container.activateComponent(component, "JSR181Component");
+
+ MockServiceComponent mock = new MockServiceComponent();
+ mock.setService(new QName("http://www.quickstockquote.com", "StockQuoteService"));
+ mock.setEndpoint("StockQuoteServiceJBI");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ StockQuoteResponse r = new StockQuoteResponse();
+ r.setResult(8.23f);
+ JAXBContext.newInstance(StockQuoteResponse.class).createMarshaller().marshal(r, baos);
+ mock.setResponseXml(baos.toString());
+ ActivationSpec as = new ActivationSpec();
+ as.setComponent(mock);
+ container.activateComponent(as);
+
+ // Start container
+ container.start();
+
+ // Deploy SU
+ component.getServiceUnitManager().deploy("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank"));
+ component.getServiceUnitManager().init("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank"));
+ component.getServiceUnitManager().start("su");
+
+ ServiceMixClient client = new DefaultServiceMixClient(container);
+ Source req = new StringSource("<AccountReportRequest><CustomerID>id</CustomerID></AccountReportRequest>");
+ Object rep = client.request(new ServiceNameEndpointResolver(
+ new QName("http://sca.servicemix.apache.org/Bigbank/Account", "AccountService")),
+ null, null, req);
+ if (rep instanceof Node) {
+ rep = new DOMSource((Node) rep);
+ }
+ log.info(new SourceTransformer().toString((Source) rep));
+ }
+
+ protected String getServiceUnitPath(String name) {
+ URL url = getClass().getClassLoader().getResource(name + "/sca.module");
+ File path = new File(url.getFile());
+ path = path.getParentFile();
+ return path.getAbsolutePath();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
new file mode 100644
index 0000000000..00c55aeffc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "customerID" })
+@XmlRootElement(name = "AccountReportRequest")
+public class AccountReportRequest {
+
+ @XmlElement(name = "CustomerID")
+ private String customerID;
+
+ public String getCustomerID() {
+ return customerID;
+ }
+
+ public void setCustomerID(String customerID) {
+ this.customerID = customerID;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java
new file mode 100644
index 0000000000..f52985d2c1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "accountSummaries" })
+@XmlRootElement(name = "AccountReportResponse")
+public class AccountReportResponse {
+
+ @XmlElement(name = "AccountSummaries")
+ private List<AccountSummary> accountSummaries;
+
+ public List<AccountSummary> getAccountSummaries() {
+ return accountSummaries;
+ }
+
+ public void setAccountSummaries(List<AccountSummary> accountSummaries) {
+ this.accountSummaries = accountSummaries;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
new file mode 100644
index 0000000000..5c2997f2c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReportResponse getAccountReport(AccountReportRequest request);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..f0cad13f5c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import java.util.ArrayList;
+
+import org.apache.servicemix.sca.bigbank.accountdata.AccountDataService;
+import org.apache.servicemix.sca.bigbank.accountdata.CheckingAccount;
+import org.apache.servicemix.sca.bigbank.accountdata.SavingsAccount;
+import org.apache.servicemix.sca.bigbank.accountdata.StockAccount;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteRequest;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteService;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(interfaces=AccountService.class)
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReportResponse getAccountReport(AccountReportRequest request) {
+ AccountReportResponse report = new AccountReportResponse();
+ String customerID = request.getCustomerID();
+ report.setAccountSummaries(new ArrayList<AccountSummary>());
+ report.getAccountSummaries().add(getCheckAccountSummary(customerID));
+ report.getAccountSummaries().add(getSavingsAccountSummary(customerID));
+ report.getAccountSummaries().add(getStockAccountSummary(customerID));
+ return report;
+ }
+
+ private AccountSummary getCheckAccountSummary(String customerID) {
+ CheckingAccount checking = accountDataService.getCheckingAccount(customerID);
+ AccountSummary summary = new AccountSummary();
+ summary.setAccountNumber(checking.getAccountNumber());
+ summary.setAccountType("Checking");
+ summary.setBalance(checking.getBalance());
+ return summary;
+ }
+
+ private AccountSummary getSavingsAccountSummary(String customerID) {
+ SavingsAccount savings = accountDataService.getSavingsAccount(customerID);
+ AccountSummary summary = new AccountSummary();
+ summary.setAccountNumber(savings.getAccountNumber());
+ summary.setAccountType("Savings");
+ summary.setBalance(savings.getBalance());
+ return summary;
+ }
+
+ private AccountSummary getStockAccountSummary(String customerID) {
+ StockAccount stock = accountDataService.getStockAccount(customerID);
+ AccountSummary summary = new AccountSummary();
+ summary.setAccountNumber(stock.getAccountNumber());
+ summary.setAccountType("Stock");
+ float quote = getQuote(stock.getSymbol());
+ summary.setBalance(quote * stock.getQuantity());
+ return summary;
+ }
+
+ private float getQuote(String symbol) {
+ StockQuoteRequest req = new StockQuoteRequest();
+ req.setSymbol(symbol);
+ StockQuoteResponse rep = stockQuoteService.getQuote(req);
+ return rep.getResult();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
new file mode 100644
index 0000000000..f6e5a060af
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "accountNumber", "accountType", "balance" })
+@XmlRootElement(name = "AccountSummary")
+public class AccountSummary {
+
+ @XmlElement(name = "AccountNumber")
+ private String accountNumber;
+
+ @XmlElement(name = "AccountType")
+ private String accountType;
+
+ @XmlElement(name = "Balance")
+ private float balance;
+
+ public AccountSummary() {
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public String getAccountType() {
+ return accountType;
+ }
+
+ public void setAccountType(String accountType) {
+ this.accountType = accountType;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..972b9dc704
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..f9d0c08df7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public class AccountDataServiceImpl implements AccountDataService {
+
+ public CheckingAccount getCheckingAccount(String customerID) {
+
+ CheckingAccount checkingAccount = new CheckingAccount();
+ checkingAccount.setAccountNumber(customerID + "_" + "CHA12345");
+ checkingAccount.setBalance(1500.0f);
+
+ return checkingAccount;
+ }
+
+ public SavingsAccount getSavingsAccount(String customerID) {
+
+ SavingsAccount savingsAccount = new SavingsAccount();
+ savingsAccount.setAccountNumber(customerID + "_" + "SAA12345");
+ savingsAccount.setBalance(1500.0f);
+
+ return savingsAccount;
+ }
+
+ public StockAccount getStockAccount(String customerID) {
+
+ StockAccount stockAccount = new StockAccount();
+ stockAccount.setAccountNumber(customerID + "_" + "STA12345");
+ stockAccount.setSymbol("IBM");
+ stockAccount.setQuantity(100);
+
+ return stockAccount;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..596dcc8d06
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public class CheckingAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..c208788ca8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public class SavingsAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java
new file mode 100644
index 0000000000..1005bceb91
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public class StockAccount {
+
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
new file mode 100644
index 0000000000..4f12b18601
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.stockquote;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "symbol" })
+@XmlRootElement(name = "StockQuoteRequest")
+public class StockQuoteRequest {
+
+ @XmlElement(name = "Symbol")
+ private String symbol;
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
new file mode 100644
index 0000000000..bf2d7c7c00
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.stockquote;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "result" })
+@XmlRootElement(name = "StockQuoteResponse")
+public class StockQuoteResponse {
+
+ @XmlElement(name = "Result")
+ private float result;
+
+ public float getResult() {
+ return result;
+ }
+
+ public void setResult(float result) {
+ this.result = result;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..3fa1558907
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.stockquote;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface StockQuoteService {
+
+ public StockQuoteResponse getQuote(StockQuoteRequest stockQuote);
+}
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties
new file mode 100644
index 0000000000..ec53858ed2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties
@@ -0,0 +1,38 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, out
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..992c894051
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties
@@ -0,0 +1,39 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
new file mode 100644
index 0000000000..9797a5739c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://sca.servicemix.apache.org/Bigbank/Account"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://sca.servicemix.apache.org/Bigbank/Account"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://sca.servicemix.apache.org/Bigbank/Account" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="getAccountReportRequest" type="tns:AccountReportRequest"/>
+ <xsd:complexType name="AccountReportRequest">
+ <xsd:sequence>
+ <xsd:element name="CustomerID" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReportResponse"/>
+
+ <xsd:complexType name="AccountReportResponse">
+ <xsd:sequence>
+ <xsd:element name="AccountSummaries">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="AccountSummary"
+ type="tns:AccountSummary" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:sequence>
+ <xsd:element name="AccountNumber" type="xsd:string"/>
+ <xsd:element name="AccountType" type="xsd:string"/>
+ <xsd:element name="Balance" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="tns:getAccountReportRequest" name="getAccountReportRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="tns:getAccountReportResponse" name="getAccountReportResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="tns:getAccountReportRequest"/>
+ <wsdl:output message="tns:getAccountReportResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="AccountServiceJBI" type="tns:AccountService">
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceJBI"
+ name="AccountServiceJBI">
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module
new file mode 100644
index 0000000000..ae520dd54e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="org.apache.servicemix.sca.bigbank">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.servicemix.sca.bigbank.account.AccountService"/>
+ <interface.wsdl interface="http://sca.servicemix.apache.org/Bigbank/Account#AccountService"/>
+ <binding.jbi port="http://sca.servicemix.apache.org/Bigbank/Account/AccountService/AccountServiceJBI"/>
+ <reference>AccountServiceComponent</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.servicemix.sca.bigbank.account.AccountServiceImpl"/>
+ <properties>
+ <v:currency>EURO</v:currency>
+ </properties>
+ <references>
+ <v:accountDataService>AccountDataServiceComponent</v:accountDataService>
+ <v:stockQuoteService>StockQuoteService</v:stockQuoteService>
+ </references>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="org.apache.servicemix.sca.bigbank.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.servicemix.sca.bigbank.stockquote.StockQuoteService"/>
+ <binding.jbi port="http://www.quickstockquote.com/StockQuoteService/StockQuoteServiceJBI"/>
+ </externalService>
+
+ <import.wsdl
+ location="org/apache/servicemix/sca/bigbank/account/AccountService.wsdl"
+ namespace="http://sca.servicemix.apache.org/Bigbank/Account" />
+
+</module>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/pom.xml
new file mode 100644
index 0000000000..8b255c7b2f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Bindings</name>
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <!-- temporary project to download and install the celtix required sun jars. The jars
+ are all CDDL so will be available on ibiblio when Sun releases them. This is just temporary.-->
+
+ <module>sunjars</module>
+ <module>binding.celtix</module>
+ <module>binding.axis2</module>
+ <module>binding.jsonrpc</module>
+ <module>binding.rmi</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>release</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>binding.axis2</module>
+ <module>binding.rmi</module>
+ </modules>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/build.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/build.xml
new file mode 100644
index 0000000000..e6fec45356
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/build.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="CeltixSunJarsInstaller">
+ <target name="checkinstalled">
+ <condition property="already.installed" >
+ <and>
+ <available file="${localRepository}/javax/annotation/jsr250-api/2.0-JAXWS-2.0-EA3/jsr250-api-2.0-JAXWS-2.0-EA3.jar"/>
+ <available file="${localRepository}/javax/jws/jsr181-api/2.0-JAXWS-2.0-EA3/jsr181-api-2.0-JAXWS-2.0-EA3.jar"/>
+ <available file="${localRepository}/javax/xml/jaxws-api/2.0-JAXWS-2.0-EA3/jaxws-api-2.0-JAXWS-2.0-EA3.jar"/>
+ <available file="${localRepository}/com/sun/xml/saaj-impl/1.3/saaj-impl-1.3.jar"/>
+ <available file="${localRepository}/javax/xml/saaj-api/1.3/saaj-api-1.3.jar"/>
+ </and>
+ </condition>
+ <condition property="maven.suffix" value="">
+ <os family="unix"/>
+ </condition>
+ <condition property="maven.suffix" value=".bat">
+ <os family="windows"/>
+ </condition>
+ </target>
+
+ <target name="installJars" depends="checkinstalled" unless="already.installed">
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.annotation -DartifactId=jsr250-api -Dversion=2.0-JAXWS-2.0-EA3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/jsr250-api-2.0-JAXWS-2.0-EA3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.jws -DartifactId=jsr181-api -Dversion=2.0-JAXWS-2.0-EA3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/jsr181-api-2.0-JAXWS-2.0-EA3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.xml -DartifactId=jaxws-api -Dversion=2.0-JAXWS-2.0-EA3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/jaxws-api-2.0-JAXWS-2.0-EA3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.xml -DartifactId=saaj-api -Dversion=1.3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/saaj-api-1.3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=com.sun.xml -DartifactId=saaj-impl -Dversion=1.3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/saaj-impl-1.3.jar"/>
+ </exec>
+ </target>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml
new file mode 100644
index 0000000000..d227956013
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sunjars</artifactId>
+ <packaging>pom</packaging>
+ <name>Project to install the Sun jars</name>
+
+ <properties>
+ <celtix.version>1.0</celtix.version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>objectweb</id>
+ <name>ObjectWeb repo</name>
+ <url>http://maven.objectweb.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <!-- This is a "hack" to overcome the Sun jar issue. Basically, we download a
+ complete celtix install kit (epl version) and then extract the Sun jars that we
+ need and install them. We use the dependency plugin to download it from the
+ objectweb snapshot mirror, then use antrun to fork a build.xml that will conditionally
+ call mvn to install the jars if they aren't already there. -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>dependency-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>getdeps</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/celtix-install</outputDirectory>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.objectweb.celtix</groupId>
+ <artifactId>celtix-distribution</artifactId>
+ <version>${celtix.version}</version>
+ <classifier>bin-epl</classifier>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant target="installJars">
+ <property name="localRepository" value="${settings.localRepository}"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset
new file mode 100644
index 0000000000..a1547fea92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<!--<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>-->
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml
new file mode 100644
index 0000000000..30d90f503b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>groovy</artifactId>
+ <name>Apache Tuscany Groovy Container</name>
+ <description>Apache Tuscany Groovy Container</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>1.0-jsr-05</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-full</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.4-RC8</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java
new file mode 100644
index 0000000000..f761122847
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ * Responsible for performing a non-blocking dispatch on a Groovy component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class AsyncGroovyInvoker extends GroovyInvoker {
+
+ private InboundWire wire;
+ private AsyncMonitor monitor;
+ private WorkContext workContext;
+ private Object target;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param wire
+ * @param component the target component
+ * @param monitor the monitor to pass events to
+ * @param workContext
+ */
+ public AsyncGroovyInvoker(String operation,
+ InboundWire wire,
+ GroovyAtomicComponent component,
+ AsyncMonitor monitor,
+ WorkContext workContext) {
+ super(operation, component);
+ this.wire = wire;
+ this.monitor = monitor;
+ this.workContext = workContext;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object messageId = msg.getMessageId();
+ wire.addMapping(messageId, msg.getFromAddress());
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(messageId);
+ invokeTarget(msg.getBody());
+ // async so no return value
+ return null;
+ } catch (Throwable e) {
+ // FIXME need to log exceptions
+ monitor.executionError(e);
+ return null;
+ }
+ }
+
+ public AsyncGroovyInvoker clone() throws CloneNotSupportedException {
+ return (AsyncGroovyInvoker) super.clone();
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!cacheable) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java
new file mode 100644
index 0000000000..4da5538990
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+/**
+ * A monitor used to log events during non-blocking invocations
+ * <p/>
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface AsyncMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Throwable e);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java
new file mode 100644
index 0000000000..b0ed18382f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import groovy.lang.GroovyObject;
+
+/**
+ * The Groovy atomic component implementation. Groovy implementations may be "scripts" or classes.
+ */
+public class GroovyAtomicComponent extends AtomicComponentExtension {
+ private final Class<? extends GroovyObject> groovyClass;
+ private final List<Class<?>> services;
+ //FIXME properties should move up to AtomicComponentExtension
+ private final Map<String, ObjectFactory> properties;
+ private AsyncMonitor monitor;
+
+ public GroovyAtomicComponent(GroovyConfiguration configuration, AsyncMonitor monitor) {
+ super(configuration.getName(),
+ configuration.getParent(),
+ configuration.getScopeContainer(),
+ configuration.getWireService(),
+ configuration.getWorkContext(),
+ null, configuration.getInitLevel());
+
+ this.groovyClass = configuration.getGroovyClass();
+ this.services = Collections.unmodifiableList(configuration.getServices());
+ this.properties = new HashMap<String, ObjectFactory>();
+ assert groovyClass != null;
+ this.monitor = monitor;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return new GroovyInvoker(operation.getName(), this);
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ return new AsyncGroovyInvoker(operation.getName(), wire, this, monitor, workContext);
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ GroovyObject instance;
+ try {
+ instance = groovyClass.newInstance();
+ } catch (IllegalAccessException e) {
+ throw new ObjectCreationException(e);
+ } catch (InstantiationException e) {
+ throw new ObjectCreationException(e);
+ }
+
+ // inject properties
+ for (Map.Entry<String, ObjectFactory> property : properties.entrySet()) {
+ instance.setProperty(property.getKey(), property.getValue().getInstance());
+ }
+
+ // inject references
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ instance.setProperty(wire.getReferenceName(), wireService.createProxy(wire));
+ }
+ }
+ return instance;
+ }
+
+ public GroovyObject getTargetInstance() throws TargetException {
+ return (GroovyObject) scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ //TODO this should return a default service from a wire
+ return scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance(String service) throws TargetException {
+ InboundWire wire = getInboundWire(service);
+ if (wire == null) {
+ TargetException e = new TargetException("ServiceDefinition not found"); // TODO better error message
+ e.setIdentifier(service);
+ throw e;
+ }
+ return wireService.createProxy(wire);
+ }
+
+ public void addPropertyFactory(String name, ObjectFactory<?> factory) {
+ properties.put(name, factory);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java
new file mode 100644
index 0000000000..4e99b888da
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import org.codehaus.groovy.control.CompilationFailedException;
+
+/**
+ * Extension point for creating {@link GroovyAtomicComponent}s from an assembly configuration
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class GroovyComponentBuilder extends ComponentBuilderExtension<GroovyImplementation> {
+
+ protected Class<GroovyImplementation> getImplementationType() {
+ return GroovyImplementation.class;
+ }
+
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<GroovyImplementation> componentDefinition,
+ DeploymentContext deploymentContext)
+ throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ GroovyImplementation implementation = componentDefinition.getImplementation();
+ GroovyComponentType componentType = implementation.getComponentType();
+
+ int initLevel = componentType.getInitLevel();
+
+ // get list of services provided by this component
+ Collection<ServiceDefinition> collection = componentType.getServices().values();
+ List<Class<?>> services = new ArrayList<Class<?>>(collection.size());
+ for (ServiceDefinition serviceDefinition : collection) {
+ services.add(serviceDefinition.getServiceContract().getInterfaceClass());
+ }
+
+ // get the Groovy classloader for this deployment component
+ GroovyClassLoader groovyClassLoader = (GroovyClassLoader) deploymentContext.getExtension("groovy.classloader");
+ if (groovyClassLoader == null) {
+ groovyClassLoader = new GroovyClassLoader(deploymentContext.getClassLoader());
+ deploymentContext.putExtension("groovy.classloader", groovyClassLoader);
+ }
+
+ // create the implementation class for the script
+ Class<? extends GroovyObject> groovyClass;
+ try {
+ String script = implementation.getScript();
+ // REVIEW JFM can we cache the class?
+ groovyClass = groovyClassLoader.parseClass(script);
+ } catch (CompilationFailedException e) {
+ BuilderConfigException bce = new BuilderConfigException(e);
+ bce.setIdentifier(name);
+ throw bce;
+ }
+ // TODO deal with init and destroy
+
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName(name);
+ configuration.setGroovyClass(groovyClass);
+ configuration.setParent(parent);
+ // get the scope container for this component's scope
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ configuration.setScopeContainer(deploymentContext.getModuleScope());
+ } else {
+ configuration.setScopeContainer(scopeRegistry.getScopeContainer(scope));
+ }
+
+
+ configuration.setWireService(wireService);
+ configuration.setWorkContext(workContext);
+ configuration.setInitLevel(initLevel);
+ configuration.setServices(services);
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+
+ // handle properties
+ for (Property<?> property : componentType.getProperties().values()) {
+ ObjectFactory<?> factory = property.getDefaultValueFactory();
+ if (factory != null) {
+ component.addPropertyFactory(property.getName(), factory);
+ }
+ }
+ return component;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java
new file mode 100644
index 0000000000..bd54371fd7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Model object representing a Groovy component type
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class GroovyComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+ private Scope lifecycleScope;
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java
new file mode 100644
index 0000000000..6da7840fdb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GroovyComponentTypeLoader extends ComponentTypeLoaderExtension<GroovyImplementation> {
+ protected Class<GroovyImplementation> getImplementationClass() {
+ return GroovyImplementation.class;
+ }
+
+ public void load(CompositeComponent parent, GroovyImplementation implementation, DeploymentContext context)
+ throws LoaderException {
+ GroovyComponentType componentType = new GroovyComponentType();
+ // for now, default to module
+ componentType.setLifecycleScope(Scope.MODULE);
+ implementation.setComponentType(componentType);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java
new file mode 100644
index 0000000000..b9ede2d034
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.WireService;
+
+import groovy.lang.GroovyObject;
+
+/**
+ * Encapsulates confuration for a Groovy-based atomic component
+ *
+ * @version $Rev$ $Date$
+ */
+public class GroovyConfiguration {
+
+ private CompositeComponent parent;
+ private ScopeContainer scopeContainer;
+ private int initLevel;
+ private Map<String, Member> referenceSites = new HashMap<String, Member>();
+ private Map<String, Member> propertySites = new HashMap<String, Member>();
+ private Map<String, Member> callbackSites = new HashMap<String, Member>();
+ private List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>();
+ private WireService wireService;
+ private WorkContext workContext;
+ private String name;
+ private Class<? extends GroovyObject> groovyClass;
+ private List<Class<?>> services;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Class<? extends GroovyObject> getGroovyClass() {
+ return groovyClass;
+ }
+
+ public void setGroovyClass(Class<? extends GroovyObject> groovyClass) {
+ this.groovyClass = groovyClass;
+ }
+
+ public CompositeComponent getParent() {
+ return parent;
+ }
+
+ public void setParent(CompositeComponent parent) {
+ this.parent = parent;
+ }
+
+ public ScopeContainer getScopeContainer() {
+ return scopeContainer;
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ this.scopeContainer = scopeContainer;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return serviceInterfaces;
+ }
+
+ public void addServiceInterface(Class<?> serviceInterface) {
+ serviceInterfaces.add(serviceInterface);
+ }
+
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ public void setInitLevel(int initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ public List<Class<?>> getServices() {
+ return services;
+ }
+
+ public void setServices(List<Class<?>> services) {
+ this.services = services;
+ }
+
+ public Map<String, Member> getReferenceSite() {
+ return referenceSites;
+ }
+
+ public void addReferenceSite(String name, Member member) {
+ referenceSites.put(name, member);
+ }
+
+ public Map<String, Member> getCallbackSite() {
+ return callbackSites;
+ }
+
+ public void addCallbackSite(String name, Member member) {
+ callbackSites.put(name, member);
+ }
+
+ public Map<String, Member> getPropertySites() {
+ return propertySites;
+ }
+
+ public void addPropertySite(String name, Member member) {
+ propertySites.put(name, member);
+ }
+
+ public WireService getWireService() {
+ return wireService;
+ }
+
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ public WorkContext getWorkContext() {
+ return workContext;
+ }
+
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java
new file mode 100644
index 0000000000..96b4a3bc2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a Groovy implementation.
+ */
+public class GroovyImplementation extends AtomicImplementation<GroovyComponentType> {
+
+ //the Groovy source to be executed
+ private String script;
+
+ /**
+ * Returns the Groovy source to be executed.
+ */
+ public String getScript() {
+ return script;
+ }
+
+ /**
+ * Sets the Groovy source to be executed.
+ */
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java
new file mode 100644
index 0000000000..b6fdbbb0b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import groovy.lang.GroovyObject;
+
+/**
+ * Dispatches to a Groovy implementation instance
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class GroovyInvoker implements TargetInvoker, Cloneable {
+
+ protected GroovyAtomicComponent component;
+ protected String operation;
+ protected boolean cacheable;
+
+ public GroovyInvoker(String operation, GroovyAtomicComponent context) {
+ this.component = context;
+ this.operation = operation;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+ /**
+ * Dispatches to the the target.
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ GroovyObject target = component.getTargetInstance();
+ Object[] args = (Object[]) payload;
+ try {
+ return target.invokeMethod(operation, args);
+ } catch (Exception ex) {
+ throw new InvocationTargetException(ex);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public GroovyInvoker clone() throws CloneNotSupportedException {
+ return (GroovyInvoker) super.clone();
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java
new file mode 100644
index 0000000000..da93abbd9d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+/**
+ * Loader for handling <groovy:implementation> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationLoader extends LoaderExtension<GroovyImplementation> {
+ private static final QName IMPLEMENTATION_GROOVY =
+ new QName("http://incubator.apache.org/tuscany/xmlns/container/groovy/1.0-incubator-M2", "implementation.groovy");
+
+ public ImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_GROOVY;
+ }
+
+ public GroovyImplementation load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ String script = reader.getAttributeValue(null, "script");
+ if (script == null) {
+ throw new MissingResourceException("No script supplied");
+ }
+ String source = loadSource(deploymentContext.getClassLoader(), script);
+
+ LoaderUtil.skipToEndElement(reader);
+
+ GroovyImplementation implementation = new GroovyImplementation();
+ implementation.setScript(source);
+ // no component type support
+ //registry.loadComponentType(parent, implementation, deploymentContext);
+ return implementation;
+ }
+
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ URL url = cl.getResource(resource);
+ if (url == null) {
+ throw new MissingResourceException(resource);
+ }
+ InputStream is;
+ try {
+ is = url.openStream();
+ } catch (IOException e) {
+ MissingResourceException mre = new MissingResourceException(resource, e);
+ mre.setIdentifier(resource);
+ throw mre;
+ }
+ try {
+ Reader reader = new InputStreamReader(is, "UTF-8");
+ char[] buffer = new char[1024];
+ StringBuilder source = new StringBuilder();
+ int count;
+ while ((count = reader.read(buffer)) > 0) {
+ source.append(buffer, 0, count);
+ }
+ return source.toString();
+ } catch (IOException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(resource);
+ throw le;
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl
new file mode 100644
index 0000000000..24fbfd5e25
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<!--
+ JavaScript configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="groovy.extension">
+
+ <component name="GroovyLoader">
+ <system:implementation.system class="org.apache.tuscany.container.groovy.ImplementationLoader"/>
+ </component>
+
+ <component name="GroovyComponentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.groovy.GroovyComponentTypeLoader"/>
+ </component>
+
+ <component name="GroovyBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.groovy.GroovyComponentBuilder"/>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java
new file mode 100644
index 0000000000..a27bb25484
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.AsyncTarget;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AsyncInvokerTestCase extends TestCase {
+
+ public void testInvoke() throws Exception {
+ GroovyObject instance = createMock(GroovyObject.class);
+ expect(instance.invokeMethod("invoke", null)).andReturn(null).once();
+ replay(instance);
+ GroovyAtomicComponent component = EasyMock.createMock(GroovyAtomicComponent.class);
+ expect(component.getTargetInstance()).andReturn(instance);
+ EasyMock.replay(component);
+ AsyncMonitor monitor = createMock(AsyncMonitor.class);
+ replay(monitor);
+
+ WorkScheduler scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+ WorkContext context = createMock(WorkContext.class);
+ Method method = AsyncTarget.class.getMethod("invoke");
+ method.setAccessible(true);
+ InboundWire wire = createMock(InboundWire.class);
+ AsyncGroovyInvoker invoker = new AsyncGroovyInvoker("invoke", wire, component, monitor, context);
+ Message msg = new MessageImpl();
+ invoker.invoke(msg);
+ verify(instance);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java
new file mode 100644
index 0000000000..bfff4bdef7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GroovyComponentTypeLoaderTestCase extends TestCase {
+
+ public void testLoad() throws Exception {
+ GroovyComponentTypeLoader loader = new GroovyComponentTypeLoader();
+ GroovyImplementation impl = new GroovyImplementation();
+ loader.load(null, impl, null);
+ GroovyComponentType type = impl.getComponentType();
+ assertEquals(Scope.MODULE, type.getLifecycleScope());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..2af0611757
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+import junit.framework.TestCase;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+ private XMLStreamReader reader;
+ private DeploymentContext deploymentContext;
+ private ClassLoader classLoader;
+ private LoaderRegistry registry;
+ private ImplementationLoader loader;
+
+ public void testNoScriptAttribute() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn(null);
+ replay(reader);
+ replay(deploymentContext);
+
+ try {
+ loader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ // ok
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.groovy");
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ ImplementationLoader mockLoader = new ImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.groovy", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.groovy", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadScript() throws LoaderException {
+ String script = loader.loadSource(getClass().getClassLoader(),
+ "org/apache/tuscany/container/groovy/mock/TestScript.groovy");
+ assertEquals("Test Script", script);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new ImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java
new file mode 100644
index 0000000000..9b828db7eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.Greeting;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import org.easymock.IAnswer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class PropertyTestCase extends TestCase {
+
+ private static final String SCRIPT = "import org.apache.tuscany.container.groovy.mock.Greeting;"
+ + "class Foo implements Greeting{"
+ + " String property;"
+ + " public String greet(String name){"
+ + " return property; "
+ + " }"
+ + "}";
+
+ private ScopeContainer scopeContainer;
+ private Class<? extends GroovyObject> implClass;
+
+ /**
+ * Tests injecting a simple property type on a Groovy implementation instance
+ */
+ public void testPropertyInjection() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ ObjectFactory<?> factory = createMock(ObjectFactory.class);
+ expect((String) factory.getInstance()).andReturn("bar");
+ replay(factory);
+ component.addPropertyFactory("property", factory);
+ Greeting greeting = (Greeting) component.getServiceInstance();
+ assertEquals("bar", greeting.greet("foo"));
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ GroovyClassLoader cl = new GroovyClassLoader(getClass().getClassLoader());
+ implClass = cl.parseClass(SCRIPT);
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return ((AtomicComponent) getCurrentArguments()[0]).createInstance();
+ }
+ });
+ replay(scopeContainer);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java
new file mode 100644
index 0000000000..f0ae7deb33
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.Greeting;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import org.easymock.IAnswer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class ScriptInvokeTestCase extends TestCase {
+
+ private static final String SCRIPT = "def greet(name) { return name }";
+
+ private Class<? extends GroovyObject> implClass;
+ private ScopeContainer scopeContainer;
+
+ /**
+ * Tests the invocation of a Groovy "script" as opposed to a class
+ */
+ public void testBasicScriptInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent context = new GroovyAtomicComponent(configuration, null);
+ GroovyObject object = (GroovyObject) context.getServiceInstance();
+ assertEquals("foo", object.invokeMethod("greet", "foo"));
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ GroovyClassLoader cl = new GroovyClassLoader(getClass().getClassLoader());
+ implClass = cl.parseClass(SCRIPT);
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return ((AtomicComponent) getCurrentArguments()[0]).createInstance();
+ }
+ });
+ replay(scopeContainer);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java
new file mode 100644
index 0000000000..79f37f514c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.Greeting;
+import static org.apache.tuscany.test.ArtifactFactory.createInboundWire;
+import static org.apache.tuscany.test.ArtifactFactory.createOutboundWire;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import static org.apache.tuscany.test.ArtifactFactory.terminateWire;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reportMatcher;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+import org.easymock.IArgumentMatcher;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class WireTestCase extends TestCase {
+
+ private static final String SCRIPT = "import org.apache.tuscany.container.groovy.mock.Greeting;"
+ + "class Foo implements Greeting{"
+ + " Greeting wire;"
+ + " "
+ + " void setWire(Greeting ref){"
+ + " wire = ref;"
+ + " };"
+ + " "
+ + " String greet(String name){"
+ + " return wire.greet(name); "
+ + " };"
+ + "}";
+
+ private static final String SCRIPT2 = "import org.apache.tuscany.container.groovy.mock.Greeting;"
+ + "class Foo implements Greeting{"
+ + " public String greet(String name){"
+ + " return name; "
+ + " }"
+ + "}";
+
+ private Class<? extends GroovyObject> implClass1;
+ private Class<? extends GroovyObject> implClass2;
+ private ScopeContainer scopeContainer;
+
+ /**
+ * Tests a basic invocation down a source wire
+ */
+ public void testReferenceWireInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass1);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ OutboundWire wire = createOutboundWire("wire", Greeting.class);
+ terminateWire(wire);
+
+ TargetInvoker invoker = createMock(TargetInvoker.class);
+ expect(invoker.isCacheable()).andReturn(false);
+ Message response = new MessageImpl();
+ response.setBody("foo");
+ expect(invoker.invoke(eqMessage())).andReturn(response);
+ replay(invoker);
+
+ for (OutboundInvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(invoker);
+ }
+ component.addOutboundWire(wire);
+ Greeting greeting = (Greeting) component.getServiceInstance();
+ assertEquals("foo", greeting.greet("foo"));
+ verify(invoker);
+ }
+
+ // todo this could be generalized and moved to test module
+ public static Message eqMessage() {
+ reportMatcher(new IArgumentMatcher() {
+ public boolean matches(Object object) {
+ if (!(object instanceof Message)) {
+ return false;
+ }
+ final Message msg = (Message) object;
+ Object[] body = (Object[]) msg.getBody();
+ return "foo".equals(body[0]);
+ }
+
+ public void appendTo(StringBuffer stringBuffer) {
+ }
+ });
+ return null;
+ }
+
+
+ /**
+ * Tests a basic invocation to a target
+ */
+ public void testTargetInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass2);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ Operation<Type> operation = new Operation<Type>("greet", null, null, null, false, null);
+ TargetInvoker invoker = component.createTargetInvoker(null, operation);
+ assertEquals("foo", invoker.invokeTarget(new String[]{"foo"}));
+ }
+
+
+ /**
+ * Tests a basic invocation down a target wire
+ */
+ public void testTargetWireInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass2);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ InboundWire wire = createInboundWire("Greeting", Greeting.class);
+ terminateWire(wire);
+ for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(component.createTargetInvoker(null, chain.getOperation()));
+ }
+ component.addInboundWire(wire);
+ Greeting greeting = (Greeting) component.getServiceInstance("Greeting");
+ assertEquals("foo", greeting.greet("foo"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ GroovyClassLoader cl = new GroovyClassLoader(getClass().getClassLoader());
+ implClass1 = cl.parseClass(SCRIPT);
+ implClass2 = cl.parseClass(SCRIPT2);
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return ((AtomicComponent) getCurrentArguments()[0]).createInstance();
+ }
+ });
+ replay(scopeContainer);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java
new file mode 100644
index 0000000000..8918c3dfd5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface AsyncTarget {
+
+ void invoke();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java
new file mode 100644
index 0000000000..b975491f16
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy.mock;
+
+public interface Greeting {
+
+ String setWire(Greeting ref);
+ String greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..2a04ae7a6c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:groovy="http://incubator.apache.org/tuscany/xmlns/container/groovy/1.0-incubator-M2"
+ name="groovy.test">
+
+ <component name="Greeting">
+ <groovy:implementation.groovy script="Foo.groovy"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy
new file mode 100644
index 0000000000..f0b0a3a9d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy
@@ -0,0 +1 @@
+Test Script \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/pom.xml
new file mode 100644
index 0000000000..f01f232c8f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>javascript</artifactId>
+ <name>Apache Tuscany JavaScript Container</name>
+ <description>Apache Tuscany JavaScript Container</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId> <!-- Reqd for E4X -->
+ <version>2.1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponent.java
new file mode 100644
index 0000000000..9872788a05
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponent.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.container.javascript.rhino.RhinoScriptInstance;
+
+/**
+ * The JavaScript component implementation.
+ */
+public class JavaScriptComponent extends AtomicComponentExtension {
+
+ private final List<Class<?>> services;
+
+ private final Map<String, Object> properties;
+
+ private RhinoScript rhinoScript;
+
+ public JavaScriptComponent(String name, RhinoScript rhinoScript, Map<String, Object> properties, List<Class<?>> services,
+ CompositeComponent parent, ScopeContainer scopeContainer, WireService wireService,
+ WorkContext workContext) {
+ super(name, parent, scopeContainer, wireService, workContext, null, 0);
+
+ this.rhinoScript = rhinoScript;
+ this.services = services;
+ this.scope = scopeContainer.getScope();
+ this.properties = properties;
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+
+ Map<String, Object> context = new HashMap<String, Object>(getProperties());
+
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ Object wireProxy = wireService.createProxy(wire);
+ //since all types that may be used in the reference interface may not be known to Rhino
+ //using the wireProxy as is will fail result in type conversion exceptions in cases where
+ //Rhino does not know enough of the tpypes used. Hence introduce a interceptor proxy,
+ //with weak typing (java.lang.Object) so that Rhino's call to the proxy succeeds. Then
+ //within this interceptor proxy perform data mediations required to correctly call the
+ //referenced service.
+ Class<?> businessInterface = wire.getServiceContract().getInterfaceClass();
+ JavaScriptReferenceProxy interceptingProxy =
+ new JavaScriptReferenceProxy(businessInterface,
+ wireProxy,
+ rhinoScript.createInstanceScope(context));
+ context.put(wire.getReferenceName(), interceptingProxy.createProxy());
+
+ }
+ }
+
+ return rhinoScript.createRhinoScriptInstance(context);
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return new JavaScriptInvoker(operation.getName(), (Class)operation.getOutputType().getLogical(), this);
+ }
+
+ // TODO: move all the following up to AtomicComponentExtension?
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public RhinoScriptInstance getTargetInstance() throws TargetException {
+ return (RhinoScriptInstance) scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getServiceInstance(null);
+ }
+
+ public Object getServiceInstance(String service) throws TargetException {
+ InboundWire wire = getInboundWire(service);
+ if (wire == null) {
+ TargetException e = new TargetException("ServiceDefinition not found"); // TODO better error message
+ e.setIdentifier(service);
+ throw e;
+ }
+ return wireService.createProxy(wire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentBuilder.java
new file mode 100644
index 0000000000..1987026e59
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentBuilder.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.container.javascript.utils.xmlfromxsd.XmlInstanceRegistry;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.xmlbeans.XmlObject;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Extension point for creating {@link JavaScriptComponent}s from an assembly configuration
+ */
+public class JavaScriptComponentBuilder extends ComponentBuilderExtension<JavaScriptImplementation> {
+
+ private static String head = "var xmlInstanceMap = new Array();";
+
+ private static String part1 = "xmlInstanceMap[\"";
+
+ private static String part2 = "\"] = ";
+
+ private static String part3 = ";";
+
+ private static String getXmlObjectFunction =
+ "function getXmlObject(xmlElementNamespace, xmlElementName){\n" +
+ "return xmlInstanceMap[xmlElementNamespace + \"#\" + xmlElementName];\n}";
+
+ XmlInstanceRegistry xmlInstRegistry;
+
+ @Constructor({"xmlInstRegistry"})
+ public JavaScriptComponentBuilder(@Autowire XmlInstanceRegistry reg) {
+ this.xmlInstRegistry = reg;
+ }
+
+ protected Class<JavaScriptImplementation> getImplementationType() {
+ return JavaScriptImplementation.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component build(CompositeComponent parent, ComponentDefinition<JavaScriptImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ JavaScriptImplementation implementation = componentDefinition.getImplementation();
+ JavaScriptComponentType componentType = implementation.getComponentType();
+
+ // get list of services provided by this component
+ Collection<ServiceDefinition> collection = componentType.getServices().values();
+ List<Class<?>> services = new ArrayList<Class<?>>(collection.size());
+ for (ServiceDefinition serviceDefinition : collection) {
+ services.add(serviceDefinition.getServiceContract().getInterfaceClass());
+ //do this for the set of references also
+ enhanceRhinoScript(serviceDefinition, implementation);
+ }
+
+ // get the properties for the component
+ Collection<PropertyValue<?>> propertyValues = componentDefinition.getPropertyValues().values();
+ Map<String, Object> properties = new HashMap<String, Object>();
+ for (PropertyValue propertyValue : propertyValues) {
+ properties.put(propertyValue.getName(), propertyValue.getValueFactory().getInstance());
+ }
+
+ RhinoScript rhinoScript = implementation.getRhinoScript();
+
+ // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method?
+ ScopeContainer scopeContainer;
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ scopeContainer = deploymentContext.getModuleScope();
+ } else {
+ scopeContainer = scopeRegistry.getScopeContainer(scope);
+ }
+
+ return new JavaScriptComponent(name, rhinoScript, properties, services, parent, scopeContainer, wireService, workContext);
+ }
+
+ private void enhanceRhinoScript(ServiceDefinition serviceDefn, JavaScriptImplementation implementation) throws BuilderConfigException {
+ //if the service interface of the component is a wsdl get the wsdl interface and generate
+ //xml instances for the elements in it. Add these xml instances to the rhinoscript.
+ //TODO : when interface.wsdl and wsdl registry is integrated remove this hardcoding and
+ //obtain wsdl from the interface.wsdl or wsdl registry
+ String wsdlPath = "org/apache/tuscany/container/javascript/rhino/helloworld.wsdl";
+
+ //this if block is a tempfix to get other testcases working. Again when a the interface.wsdl
+ //extension is in place this will be deleted. Right now this is the only way we know that
+ //a js has to do with an interface that is wsdl.
+ if (!implementation.getRhinoScript().getScriptName().endsWith("e4x.js")) {
+ return;
+ }
+
+ try {
+ Map<String, XmlObject> xmlInstanceMap = xmlInstRegistry.getXmlInstance(wsdlPath);
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(head);
+ sb.append("\n");
+ for (String xmlInstanceKey : xmlInstanceMap.keySet()) {
+ sb.append(part1);
+ sb.append(xmlInstanceKey);
+ sb.append(part2);
+ sb.append(xmlInstanceMap.get(xmlInstanceKey).toString());
+ sb.append(part3);
+ sb.append("\n");
+ }
+ // System.out.println(" **** - " + sb.toString());
+
+ sb.append(getXmlObjectFunction);
+
+ RhinoScript rhinoScript = implementation.getRhinoScript();
+ sb.append(rhinoScript.getScript());
+ rhinoScript.setScript(sb.toString());
+ rhinoScript.initScriptScope(rhinoScript.getScriptName(), sb.toString(), null, rhinoScript.getClassLoader());
+ implementation.setRhinoScript(rhinoScript);
+
+ } catch (Exception e) {
+ throw new BuilderConfigException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentType.java
new file mode 100644
index 0000000000..31a4db14b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentType.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+public class JavaScriptComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+
+ private Scope lifecycleScope = Scope.MODULE;
+
+ public JavaScriptComponentType() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public JavaScriptComponentType(ComponentType ct) {
+ // TODO: A bit hacky but this is so the non-JavaScript .componentType side file can be used for now
+ setInitLevel(ct.getInitLevel());
+ for (Object property : ct.getProperties().values()) {
+ add((Property)property);
+ }
+ for (Object reference : ct.getReferences().values()) {
+ add((ReferenceDefinition)reference);
+ }
+ for (Object service : ct.getServices().values()) {
+ add((ServiceDefinition)service);
+ }
+ }
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentTypeLoader.java
new file mode 100644
index 0000000000..e28daeceb0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptComponentTypeLoader.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ComponentType;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoSCAConfig;
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptComponentTypeLoader extends ComponentTypeLoaderExtension<JavaScriptImplementation> {
+
+ private JavaInterfaceProcessorRegistry processorRegistry;
+
+ public JavaScriptComponentTypeLoader(@Autowire JavaInterfaceProcessorRegistry processorRegistry) {
+ this.processorRegistry = processorRegistry;
+ }
+
+ @Override
+ protected Class<JavaScriptImplementation> getImplementationClass() {
+ return JavaScriptImplementation.class;
+ }
+
+ protected JavaScriptComponentType loadByIntrospection(CompositeComponent parent,
+ JavaScriptImplementation implementation,
+ DeploymentContext deploymentContext) throws
+ MissingResourceException,
+ InvalidServiceContractException {
+
+ RhinoScript rhinoScript = implementation.getRhinoScript();
+ RhinoSCAConfig scaConfig = rhinoScript.getSCAConfig();
+ if (!scaConfig.hasSCAConfig()) {
+ throw new IllegalArgumentException(
+ "must use either .componentType side file or JS SCA varriable definition");
+ }
+
+ // FIXME this should be a system service, not instantiated here
+ JavaScriptComponentType componentType = new JavaScriptIntrospector(null, processorRegistry)
+ .introspectScript(scaConfig, rhinoScript.getClassLoader());
+
+ return componentType;
+ }
+
+ protected String getResourceName(JavaScriptImplementation implementation) {
+ return implementation.getRhinoScript().getScriptName();
+ }
+
+ // TODO: must be possible to move all the following up in to ComponentTypeLoaderExtension
+
+ public void load(CompositeComponent parent, JavaScriptImplementation implementation,
+ DeploymentContext deploymentContext)
+ throws LoaderException {
+
+ URL resource = implementation.getRhinoScript().getClassLoader().getResource(getSideFileName(implementation));
+ JavaScriptComponentType componentType;
+ if (resource == null) {
+ try {
+ componentType = loadByIntrospection(parent, implementation, deploymentContext);
+ } catch (InvalidServiceContractException e) {
+ throw new LoaderException("Invalid service contract", e);
+ }
+ } else {
+ componentType = loadFromSidefile(resource, deploymentContext);
+ }
+
+ implementation.setComponentType(componentType);
+ }
+
+ protected JavaScriptComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext)
+ throws LoaderException {
+ ComponentType ct = loaderRegistry.load(null, url, ComponentType.class, deploymentContext);
+ JavaScriptComponentType jsct = new JavaScriptComponentType(ct);
+ return jsct;
+ }
+
+ private String getSideFileName(JavaScriptImplementation implementation) {
+ String baseName = getResourceName(implementation);
+ int lastDot = baseName.lastIndexOf('.');
+ if (lastDot != -1) {
+ baseName = baseName.substring(0, lastDot);
+ }
+ return baseName + ".componentType";
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementation.java
new file mode 100644
index 0000000000..7de479f096
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementation.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a JavaScript implementation.
+ */
+public class JavaScriptImplementation extends AtomicImplementation<JavaScriptComponentType> {
+
+ private RhinoScript rhinoScript;
+
+ public RhinoScript getRhinoScript() {
+ return rhinoScript;
+ }
+
+ public void setRhinoScript(RhinoScript rhinoScript) {
+ this.rhinoScript = rhinoScript;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoader.java
new file mode 100644
index 0000000000..67cc35afc2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoader.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling JavaScript <js:implementation.js> elements.
+ */
+public class JavaScriptImplementationLoader extends LoaderExtension<JavaScriptImplementation> {
+ private static final QName IMPLEMENTATION_JAVASCRIPT =
+ new QName("http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2", "implementation.js");
+
+ @Constructor({"registry"})
+ public JavaScriptImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_JAVASCRIPT;
+ }
+
+ public JavaScriptImplementation load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ String script = reader.getAttributeValue(null, "script");
+ if (script == null) {
+ throw new MissingResourceException("No script supplied");
+ }
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String source = loadSource(cl, script);
+
+ LoaderUtil.skipToEndElement(reader);
+
+ JavaScriptImplementation implementation = new JavaScriptImplementation();
+ RhinoScript rhinoScript = new RhinoScript(script, source, null, cl);
+ implementation.setRhinoScript(rhinoScript);
+ registry.loadComponentType(parent, implementation, deploymentContext);
+ return implementation;
+ }
+
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ URL url = cl.getResource(resource);
+ if (url == null) {
+ throw new MissingResourceException(resource);
+ }
+ InputStream is;
+ try {
+ is = url.openStream();
+ } catch (IOException e) {
+ MissingResourceException mre = new MissingResourceException(resource, e);
+ mre.setIdentifier(resource);
+ throw mre;
+ }
+ try {
+ Reader reader = new InputStreamReader(is, "UTF-8");
+ char[] buffer = new char[1024];
+ StringBuilder source = new StringBuilder();
+ int count;
+ while ((count = reader.read(buffer)) > 0) {
+ source.append(buffer, 0, count);
+ }
+ return source.toString();
+ } catch (IOException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(resource);
+ throw le;
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptIntrospector.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptIntrospector.java
new file mode 100644
index 0000000000..542504b62e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptIntrospector.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.util.Iterator;
+import java.util.Map;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoSCAConfig;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+
+/**
+ * Introspects JavaScript files for SCA configuration
+ */
+public class JavaScriptIntrospector {
+
+ private WSDLDefinitionRegistry wsdlRegistry;
+ private JavaInterfaceProcessorRegistry processorRegistry;
+
+ public JavaScriptIntrospector(@Autowire WSDLDefinitionRegistry wsdlRegistry,
+ @Autowire JavaInterfaceProcessorRegistry processorRegistry) {
+ this.wsdlRegistry = wsdlRegistry;
+ this.processorRegistry = processorRegistry;
+ }
+
+ public JavaScriptComponentType introspectScript(RhinoSCAConfig scaConfig, ClassLoader cl)
+ throws MissingResourceException, InvalidServiceContractException {
+ JavaScriptComponentType componentType = new JavaScriptComponentType();
+ introspectJavaInterface(componentType, cl, scaConfig.getJavaInterface());
+ introspectWSDLInterface(componentType, cl, scaConfig.getWSDLNamespace(), scaConfig.getWSDLPortType(),
+ scaConfig.getWSDLLocation());
+ introspectReferences(componentType, cl, scaConfig.getReferences());
+ introspectProperties(componentType, cl, scaConfig.getProperties());
+ introspectScope(componentType, scaConfig.getScope());
+ return componentType;
+ }
+
+ private void introspectScope(JavaScriptComponentType componentType, Scope scope) {
+ if (scope != null) {
+ componentType.setLifecycleScope(scope);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void introspectJavaInterface(ComponentType componentType, ClassLoader cl, String serviceClass)
+ throws MissingResourceException, InvalidServiceContractException {
+ if (serviceClass != null) {
+ ServiceDefinition service = new ServiceDefinition();
+ try {
+ ServiceContract<?> sc = processorRegistry.introspect(Class.forName(serviceClass));
+ service.setServiceContract(sc);
+ componentType.add(service);
+ } catch (ClassNotFoundException e) {
+ throw new MissingResourceException("Interface not found", e);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void introspectWSDLInterface(ComponentType componentType, ClassLoader cl, String wsdlNamespace,
+ String wsdlPortType, String wsdlLocation) {
+ if (wsdlNamespace == null && wsdlPortType == null && wsdlLocation == null) {
+ return;
+ }
+
+ PortType portType = null;
+ if (wsdlLocation != null) {
+ portType = readWSDLPortType(wsdlNamespace, wsdlPortType, wsdlLocation, portType);
+ } else {
+ portType = getPortType(wsdlNamespace, wsdlPortType);
+ }
+
+ ServiceDefinition service = new ServiceDefinition();
+ WSDLServiceContract wsdlSC = new WSDLServiceContract();
+ wsdlSC.setPortType(portType);
+ service.setServiceContract(wsdlSC);
+ componentType.add(service);
+ }
+
+ private PortType readWSDLPortType(String wsdlNamespace, String wsdlPortType, String wsdlLocation,
+ PortType portType) {
+ Definition wsdlDefinition;
+ try {
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ wsdlDefinition = reader.readWSDL(wsdlLocation.toString());
+ } catch (WSDLException e) {
+ throw new RuntimeException(e);
+
+ }
+ Map portTypes = wsdlDefinition.getPortTypes();
+ for (Iterator i = portTypes.keySet().iterator(); i.hasNext();) {
+ QName portTypeQN = (QName) i.next();
+ if (wsdlNamespace != null) {
+ if (!portTypeQN.getNamespaceURI().equals(wsdlNamespace)) {
+ continue;
+ }
+ }
+ if (wsdlPortType != null) {
+ if (!portTypeQN.getLocalPart().equals(wsdlPortType)) {
+ continue;
+ }
+ }
+ if (portType != null) {
+ throw new RuntimeException("multiple matching portTypes in wsdl: " + wsdlLocation);
+ }
+ portType = (PortType) portTypes.get(portTypeQN);
+ }
+ if (portType == null) {
+ throw new RuntimeException("portType not found in wsdl: " + wsdlLocation);
+ }
+ return portType;
+ }
+
+ private PortType getPortType(String wsdlNamespace, String wsdlPortType) {
+ if (wsdlPortType == null) {
+ throw new IllegalArgumentException("must specify the wsdlPortType in script SCA config");
+ }
+ PortType portType = null;
+ if (wsdlNamespace != null) {
+ QName portTypeQN = new QName(wsdlNamespace.toString(), wsdlPortType.toString());
+ portType = wsdlRegistry.getPortType(portTypeQN);
+ if (portType == null) {
+ throw new IllegalArgumentException("no WSDL registered for portType: " + portTypeQN);
+ }
+ } else {
+ // wsdlRegistry.getPortType(wsdlPortType.toString());
+ if (portType == null) {
+ throw new IllegalArgumentException("no WSDL registered for portType:" + wsdlPortType);
+ }
+ }
+ return portType;
+ }
+
+
+ private void introspectProperties(ComponentType componentType, ClassLoader cl, Map properties) {
+ }
+
+ private void introspectReferences(ComponentType componentType, ClassLoader cl, Map references) {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptInvoker.java
new file mode 100644
index 0000000000..281b417d64
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptInvoker.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.container.javascript.rhino.RhinoScriptInstance;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Dispatches to a JavaScript implementation instance
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class JavaScriptInvoker extends TargetInvokerExtension {
+
+ private JavaScriptComponent context;
+
+ private String functionName;
+
+ private Class responseClass;
+
+ public JavaScriptInvoker(String functionName, Class respClass, JavaScriptComponent context) {
+ this.functionName = functionName;
+ this.context = context;
+ this.responseClass = respClass;
+ }
+
+ /**
+ * Invokes a function on a script instance
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ RhinoScriptInstance target = context.getTargetInstance();
+ return target.invokeFunction(functionName, (Object[]) payload, responseClass);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptRefInvocInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptRefInvocInterceptor.java
new file mode 100644
index 0000000000..f8c978f833
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptRefInvocInterceptor.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * This Interceptor encasulates the data mediation required by the JavaScriptReferenceProxy. The
+ * invocation handler of this class traps the javascript reference calls, performs data mediation
+ * and calls then calls the actual referred service. This classes implementation is subject to
+ * review and change when the DataMediation infrastructure of Tuscany is ready.
+ *
+ */
+public class JavaScriptRefInvocInterceptor implements InvocationHandler {
+ private Object actualProxy;
+
+ private Class wireInterface;
+
+ private Scriptable instanceScope;
+
+ JavaScriptRefInvocInterceptor(Object wireProxy, Class wireIfc, Scriptable instScope) {
+ this.actualProxy = wireProxy;
+ this.wireInterface = wireIfc;
+ this.instanceScope = instScope;
+ }
+
+ public Object invoke(Object arg0, Method method, Object[] args) throws Throwable {
+ // TODO Auto-generated method stub
+ Context cx = Context.enter();
+ try {
+ Method invokedMethod = getInvokedMethod(method.getName());
+ Object[] tranformedArgs = new Object[args.length];
+ for (int count = 0; count < args.length; ++count) {
+ tranformedArgs[count] = fromJavaScript(invokedMethod.getParameterTypes()[count], args[count]);
+ }
+
+ Object response = invokedMethod.invoke(actualProxy, tranformedArgs);
+ response = toJavaScript(response, instanceScope, cx);
+ return response;
+ } finally {
+ Context.exit();
+ }
+ }
+
+ private Method getInvokedMethod(String methodName) {
+ Method[] methods = wireInterface.getMethods();
+
+ for (int count = 0; count < methods.length; ++count) {
+ if (methods[count].getName().equals(methodName)) {
+ return methods[count];
+ }
+ }
+ throw new RuntimeException("Unable to find invocation method");
+ }
+
+ protected Object fromJavaScript(Class reqArgType, Object jsArg) throws Exception {
+ Object javaArg;
+ if (Context.getUndefinedValue().equals(jsArg)) {
+ javaArg = null;
+ } else if (jsArg instanceof XMLObject) {
+ // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost???
+ Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) jsArg, "copy", new Object[0]);
+ Wrapper wrapper = (Wrapper) ScriptableObject.callMethod(jsXML, "getXmlObject", new Object[0]);
+ javaArg = wrapper.unwrap();
+
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(javaArg.toString().getBytes()));
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader);
+ javaArg = staxOMBuilder.getDocumentElement();
+ } else if (jsArg instanceof Wrapper) {
+ javaArg = ((Wrapper) jsArg).unwrap();
+ } else {
+ if (reqArgType != null) {
+ javaArg = Context.jsToJava(jsArg, reqArgType);
+ } else {
+ javaArg = Context.jsToJava(jsArg, String.class);
+ }
+ }
+
+ return javaArg;
+ }
+
+ protected Object toJavaScript(Object retVal, Scriptable scope, Context cx) throws RuntimeException {
+ Object jsRetVal;
+ if (retVal instanceof OMElement) {
+ try {
+ XmlObject xmlObject = XmlObject.Factory.parse(retVal.toString());
+ Object jsXML = cx.getWrapFactory().wrap(cx, scope, xmlObject, XmlObject.class);
+ jsRetVal = cx.newObject(scope, "XML", new Object[] { jsXML });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else if (retVal instanceof XmlObject) {
+ Object jsXML = cx.getWrapFactory().wrap(cx, scope, (XmlObject) retVal, XmlObject.class);
+ jsRetVal = cx.newObject(scope, "XML", new Object[] { jsXML });
+ } else {
+ jsRetVal = Context.toObject(retVal, scope);
+ }
+
+ return jsRetVal;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptReferenceProxy.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptReferenceProxy.java
new file mode 100644
index 0000000000..8b432872b8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/JavaScriptReferenceProxy.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import net.sf.cglib.asm.ClassWriter;
+import net.sf.cglib.asm.CodeVisitor;
+import net.sf.cglib.asm.Constants;
+import net.sf.cglib.asm.Type;
+
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * This is a proxy that will mediate reference calls from the JavaScript. The mediation code here will be reviewed when the DataMediation
+ * infrastructure is ready. This proxy assmes that there is no verloading of service methods on the reference interface i.e. there are no two service
+ * methods that have the same method name or operation name.
+ */
+public class JavaScriptReferenceProxy {
+
+ private Class interfaze;
+
+ private Object wireProxy;
+
+ private Scriptable instanceScope;
+
+ public JavaScriptReferenceProxy(Class interfaze, Object wireProxy, Scriptable instScope) {
+ this.interfaze = interfaze;
+ this.wireProxy = wireProxy;
+ this.instanceScope = instScope;
+ }
+
+ public Object createProxy() {
+ try {
+ GenericProxyClassLoader classloader = new GenericProxyClassLoader();
+ final byte[] byteCode = generateGenericInterface(interfaze);
+
+ Class genericInterface = classloader.defineClass(byteCode);
+ InvocationHandler proxyHandler = new JavaScriptRefInvocInterceptor(wireProxy,
+ interfaze, instanceScope);
+ // return genericInterface.cast(Proxy.newProxyInstance(classloader, new Class[]{genericInterface}, proxyHandler));
+ return Proxy.newProxyInstance(classloader,
+ new Class[]{genericInterface},
+ proxyHandler);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static byte[] generateGenericInterface(Class serviceInterface) {
+ String interfazeName = serviceInterface.getCanonicalName();
+ ClassWriter cw = new ClassWriter(false);
+
+ cw.visit(Constants.V1_5,
+ Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE,
+ interfazeName.replace('.',
+ '/'),
+ "java/lang/Object",
+ null,
+ serviceInterface.getSimpleName() + ".java");
+
+ StringBuffer argsAndReturn = new StringBuffer("(");
+ Method[] methods = serviceInterface.getMethods();
+ for (int count = 0; count < methods.length; ++count) {
+ argsAndReturn = new StringBuffer("(");
+ Class[] paramTypes = methods[count].getParameterTypes();
+ Class returnType = methods[count].getReturnType();
+
+ for (int paramCount = 0; paramCount < paramTypes.length; ++paramCount) {
+ argsAndReturn.append(Type.getType(Object.class));
+ }
+ argsAndReturn.append(")");
+ argsAndReturn.append(Type.getType(Object.class));
+
+ Class[] exceptionTypes = methods[count].getExceptionTypes();
+ String[] exceptions = new String[exceptionTypes.length];
+ for (int excCount = 0; excCount < exceptionTypes.length; ++excCount) {
+ exceptions[excCount] = exceptionTypes[excCount].getName();
+ exceptions[excCount] = exceptions[excCount].replace('.',
+ '/');
+ }
+
+ CodeVisitor cv = cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT,
+ methods[count].getName(),
+ argsAndReturn.toString(),
+ exceptions,
+ null);
+ cw.visitEnd();
+ }
+
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+
+ private class GenericProxyClassLoader extends ClassLoader {
+ public Class defineClass(byte[] byteArray) {
+ try {
+ return defineClass(null,
+ byteArray,
+ 0,
+ byteArray.length);
+ } catch (Throwable e) {
+ return null;
+ }
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvoker.java
new file mode 100644
index 0000000000..b2064f9110
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvoker.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * An invoker for a specific function in a JavaScript script
+ */
+public class RhinoFunctionInvoker {
+
+ private Scriptable instanceScope;
+
+ private Function function;
+
+ private Class responseClass;
+
+ public RhinoFunctionInvoker(Scriptable instanceScope, Function function, Class responseClass) {
+ this.instanceScope = instanceScope;
+ this.function = function;
+ this.responseClass = responseClass;
+ }
+
+ public Object invoke(Object[] args) {
+ Context cx = Context.enter();
+ try {
+
+ Object[] jsArgs = toJavaScript(args, instanceScope, cx);
+ Object jsResponse = function.call(cx, instanceScope, instanceScope, jsArgs);
+ Object response = fromJavaScript(jsResponse);
+ return response;
+
+ } catch ( Exception e ) {
+ throw new RuntimeException(e);
+ }
+ finally {
+ Context.exit();
+ }
+ }
+
+ protected Object[] toJavaScript(Object[] arg, Scriptable scope, Context cx) throws RuntimeException {
+ Object[] jsArgs;
+ if (arg == null) {
+ jsArgs = new Object[0];
+ } else if (arg.length == 1 && arg[0] instanceof OMElement) {
+ try {
+ XmlObject xmlObject = XmlObject.Factory.parse(arg[0].toString());
+ Object jsXML = cx.getWrapFactory().wrap(cx, scope, xmlObject, XmlObject.class);
+ jsArgs = new Object[] { cx.newObject(scope, "XML", new Object[] { jsXML }) };
+ } catch ( Exception e ) {
+ throw new RuntimeException(e);
+ }
+ } else if (arg.length == 1 && arg[0] instanceof XmlObject) {
+ Object jsXML = cx.getWrapFactory().wrap(cx, scope, (XmlObject)arg[0], XmlObject.class);
+ jsArgs = new Object[] { cx.newObject(scope, "XML", new Object[] { jsXML }) };
+ } else {
+ jsArgs = new Object[arg.length];
+ for (int i = 0; i < jsArgs.length; i++) {
+ jsArgs[i] = Context.toObject(arg[i], scope);
+ }
+ }
+
+ return jsArgs;
+ }
+
+ protected Object fromJavaScript(Object o) throws Exception {
+ Object response;
+ if (Context.getUndefinedValue().equals(o)) {
+ response = null;
+ } else if (o instanceof XMLObject) {
+ // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost???
+ Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
+ Wrapper wrapper = (Wrapper) ScriptableObject.callMethod(jsXML, "getXmlObject", new Object[0]);
+ response = wrapper.unwrap();
+
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(response.toString().getBytes()));
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader);
+ response = staxOMBuilder.getDocumentElement();
+
+ } else if (o instanceof Wrapper) {
+ response = ((Wrapper) o).unwrap();
+ } else {
+ if (responseClass != null) {
+ response = Context.jsToJava(o, responseClass);
+ } else {
+ response = Context.jsToJava(o, String.class);
+ }
+ }
+ return response;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfig.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfig.java
new file mode 100644
index 0000000000..af27403c03
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfig.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Scope;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.UniqueTag;
+
+/**
+ * Represents the variable defining the SCA aspects of the script
+ * <code>
+ * SCA = {
+ * javaInterface : "my.pkg.ClassName",
+ * wsdlPortType : "wsdlPortTypeName",
+ * wsdlNameSpace : "http://my.namespace.com",
+ * wsdlLocation : "\wsdl\mywsdl.txt",
+ * properties : { "foo" : ["java.lang.String", "defaultValue"],},
+ * references : {},
+ * scope : 'stateless'|'request'|'conversational'|'composite',
+ * }
+ * </code>
+ * The config must define the service with either javaInterface or wsdl. When
+ * using wsdl the three parameters are optional. If wsdlLocation is used that is the
+ * WSDL document used, and the namespace and portType parameters are only required if
+ * the WSDL definition defines multiple portTypes.
+ */
+public class RhinoSCAConfig {
+
+ private boolean hasSCAConfig;
+
+ private String javaInterface;
+
+ private String wsdlLocation;
+
+ private String wsdlNamespace;
+
+ private String wsdlPortType;
+
+ private Map properties;
+
+ private Map references;
+
+ private Scope scope;
+
+ public RhinoSCAConfig(Scriptable scriptScope) {
+ Object o = scriptScope.get("SCA", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ hasSCAConfig = true;
+ Scriptable scaVar = (Scriptable) o;
+ o = scaVar.get("javaInterface", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ this.javaInterface = o.toString();
+ }
+ o = scaVar.get("wsdlLocation", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ this.wsdlLocation = o.toString();
+ }
+ o = scaVar.get("wsdlPortType", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ this.wsdlPortType = o.toString();
+ }
+ o = scaVar.get("wsdlNamespace", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ this.wsdlNamespace = o.toString();
+ }
+ if (javaInterface != null) {
+ if (wsdlLocation != null || wsdlPortType != null || wsdlNamespace != null) {
+ throw new IllegalArgumentException("script SCA config defines both Java and WSDL service interface");
+ }
+ } else {
+ if (wsdlLocation == null && wsdlPortType == null && wsdlNamespace == null) {
+ throw new IllegalArgumentException("script SCA config must define either Java or WSDL service interface");
+ }
+ }
+
+ this.properties = new HashMap();
+ o = scaVar.get("properties", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ // TODO parse properties
+ }
+
+ this.references = new HashMap();
+ o = scaVar.get("references", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ // TODO parse references
+ }
+
+ o = scaVar.get("scope", scriptScope);
+ if (o != null && UniqueTag.NOT_FOUND != o) {
+ if ("stateless".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.STATELESS;
+ } else if ("request".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.REQUEST;
+ } else if ("conversational".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.SESSION; // TODO: where's CONVERSATIONAL?
+ } else if ("composite".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.MODULE; // TODO: composite = MODULE for now?
+ } else {
+ throw new IllegalArgumentException("invalid scope value: " + o);
+ }
+ }
+
+ }
+ }
+
+ public boolean hasSCAConfig() {
+ return hasSCAConfig;
+ }
+
+ public String getJavaInterface() {
+ return javaInterface;
+ }
+
+ public Map getProperties() {
+ return properties;
+ }
+
+ public Map getReferences() {
+ return references;
+ }
+
+ public String getWSDLLocation() {
+ return wsdlLocation;
+ }
+
+ public String getWSDLNamespace() {
+ return wsdlNamespace;
+ }
+
+ public String getWSDLPortType() {
+ return wsdlPortType;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScript.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScript.java
new file mode 100644
index 0000000000..3552372223
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScript.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.ImporterTopLevel;
+import org.mozilla.javascript.Script;
+import org.mozilla.javascript.Scriptable;
+
+/**
+ * A RhinoScript represents a compiled JavaScript script
+ */
+public class RhinoScript {
+
+ protected String scriptName;
+
+ protected String script;
+
+ protected Scriptable scriptScope;
+
+ protected Map<String, Class> responseClasses;
+
+ protected ClassLoader classLoader;
+
+ /*
+ * Enable dynamic scopes so a script can be used concurrently with a global shared scope and individual execution scopes. See
+ * http://www.mozilla.org/rhino/scopes.html
+ */
+ private static class MyFactory extends ContextFactory {
+ protected boolean hasFeature(Context cx, int featureIndex) {
+ if (featureIndex == Context.FEATURE_DYNAMIC_SCOPE) {
+ return true;
+ }
+ return super.hasFeature(cx, featureIndex);
+ }
+ }
+
+ static {
+ ContextFactory.initGlobal(new MyFactory());
+ }
+
+ /**
+ * Create a new RhinoScript.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ */
+ public RhinoScript(String scriptName, String script) {
+ this(scriptName, script, (Map) null, null);
+ }
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ * @param context
+ * name-value pairs that are added in to the scope where the script is compiled. May be null. The value objects are made available to
+ * the script by using a variable with the name.
+ * @param classLoader
+ * the ClassLoader Rhino should use to locate any user Java classes used in the script
+ */
+ public RhinoScript(String scriptName, String script, Map context, ClassLoader classLoader) {
+ this.scriptName = scriptName;
+ this.script = script;
+ this.responseClasses = new HashMap<String, Class>();
+ this.classLoader = classLoader;
+ initScriptScope(scriptName, script, context, classLoader);
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @return a RhinoScriptInstance
+ */
+ public RhinoScriptInstance createRhinoScriptInstance() {
+ return createRhinoScriptInstance(null);
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ */
+ public RhinoScriptInstance createRhinoScriptInstance(Map<String, Object> context) {
+ Scriptable instanceScope = createInstanceScope(context);
+ RhinoScriptInstance rsi = new RhinoScriptInstance(scriptScope, instanceScope, context, responseClasses);
+ return rsi;
+ }
+
+ /**
+ * Initialize the Rhino Scope for this script instance
+ */
+ public Scriptable createInstanceScope(Map<String, Object> context) {
+ Context cx = Context.enter();
+ try {
+
+ Scriptable instanceScope = cx.newObject(scriptScope);
+ instanceScope.setPrototype(scriptScope);
+ instanceScope.setParentScope(null);
+
+ addContexts(instanceScope, context);
+
+ return instanceScope;
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Create a Rhino scope and compile the script into it
+ */
+ public void initScriptScope(String fileName, String scriptCode, Map context, ClassLoader cl) {
+ Context cx = Context.enter();
+ try {
+ if (cl != null) {
+ // TODO: broken with the way the tuscany launcher now uses class loaders
+ // cx.setApplicationClassLoader(cl);
+ }
+ this.scriptScope = new ImporterTopLevel(cx, true);
+ Script compiledScript = cx.compileString(scriptCode, fileName, 1, null);
+ compiledScript.exec(cx, scriptScope);
+ addContexts(scriptScope, context);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ }
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public Scriptable getScriptScope() {
+ return scriptScope;
+ }
+
+ public Map<String, Class> getResponseClasses() {
+ return responseClasses;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ /**
+ * Set the Java type of a response value. JavaScript is dynamically typed so Rhino cannot always work out what the intended Java type of a
+ * response should be, for example should the statement "return 42" be a Java int, or Integer or Double etc. When Rhino can't determine the type
+ * it will default to returning a String, using this method enables overriding the Rhino default to use a specific Java type.
+ */
+ public void setResponseClass(String functionName, Class responseClasses) {
+ this.responseClasses.put(functionName, responseClasses);
+ }
+
+ public RhinoSCAConfig getSCAConfig() {
+ return new RhinoSCAConfig(getScriptScope());
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstance.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstance.java
new file mode 100644
index 0000000000..508bc2a90a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstance.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.UniqueTag;
+
+/**
+ * An invokeable instance of a JavaScript script.
+ */
+public class RhinoScriptInstance {
+
+ private Scriptable scriptScope;
+
+ private Scriptable instanceScope;
+
+ private Map<String, Class> responseClasses;
+
+ public RhinoScriptInstance(Scriptable scriptScope, Scriptable instanceScope, Map<String, Object> context, Map<String, Class> responseClasses) {
+ this.scriptScope = scriptScope;
+ this.instanceScope = instanceScope;
+ this.responseClasses = responseClasses;
+ if (this.responseClasses == null) {
+ this.responseClasses = new HashMap<String, Class>();
+ }
+ addContexts(instanceScope, context);
+ }
+
+ public Object invokeFunction(String functionName, Object[] args) {
+ return invokeFunction(functionName, args, null);
+ }
+
+ public Object invokeFunction(String functionName, Object[] args, Class respClass) {
+ RhinoFunctionInvoker invoker = createRhinoFunctionInvoker(functionName, respClass);
+ return invoker.invoke(args);
+ }
+
+ public RhinoFunctionInvoker createRhinoFunctionInvoker(String functionName) {
+ return createRhinoFunctionInvoker(functionName, null);
+ }
+
+
+ public RhinoFunctionInvoker createRhinoFunctionInvoker(String functionName, Class responseClass) {
+ Function function = getFunction(functionName);
+ //Class responseClass = responseClasses.get(functionName);
+ RhinoFunctionInvoker invoker = new RhinoFunctionInvoker(instanceScope, function, responseClass);
+ return invoker;
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ Context.enter();
+ try {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ } finally {
+ Context.exit();
+ }
+ }
+ }
+
+ /**
+ * Get the Rhino Function object for the named script function
+ */
+ protected Function getFunction(String functionName) {
+
+ Object handleObj = scriptScope.get(functionName, instanceScope);
+ if (UniqueTag.NOT_FOUND.equals(handleObj)) {
+ // Bit of a hack so E4X scripts don't need to define a function for every operation
+ handleObj = scriptScope.get("process", instanceScope);
+ }
+ if (!(handleObj instanceof Function)) {
+ throw new RuntimeException("script function '" + functionName + "' is undefined or not a function");
+ }
+
+ return (Function) handleObj;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsHandler.java
new file mode 100644
index 0000000000..b724b33ac3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsHandler.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+/**
+ * This interface is to be implemented by classes that wish to
+ * handle commandline arguments.
+ *
+ */
+public interface CmdLineArgsHandler {
+ public void handleArgument(String optionFlag, String argValue) throws IllegalArgumentException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsProcessor.java
new file mode 100644
index 0000000000..914f1d03f2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/CmdLineArgsProcessor.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+/**
+ * This class provides a generic command line arguments processing utility. The processArgs
+ * method of this class processes the command line arguments that could contain option flags,
+ * options and values and calls a ArgumentHanlder instance for handling the agruments.
+ *
+ */
+public class CmdLineArgsProcessor {
+ private String printUsageMessage = "No hints available on Usage!";
+
+ private CmdLineArgsHandler argsHandler = null;
+
+ public static final String HYPEN = "-";
+
+ public void processArgs(String[] args) {
+ try {
+ if (args.length == 0) {
+ printUsage();
+ } else {
+ parseAndHandleArgs(args);
+ }
+ } catch (Exception e) {
+ System.out.println("Exception in processing argument - " + e);
+ printUsage();
+ }
+
+ }
+
+ public void parseAndHandleArgs(String[] args) throws Exception {
+ int index = 0;
+ while (index < args.length - 1) {
+ if (args[index].startsWith(HYPEN) && !args[index + 1].startsWith(HYPEN)) {
+ argsHandler.handleArgument(args[index].substring(1), args[index + 1]);
+ index = index + 2;
+ } else {
+ throw new IllegalArgumentException("Wrong Usage of options!");
+ }
+ }
+ }
+
+ protected void printUsage() {
+
+ }
+
+ public CmdLineArgsHandler getArgsHandler() {
+ return argsHandler;
+ }
+
+ public void setArgsHandler(CmdLineArgsHandler argsHandler) {
+ this.argsHandler = argsHandler;
+ }
+
+ public String getPrintUsageMessage() {
+ return printUsageMessage;
+ }
+
+ public void setPrintUsageMessage(String printUsageMessage) {
+ this.printUsageMessage = printUsageMessage;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/TuscanySampleXmlUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/TuscanySampleXmlUtil.java
new file mode 100644
index 0000000000..a0155c76e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/TuscanySampleXmlUtil.java
@@ -0,0 +1,1097 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.SchemaParticle;
+import org.apache.xmlbeans.SchemaLocalElement;
+import org.apache.xmlbeans.SchemaProperty;
+import org.apache.xmlbeans.GDuration;
+import org.apache.xmlbeans.GDurationBuilder;
+import org.apache.xmlbeans.GDate;
+import org.apache.xmlbeans.GDateBuilder;
+import org.apache.xmlbeans.XmlAnySimpleType;
+import org.apache.xmlbeans.SimpleValue;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlInteger;
+import org.apache.xmlbeans.XmlDate;
+import org.apache.xmlbeans.XmlDateTime;
+import org.apache.xmlbeans.XmlTime;
+import org.apache.xmlbeans.XmlGYear;
+import org.apache.xmlbeans.XmlGYearMonth;
+import org.apache.xmlbeans.XmlGMonth;
+import org.apache.xmlbeans.XmlGMonthDay;
+import org.apache.xmlbeans.XmlGDay;
+import org.apache.xmlbeans.XmlDecimal;
+import org.apache.xmlbeans.XmlDuration;
+import org.apache.xmlbeans.soap.SchemaWSDLArrayType;
+import org.apache.xmlbeans.soap.SOAPArrayType;
+import org.apache.xmlbeans.impl.util.Base64;
+import org.apache.xmlbeans.impl.util.HexBin;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Random;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This class is a replication of the XMLBeans SampleXMLutil class. This replication
+ * is required to overide the XMLBeans behaviour of this class in certain places. Since
+ * most methods of the XMLBeans implementation of this class is private, no overiding
+ * has been possible using inheritance. Hence this replication.
+ *
+ */
+public class TuscanySampleXmlUtil {
+ private static final String BLANK_STRING = " ";
+
+ private boolean generate_sample_data = false;
+
+ private boolean _soapEnc;
+
+ private static final int MAX_ELEMENTS = 1000;
+
+ private int _nElements;
+
+ boolean flag = true;
+
+ private TuscanySampleXmlUtil(boolean soapEnc) {
+ _soapEnc = soapEnc;
+ }
+
+ public TuscanySampleXmlUtil() {
+ this(false);
+ }
+
+ public String createSampleForType(SchemaType sType) {
+ XmlObject object = XmlObject.Factory.newInstance();
+ XmlCursor cursor = object.newCursor();
+ // Skip the document node
+ cursor.toNextToken();
+ // Using the type and the cursor, call the utility method to get a
+ // sample XML payload for that Schema element
+ createSampleForType(sType, cursor);
+ // Cursor now contains the sample payload
+ // Pretty print the result. Note that the cursor is positioned at the
+ // end of the doc so we use the original xml object that the cursor was
+ // created upon to do the xmlText() against.
+ XmlOptions options = new XmlOptions();
+ options.put(XmlOptions.SAVE_PRETTY_PRINT);
+ options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 2);
+ options.put(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES);
+ String result = object.xmlText(options);
+ return result;
+ }
+
+ Random _picker = new Random(1);
+
+ /**
+ * Cursor position
+ * Before:
+ * <theElement>^</theElement>
+ * After:
+ * <theElement><lots of stuff/>^</theElement>
+ */
+ private void createSampleForType(SchemaType stype, XmlCursor xmlc) {
+ if (_typeStack.contains(stype))
+ //if ( !flag )
+ return;
+ //else
+ // flag = false;
+
+ _typeStack.add(stype);
+
+ try {
+ if (stype.isSimpleType() || stype.isURType()) {
+ processSimpleType(stype, xmlc);
+ return;
+ }
+
+ // complex Type
+ // <theElement>^</theElement>
+ processAttributes(stype, xmlc);
+
+ // <theElement attri1="string">^</theElement>
+ switch (stype.getContentType()) {
+ case SchemaType.NOT_COMPLEX_TYPE:
+ case SchemaType.EMPTY_CONTENT:
+ // noop
+ break;
+ case SchemaType.SIMPLE_CONTENT: {
+ processSimpleType(stype, xmlc);
+ }
+ break;
+ case SchemaType.MIXED_CONTENT:
+ if (isGenerate_sample_data())
+ xmlc.insertChars(pick(WORDS) + " ");
+ if (stype.getContentModel() != null) {
+ processParticle(stype.getContentModel(), xmlc, true);
+ }
+ if (isGenerate_sample_data())
+ xmlc.insertChars(pick(WORDS));
+
+ break;
+ case SchemaType.ELEMENT_CONTENT:
+ if (stype.getContentModel() != null) {
+ processParticle(stype.getContentModel(), xmlc, false);
+ }
+ break;
+ }
+ } finally {
+ _typeStack.remove(_typeStack.size() - 1);
+ }
+ }
+
+ private void processSimpleType(SchemaType stype, XmlCursor xmlc) {
+ String sample = sampleDataForSimpleType(stype);
+ xmlc.insertChars(sample);
+
+ }
+
+ private String sampleDataForSimpleType(SchemaType sType) {
+ if (isGenerate_sample_data()) {
+ return generateSampleDataForSimpleType(sType);
+ } else {
+ return BLANK_STRING;
+ }
+ }
+
+ private String generateSampleDataForSimpleType(SchemaType sType) {
+ if (XmlObject.type.equals(sType))
+ return "anyType";
+
+ if (XmlAnySimpleType.type.equals(sType))
+ return "anySimpleType";
+
+ if (sType.getSimpleVariety() == SchemaType.LIST) {
+ SchemaType itemType = sType.getListItemType();
+ StringBuffer sb = new StringBuffer();
+ int length = pickLength(sType);
+ if (length > 0)
+ sb.append(sampleDataForSimpleType(itemType));
+ for (int i = 1; i < length; i += 1) {
+ sb.append(' ');
+ sb.append(sampleDataForSimpleType(itemType));
+ }
+ return sb.toString();
+ }
+
+ if (sType.getSimpleVariety() == SchemaType.UNION) {
+ SchemaType[] possibleTypes = sType.getUnionConstituentTypes();
+ if (possibleTypes.length == 0)
+ return "";
+ return sampleDataForSimpleType(possibleTypes[pick(possibleTypes.length)]);
+ }
+
+ XmlAnySimpleType[] enumValues = sType.getEnumerationValues();
+ if (enumValues != null && enumValues.length > 0) {
+ return enumValues[pick(enumValues.length)].getStringValue();
+ }
+
+ switch (sType.getPrimitiveType().getBuiltinTypeCode()) {
+ default:
+ case SchemaType.BTC_NOT_BUILTIN:
+ return "";
+
+ case SchemaType.BTC_ANY_TYPE:
+ case SchemaType.BTC_ANY_SIMPLE:
+ return "anything";
+
+ case SchemaType.BTC_BOOLEAN:
+ return pick(2) == 0 ? "true" : "false";
+
+ case SchemaType.BTC_BASE_64_BINARY: {
+ String result = null;
+ try {
+ result = new String(Base64.encode(formatToLength(pick(WORDS), sType).getBytes("utf-8")));
+ } catch (java.io.UnsupportedEncodingException e) { /* Can't possibly happen */
+ }
+ return result;
+ }
+
+ case SchemaType.BTC_HEX_BINARY:
+ return HexBin.encode(formatToLength(pick(WORDS), sType));
+
+ case SchemaType.BTC_ANY_URI:
+ return formatToLength("http://www." + pick(DNS1) + "." + pick(DNS2) + "/" + pick(WORDS) + "/" + pick(WORDS), sType);
+
+ case SchemaType.BTC_QNAME:
+ return formatToLength("qname", sType);
+
+ case SchemaType.BTC_NOTATION:
+ return formatToLength("notation", sType);
+
+ case SchemaType.BTC_FLOAT:
+ return "1.5E2";
+ case SchemaType.BTC_DOUBLE:
+ return "1.051732E7";
+ case SchemaType.BTC_DECIMAL:
+ switch (closestBuiltin(sType).getBuiltinTypeCode()) {
+ case SchemaType.BTC_SHORT:
+ return formatDecimal("1", sType);
+ case SchemaType.BTC_UNSIGNED_SHORT:
+ return formatDecimal("5", sType);
+ case SchemaType.BTC_BYTE:
+ return formatDecimal("2", sType);
+ case SchemaType.BTC_UNSIGNED_BYTE:
+ return formatDecimal("6", sType);
+ case SchemaType.BTC_INT:
+ return formatDecimal("3", sType);
+ case SchemaType.BTC_UNSIGNED_INT:
+ return formatDecimal("7", sType);
+ case SchemaType.BTC_LONG:
+ return formatDecimal("10", sType);
+ case SchemaType.BTC_UNSIGNED_LONG:
+ return formatDecimal("11", sType);
+ case SchemaType.BTC_INTEGER:
+ return formatDecimal("100", sType);
+ case SchemaType.BTC_NON_POSITIVE_INTEGER:
+ return formatDecimal("-200", sType);
+ case SchemaType.BTC_NEGATIVE_INTEGER:
+ return formatDecimal("-201", sType);
+ case SchemaType.BTC_NON_NEGATIVE_INTEGER:
+ return formatDecimal("200", sType);
+ case SchemaType.BTC_POSITIVE_INTEGER:
+ return formatDecimal("201", sType);
+ default:
+ case SchemaType.BTC_DECIMAL:
+ return formatDecimal("1000.00", sType);
+ }
+
+ case SchemaType.BTC_STRING: {
+ String result;
+ switch (closestBuiltin(sType).getBuiltinTypeCode()) {
+ case SchemaType.BTC_STRING:
+ case SchemaType.BTC_NORMALIZED_STRING:
+ result = "string";
+ break;
+
+ case SchemaType.BTC_TOKEN:
+ result = "token";
+ break;
+
+ default:
+ result = "string";
+ break;
+ }
+
+ return formatToLength(result, sType);
+ }
+
+ case SchemaType.BTC_DURATION:
+ return formatDuration(sType);
+
+ case SchemaType.BTC_DATE_TIME:
+ case SchemaType.BTC_TIME:
+ case SchemaType.BTC_DATE:
+ case SchemaType.BTC_G_YEAR_MONTH:
+ case SchemaType.BTC_G_YEAR:
+ case SchemaType.BTC_G_MONTH_DAY:
+ case SchemaType.BTC_G_DAY:
+ case SchemaType.BTC_G_MONTH:
+ return formatDate(sType);
+ }
+ }
+
+ // a bit from the Aenid
+ public static final String[] WORDS = new String[] { "ipsa", "iovis", "rapidum", "iaculata", "e", "nubibus", "ignem", "disiecitque", "rates",
+ "evertitque", "aequora", "ventis", "illum", "exspirantem", "transfixo", "pectore", "flammas", "turbine", "corripuit", "scopuloque",
+ "infixit", "acuto", "ast", "ego", "quae", "divum", "incedo", "regina", "iovisque", "et", "soror", "et", "coniunx", "una", "cum", "gente",
+ "tot", "annos", "bella", "gero", "et", "quisquam", "numen", "iunonis", "adorat", "praeterea", "aut", "supplex", "aris", "imponet",
+ "honorem", "talia", "flammato", "secum", "dea", "corde", "volutans", "nimborum", "in", "patriam", "loca", "feta", "furentibus",
+ "austris", "aeoliam", "venit", "hic", "vasto", "rex", "aeolus", "antro", "luctantis", "ventos", "tempestatesque", "sonoras", "imperio",
+ "premit", "ac", "vinclis", "et", "carcere", "frenat", "illi", "indignantes", "magno", "cum", "murmure", "montis", "circum", "claustra",
+ "fremunt", "celsa", "sedet", "aeolus", "arce", "sceptra", "tenens", "mollitque", "animos", "et", "temperat", "iras", "ni", "faciat",
+ "maria", "ac", "terras", "caelumque", "profundum", "quippe", "ferant", "rapidi", "secum", "verrantque", "per", "auras", "sed", "pater",
+ "omnipotens", "speluncis", "abdidit", "atris", "hoc", "metuens", "molemque", "et", "montis", "insuper", "altos", "imposuit", "regemque",
+ "dedit", "qui", "foedere", "certo", "et", "premere", "et", "laxas", "sciret", "dare", "iussus", "habenas", };
+
+ private static final String[] DNS1 = new String[] { "corp", "your", "my", "sample", "company", "test", "any" };
+
+ private static final String[] DNS2 = new String[] { "com", "org", "com", "gov", "org", "com", "org", "com", "edu" };
+
+ private int pick(int n) {
+ return _picker.nextInt(n);
+ }
+
+ private String pick(String[] a) {
+ return a[pick(a.length)];
+ }
+
+ private String pick(String[] a, int count) {
+ if (count <= 0)
+ return "";
+
+ int i = pick(a.length);
+ StringBuffer sb = new StringBuffer(a[i]);
+ while (count-- > 0) {
+ i += 1;
+ if (i >= a.length)
+ i = 0;
+ sb.append(' ');
+ sb.append(a[i]);
+ }
+ return sb.toString();
+ }
+
+ private String pickDigits(int digits) {
+ StringBuffer sb = new StringBuffer();
+ while (digits-- > 0)
+ sb.append(Integer.toString(pick(10)));
+ return sb.toString();
+ }
+
+ private int pickLength(SchemaType sType) {
+ XmlInteger length = (XmlInteger) sType.getFacet(SchemaType.FACET_LENGTH);
+ if (length != null)
+ return length.getBigIntegerValue().intValue();
+ XmlInteger min = (XmlInteger) sType.getFacet(SchemaType.FACET_MIN_LENGTH);
+ XmlInteger max = (XmlInteger) sType.getFacet(SchemaType.FACET_MAX_LENGTH);
+ int minInt, maxInt;
+ if (min == null)
+ minInt = 0;
+ else
+ minInt = min.getBigIntegerValue().intValue();
+ if (max == null)
+ maxInt = Integer.MAX_VALUE;
+ else
+ maxInt = max.getBigIntegerValue().intValue();
+ // We try to keep the length of the array within reasonable limits,
+ // at least 1 item and at most 3 if possible
+ if (minInt == 0 && maxInt >= 1)
+ minInt = 1;
+ if (maxInt > minInt + 2)
+ maxInt = minInt + 2;
+ if (maxInt < minInt)
+ maxInt = minInt;
+ return minInt + pick(maxInt - minInt);
+ }
+
+ /**
+ * Formats a given string to the required length, using the following operations:
+ * - append the source string to itself as necessary to pass the minLength;
+ * - truncate the result of previous step, if necessary, to keep it within minLength.
+ */
+ private String formatToLength(String s, SchemaType sType) {
+ String result = s;
+ try {
+ SimpleValue min = (SimpleValue) sType.getFacet(SchemaType.FACET_LENGTH);
+ if (min == null)
+ min = (SimpleValue) sType.getFacet(SchemaType.FACET_MIN_LENGTH);
+ if (min != null) {
+ int len = min.getIntValue();
+ while (result.length() < len)
+ result = result + result;
+ }
+ SimpleValue max = (SimpleValue) sType.getFacet(SchemaType.FACET_LENGTH);
+ if (max == null)
+ max = (SimpleValue) sType.getFacet(SchemaType.FACET_MAX_LENGTH);
+ if (max != null) {
+ int len = max.getIntValue();
+ if (result.length() > len)
+ result = result.substring(0, len);
+ }
+ } catch (Exception e) // intValue can be out of range
+ {
+ }
+ return result;
+ }
+
+ private String formatDecimal(String start, SchemaType sType) {
+ BigDecimal result = new BigDecimal(start);
+ XmlDecimal xmlD;
+ xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ BigDecimal min = xmlD != null ? xmlD.getBigDecimalValue() : null;
+ xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ BigDecimal max = xmlD != null ? xmlD.getBigDecimalValue() : null;
+ boolean minInclusive = true, maxInclusive = true;
+ xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (xmlD != null) {
+ BigDecimal minExcl = xmlD.getBigDecimalValue();
+ if (min == null || min.compareTo(minExcl) < 0) {
+ min = minExcl;
+ minInclusive = false;
+ }
+ }
+ xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (xmlD != null) {
+ BigDecimal maxExcl = xmlD.getBigDecimalValue();
+ if (max == null || max.compareTo(maxExcl) > 0) {
+ max = maxExcl;
+ maxInclusive = false;
+ }
+ }
+ xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_TOTAL_DIGITS);
+ int totalDigits = -1;
+ if (xmlD != null) {
+ totalDigits = xmlD.getBigDecimalValue().intValue();
+
+ StringBuffer sb = new StringBuffer(totalDigits);
+ for (int i = 0; i < totalDigits; i++)
+ sb.append('9');
+ BigDecimal digitsLimit = new BigDecimal(sb.toString());
+ if (max != null && max.compareTo(digitsLimit) > 0) {
+ max = digitsLimit;
+ maxInclusive = true;
+ }
+ digitsLimit = digitsLimit.negate();
+ if (min != null && min.compareTo(digitsLimit) < 0) {
+ min = digitsLimit;
+ minInclusive = true;
+ }
+ }
+
+ int sigMin = min == null ? 1 : result.compareTo(min);
+ int sigMax = max == null ? -1 : result.compareTo(max);
+ boolean minOk = sigMin > 0 || sigMin == 0 && minInclusive;
+ boolean maxOk = sigMax < 0 || sigMax == 0 && maxInclusive;
+
+ // Compute the minimum increment
+ xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_FRACTION_DIGITS);
+ int fractionDigits = -1;
+ BigDecimal increment;
+ if (xmlD == null)
+ increment = new BigDecimal(1);
+ else {
+ fractionDigits = xmlD.getBigDecimalValue().intValue();
+ if (fractionDigits > 0) {
+ StringBuffer sb = new StringBuffer("0.");
+ for (int i = 1; i < fractionDigits; i++)
+ sb.append('0');
+ sb.append('1');
+ increment = new BigDecimal(sb.toString());
+ } else
+ increment = new BigDecimal(1.0);
+ }
+
+ if (minOk && maxOk) {
+ // OK
+ } else if (minOk && !maxOk) {
+ // TOO BIG
+ if (maxInclusive)
+ result = max;
+ else
+ result = max.subtract(increment);
+ } else if (!minOk && maxOk) {
+ // TOO SMALL
+ if (minInclusive)
+ result = min;
+ else
+ result = min.add(increment);
+ } else {
+ // MIN > MAX!!
+ }
+
+ // We have the number
+ // Adjust the scale according to the totalDigits and fractionDigits
+ int digits = 0;
+ BigDecimal ONE = new BigDecimal(BigInteger.ONE);
+ for (BigDecimal n = result; n.abs().compareTo(ONE) >= 0; digits++)
+ n = n.movePointLeft(1);
+
+ if (fractionDigits > 0)
+ if (totalDigits >= 0)
+ result.setScale(Math.max(fractionDigits, totalDigits - digits));
+ else
+ result.setScale(fractionDigits);
+ else if (fractionDigits == 0)
+ result.setScale(0);
+
+ return result.toString();
+ }
+
+ private String formatDuration(SchemaType sType) {
+ XmlDuration d = (XmlDuration) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ GDuration minInclusive = null;
+ if (d != null)
+ minInclusive = d.getGDurationValue();
+
+ d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ GDuration maxInclusive = null;
+ if (d != null)
+ maxInclusive = d.getGDurationValue();
+
+ d = (XmlDuration) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ GDuration minExclusive = null;
+ if (d != null)
+ minExclusive = d.getGDurationValue();
+
+ d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ GDuration maxExclusive = null;
+ if (d != null)
+ maxExclusive = d.getGDurationValue();
+
+ GDurationBuilder gdurb = new GDurationBuilder();
+ BigInteger min, max;
+
+ gdurb.setSecond(pick(800000));
+ gdurb.setMonth(pick(20));
+
+ // Years
+ // Months
+ // Days
+ // Hours
+ // Minutes
+ // Seconds
+ // Fractions
+ if (minInclusive != null) {
+ if (gdurb.getYear() < minInclusive.getYear())
+ gdurb.setYear(minInclusive.getYear());
+ if (gdurb.getMonth() < minInclusive.getMonth())
+ gdurb.setMonth(minInclusive.getMonth());
+ if (gdurb.getDay() < minInclusive.getDay())
+ gdurb.setDay(minInclusive.getDay());
+ if (gdurb.getHour() < minInclusive.getHour())
+ gdurb.setHour(minInclusive.getHour());
+ if (gdurb.getMinute() < minInclusive.getMinute())
+ gdurb.setMinute(minInclusive.getMinute());
+ if (gdurb.getSecond() < minInclusive.getSecond())
+ gdurb.setSecond(minInclusive.getSecond());
+ if (gdurb.getFraction().compareTo(minInclusive.getFraction()) < 0)
+ gdurb.setFraction(minInclusive.getFraction());
+ }
+
+ if (maxInclusive != null) {
+ if (gdurb.getYear() > maxInclusive.getYear())
+ gdurb.setYear(maxInclusive.getYear());
+ if (gdurb.getMonth() > maxInclusive.getMonth())
+ gdurb.setMonth(maxInclusive.getMonth());
+ if (gdurb.getDay() > maxInclusive.getDay())
+ gdurb.setDay(maxInclusive.getDay());
+ if (gdurb.getHour() > maxInclusive.getHour())
+ gdurb.setHour(maxInclusive.getHour());
+ if (gdurb.getMinute() > maxInclusive.getMinute())
+ gdurb.setMinute(maxInclusive.getMinute());
+ if (gdurb.getSecond() > maxInclusive.getSecond())
+ gdurb.setSecond(maxInclusive.getSecond());
+ if (gdurb.getFraction().compareTo(maxInclusive.getFraction()) > 0)
+ gdurb.setFraction(maxInclusive.getFraction());
+ }
+
+ if (minExclusive != null) {
+ if (gdurb.getYear() <= minExclusive.getYear())
+ gdurb.setYear(minExclusive.getYear() + 1);
+ if (gdurb.getMonth() <= minExclusive.getMonth())
+ gdurb.setMonth(minExclusive.getMonth() + 1);
+ if (gdurb.getDay() <= minExclusive.getDay())
+ gdurb.setDay(minExclusive.getDay() + 1);
+ if (gdurb.getHour() <= minExclusive.getHour())
+ gdurb.setHour(minExclusive.getHour() + 1);
+ if (gdurb.getMinute() <= minExclusive.getMinute())
+ gdurb.setMinute(minExclusive.getMinute() + 1);
+ if (gdurb.getSecond() <= minExclusive.getSecond())
+ gdurb.setSecond(minExclusive.getSecond() + 1);
+ if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0)
+ gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal(0.001)));
+ }
+
+ if (maxExclusive != null) {
+ if (gdurb.getYear() > maxExclusive.getYear())
+ gdurb.setYear(maxExclusive.getYear());
+ if (gdurb.getMonth() > maxExclusive.getMonth())
+ gdurb.setMonth(maxExclusive.getMonth());
+ if (gdurb.getDay() > maxExclusive.getDay())
+ gdurb.setDay(maxExclusive.getDay());
+ if (gdurb.getHour() > maxExclusive.getHour())
+ gdurb.setHour(maxExclusive.getHour());
+ if (gdurb.getMinute() > maxExclusive.getMinute())
+ gdurb.setMinute(maxExclusive.getMinute());
+ if (gdurb.getSecond() > maxExclusive.getSecond())
+ gdurb.setSecond(maxExclusive.getSecond());
+ if (gdurb.getFraction().compareTo(maxExclusive.getFraction()) > 0)
+ gdurb.setFraction(maxExclusive.getFraction());
+ }
+
+ gdurb.normalize();
+ return gdurb.toString();
+ }
+
+ private String formatDate(SchemaType sType) {
+ GDateBuilder gdateb = new GDateBuilder(new Date(1000L * pick(365 * 24 * 60 * 60) + (30L + pick(20)) * 365 * 24 * 60 * 60 * 1000));
+ GDate min = null, max = null;
+ GDate temp;
+
+ // Find the min and the max according to the type
+ switch (sType.getPrimitiveType().getBuiltinTypeCode()) {
+ case SchemaType.BTC_DATE_TIME: {
+ XmlDateTime x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_TIME: {
+ XmlTime x = (XmlTime) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlTime) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlTime) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlTime) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_DATE: {
+ XmlDate x = (XmlDate) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlDate) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlDate) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlDate) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_G_YEAR_MONTH: {
+ XmlGYearMonth x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_G_YEAR: {
+ XmlGYear x = (XmlGYear) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlGYear) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlGYear) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlGYear) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_G_MONTH_DAY: {
+ XmlGMonthDay x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_G_DAY: {
+ XmlGDay x = (XmlGDay) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlGDay) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlGDay) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlGDay) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ case SchemaType.BTC_G_MONTH: {
+ XmlGMonth x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE);
+ if (x != null)
+ min = x.getGDateValue();
+ x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE);
+ if (x != null)
+ if (min == null || min.compareToGDate(x.getGDateValue()) <= 0)
+ min = x.getGDateValue();
+
+ x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE);
+ if (x != null)
+ max = x.getGDateValue();
+ x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
+ if (x != null)
+ if (max == null || max.compareToGDate(x.getGDateValue()) >= 0)
+ max = x.getGDateValue();
+ break;
+ }
+ }
+
+ if (min != null && max == null) {
+ if (min.compareToGDate(gdateb) >= 0) {
+ // Reset the date to min + (1-8) hours
+ Calendar c = gdateb.getCalendar();
+ c.add(Calendar.HOUR_OF_DAY, pick(8));
+ gdateb = new GDateBuilder(c);
+ }
+ } else if (min == null && max != null) {
+ if (max.compareToGDate(gdateb) <= 0) {
+ // Reset the date to max - (1-8) hours
+ Calendar c = gdateb.getCalendar();
+ c.add(Calendar.HOUR_OF_DAY, 0 - pick(8));
+ gdateb = new GDateBuilder(c);
+ }
+ } else if (min != null && max != null) {
+ if (min.compareToGDate(gdateb) >= 0 || max.compareToGDate(gdateb) <= 0) {
+ // Find a date between the two
+ Calendar c = min.getCalendar();
+ Calendar cmax = max.getCalendar();
+ c.add(Calendar.HOUR_OF_DAY, 1);
+ if (c.after(cmax)) {
+ c.add(Calendar.HOUR_OF_DAY, -1);
+ c.add(Calendar.MINUTE, 1);
+ if (c.after(cmax)) {
+ c.add(Calendar.MINUTE, -1);
+ c.add(Calendar.SECOND, 1);
+ if (c.after(cmax)) {
+ c.add(Calendar.SECOND, -1);
+ c.add(Calendar.MILLISECOND, 1);
+ if (c.after(cmax))
+ c.add(Calendar.MILLISECOND, -1);
+ }
+ }
+ }
+ gdateb = new GDateBuilder(c);
+ }
+ }
+
+ gdateb.setBuiltinTypeCode(sType.getPrimitiveType().getBuiltinTypeCode());
+ if (pick(2) == 0)
+ gdateb.clearTimeZone();
+ return gdateb.toString();
+ }
+
+ private SchemaType closestBuiltin(SchemaType sType) {
+ while (!sType.isBuiltinType())
+ sType = sType.getBaseType();
+ return sType;
+ }
+
+ /**
+ * Cracks a combined QName of the form URL:localname
+ */
+ public static QName crackQName(String qName) {
+ String ns;
+ String name;
+
+ int index = qName.lastIndexOf(':');
+ if (index >= 0) {
+ ns = qName.substring(0, index);
+ name = qName.substring(index + 1);
+ } else {
+ ns = "";
+ name = qName;
+ }
+
+ return new QName(ns, name);
+ }
+
+ /**
+ * Cursor position:
+ * Before this call:
+ * <outer><foo/>^</outer> (cursor at the ^)
+ * After this call:
+ * <<outer><foo/><bar/>som text<etc/>^</outer>
+ */
+ private void processParticle(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
+ int loop = determineMinMaxForSample(sp, xmlc);
+
+ while (loop-- > 0) {
+ switch (sp.getParticleType()) {
+ case (SchemaParticle.ELEMENT):
+ processElement(sp, xmlc, mixed);
+ break;
+ case (SchemaParticle.SEQUENCE):
+ processSequence(sp, xmlc, mixed);
+ break;
+ case (SchemaParticle.CHOICE):
+ processChoice(sp, xmlc, mixed);
+ break;
+ case (SchemaParticle.ALL):
+ processAll(sp, xmlc, mixed);
+ break;
+ case (SchemaParticle.WILDCARD):
+ processWildCard(sp, xmlc, mixed);
+ break;
+ default:
+ // throw new Exception("No Match on Schema Particle Type: " + String.valueOf(sp.getParticleType()));
+ }
+ }
+ }
+
+ private int determineMinMaxForSample(SchemaParticle sp, XmlCursor xmlc) {
+ int minOccurs = sp.getIntMinOccurs();
+ int maxOccurs = sp.getIntMaxOccurs();
+
+ if (minOccurs == maxOccurs)
+ return minOccurs;
+
+ int result = minOccurs;
+ if (result == 0 && _nElements < MAX_ELEMENTS)
+ result = 1;
+
+ if (sp.getParticleType() != SchemaParticle.ELEMENT)
+ return result;
+
+ // it probably only makes sense to put comments in front of individual elements that repeat
+
+ if (sp.getMaxOccurs() == null) {
+ // xmlc.insertComment("The next " + getItemNameOrType(sp, xmlc) + " may be repeated " + minOccurs + " or more times");
+ if (minOccurs == 0)
+ xmlc.insertComment("Zero or more repetitions:");
+ else
+ xmlc.insertComment(minOccurs + " or more repetitions:");
+ } else if (sp.getIntMaxOccurs() > 1) {
+ xmlc.insertComment(minOccurs + " to " + String.valueOf(sp.getMaxOccurs()) + " repetitions:");
+ } else {
+ xmlc.insertComment("Optional:");
+ }
+ return result;
+ }
+
+ /*
+ Return a name for the element or the particle type to use in the comment for minoccurs, max occurs
+ */
+ private String getItemNameOrType(SchemaParticle sp, XmlCursor xmlc) {
+ String elementOrTypeName = null;
+ if (sp.getParticleType() == SchemaParticle.ELEMENT) {
+ elementOrTypeName = "Element (" + sp.getName().getLocalPart() + ")";
+ } else {
+ elementOrTypeName = printParticleType(sp.getParticleType());
+ }
+ return elementOrTypeName;
+ }
+
+ private void processElement(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
+ // cast as schema local element
+ SchemaLocalElement element = (SchemaLocalElement) sp;
+ /// ^ -> <elemenname></elem>^
+ if (_soapEnc)
+ xmlc.insertElement(element.getName().getLocalPart()); // soap encoded? drop namespaces.
+ else
+ xmlc.insertElement(element.getName().getLocalPart(), element.getName().getNamespaceURI());
+ _nElements++;
+ /// -> <elem>^</elem>
+ xmlc.toPrevToken();
+ // -> <elem>stuff^</elem>
+ createSampleForType(element.getType(), xmlc);
+ // -> <elem>stuff</elem>^
+ xmlc.toNextToken();
+
+ }
+
+ private void moveToken(int numToMove, XmlCursor xmlc) {
+ for (int i = 0; i < Math.abs(numToMove); i++) {
+ if (numToMove < 0) {
+ xmlc.toPrevToken();
+ } else {
+ xmlc.toNextToken();
+ }
+ }
+ }
+
+ private static final String formatQName(XmlCursor xmlc, QName qName) {
+ XmlCursor parent = xmlc.newCursor();
+ parent.toParent();
+ String prefix = parent.prefixForNamespace(qName.getNamespaceURI());
+ parent.dispose();
+ String name;
+ if (prefix == null || prefix.length() == 0)
+ name = qName.getLocalPart();
+ else
+ name = prefix + ":" + qName.getLocalPart();
+ return name;
+ }
+
+ private static final QName HREF = new QName("href");
+
+ private static final QName ID = new QName("id");
+
+ private static final QName XSI_TYPE = new QName("http://www.w3.org/2001/XMLSchema-instance", "type");
+
+ private static final QName ENC_ARRAYTYPE = new QName("http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
+
+ private static final QName ENC_OFFSET = new QName("http://schemas.xmlsoap.org/soap/encoding/", "offset");
+
+ private static final Set SKIPPED_SOAP_ATTRS = new HashSet(Arrays.asList(new QName[] { HREF, ID, ENC_OFFSET }));
+
+ private void processAttributes(SchemaType stype, XmlCursor xmlc) {
+ if (_soapEnc) {
+ QName typeName = stype.getName();
+ if (typeName != null) {
+ xmlc.insertAttributeWithValue(XSI_TYPE, formatQName(xmlc, typeName));
+ }
+ }
+
+ SchemaProperty[] attrProps = stype.getAttributeProperties();
+ for (int i = 0; i < attrProps.length; i++) {
+ SchemaProperty attr = attrProps[i];
+ if (_soapEnc) {
+ if (SKIPPED_SOAP_ATTRS.contains(attr.getName()))
+ continue;
+ if (ENC_ARRAYTYPE.equals(attr.getName())) {
+ SOAPArrayType arrayType = ((SchemaWSDLArrayType) stype.getAttributeModel().getAttribute(attr.getName())).getWSDLArrayType();
+ if (arrayType != null)
+ xmlc.insertAttributeWithValue(attr.getName(), formatQName(xmlc, arrayType.getQName()) + arrayType.soap11DimensionString());
+ continue;
+ }
+ }
+ String defaultValue = attr.getDefaultText();
+ xmlc.insertAttributeWithValue(attr.getName(), defaultValue == null ? sampleDataForSimpleType(attr.getType()) : defaultValue);
+ }
+ }
+
+ private void processSequence(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
+ SchemaParticle[] spc = sp.getParticleChildren();
+ for (int i = 0; i < spc.length; i++) {
+ /// <parent>maybestuff^</parent>
+ processParticle(spc[i], xmlc, mixed);
+ //<parent>maybestuff...morestuff^</parent>
+ if (mixed && i < spc.length - 1) {
+ if (isGenerate_sample_data()) {
+ xmlc.insertChars(pick(WORDS));
+ } else {
+ xmlc.insertChars("");
+ }
+ }
+ }
+ }
+
+ private void processChoice(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
+ SchemaParticle[] spc = sp.getParticleChildren();
+ xmlc.insertComment("You have a CHOICE of the next " + String.valueOf(spc.length) + " items at this level");
+ for (int i = 0; i < spc.length; i++) {
+ processParticle(spc[i], xmlc, mixed);
+ }
+ }
+
+ private void processAll(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
+ SchemaParticle[] spc = sp.getParticleChildren();
+ // xmlc.insertComment("You may enter the following " + String.valueOf(spc.length) + " items in any order");
+ for (int i = 0; i < spc.length; i++) {
+ processParticle(spc[i], xmlc, mixed);
+ if (mixed && i < spc.length - 1)
+ xmlc.insertChars(pick(WORDS));
+ }
+ }
+
+ private void processWildCard(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
+ xmlc.insertComment("You may enter ANY elements at this point");
+ xmlc.insertElement("AnyElement");
+ }
+
+ /**
+ * This method will get the base type for the schema type
+ */
+
+ private static QName getClosestName(SchemaType sType) {
+ while (sType.getName() == null)
+ sType = sType.getBaseType();
+
+ return sType.getName();
+ }
+
+ private String printParticleType(int particleType) {
+ StringBuffer returnParticleType = new StringBuffer();
+ returnParticleType.append("Schema Particle Type: ");
+
+ switch (particleType) {
+ case SchemaParticle.ALL:
+ returnParticleType.append("ALL\n");
+ break;
+ case SchemaParticle.CHOICE:
+ returnParticleType.append("CHOICE\n");
+ break;
+ case SchemaParticle.ELEMENT:
+ returnParticleType.append("ELEMENT\n");
+ break;
+ case SchemaParticle.SEQUENCE:
+ returnParticleType.append("SEQUENCE\n");
+ break;
+ case SchemaParticle.WILDCARD:
+ returnParticleType.append("WILDCARD\n");
+ break;
+ default:
+ returnParticleType.append("Schema Particle Type Unknown");
+ break;
+ }
+
+ return returnParticleType.toString();
+ }
+
+ private ArrayList _typeStack = new ArrayList();
+
+ public boolean isGenerate_sample_data() {
+ return generate_sample_data;
+ }
+
+ public void setGenerate_sample_data(boolean generate_sample_data) {
+ this.generate_sample_data = generate_sample_data;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XBbasedXMLGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XBbasedXMLGenerator.java
new file mode 100644
index 0000000000..128d65cecd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XBbasedXMLGenerator.java
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.SchemaGlobalElement;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.xsd2inst.SchemaInstanceGenerator;
+import org.xml.sax.InputSource;
+
+import com.ibm.wsdl.util.xml.DOM2Writer;
+
+public class XBbasedXMLGenerator extends SchemaInstanceGenerator implements XMLGenerator {
+ private XMLfromXSDConfiguration config = null;
+
+ public static final String QNAME_SEPARATOR = "#";
+
+ public XBbasedXMLGenerator(XMLfromXSDConfiguration config) {
+ this.config = config;
+ // config.setXsdInputStream(getClass().getResource(conf).openStream());
+ }
+
+ public Hashtable<String, XmlObject> generateXmlAll() throws Exception {
+ Hashtable<String, XmlObject> xmlInstances = new Hashtable<String, XmlObject>();
+ TuscanySampleXmlUtil xmlUtil = new TuscanySampleXmlUtil();
+ xmlUtil.setGenerate_sample_data(config.isGenerateSampleData());
+ SchemaTypeSystem sts = processXSDSources();
+ SchemaType elementType = null;
+ for (SchemaGlobalElement globalElement : sts.globalElements()) {
+ elementType = getRootElementSchemaType(sts, globalElement.getName().getNamespaceURI(), globalElement.getName().getLocalPart());
+ xmlInstances.put(makeQName(globalElement.getName()), XmlObject.Factory.parse(xmlUtil.createSampleForType(elementType)));
+ }
+
+ return xmlInstances;
+ }
+
+ public String generateXMLAsString() throws Exception {
+ SchemaTypeSystem sts = processXSDSources();
+ SchemaType rootElementType = getRootElementSchemaType(sts, config.getSchemaTypeNamespaceURI(), config.getSchemaTypeName());
+ String result = "";
+ if (rootElementType != null) {
+ TuscanySampleXmlUtil xmlUtil = new TuscanySampleXmlUtil();
+ xmlUtil.setGenerate_sample_data(config.isGenerateSampleData());
+ result = xmlUtil.createSampleForType(rootElementType);
+ } else {
+ System.out.println("Could not find a global element with name \"" + config.getRootElementLocalName() + "\"");
+ }
+ return result;
+ }
+
+ public void generateXMLIntoOutputStream() throws Exception {
+ config.getXmlOutputStream().write(generateXMLAsString().getBytes());
+ }
+
+ public void generateXML() throws Exception {
+ SchemaTypeSystem sts = processXSDSources();
+
+ SchemaType rootElementType = getRootElementSchemaType(sts, config.getSchemaTypeNamespaceURI(), config.getSchemaTypeName());
+
+ if (rootElementType != null) {
+ TuscanySampleXmlUtil xmlUtil = new TuscanySampleXmlUtil();
+ xmlUtil.setGenerate_sample_data(config.isGenerateSampleData());
+ String result = xmlUtil.createSampleForType(rootElementType);
+ config.getXmlOutputStream().write(result.getBytes());
+ // System.out.println(result);
+ } else {
+ System.out.println("Could not find a global element with name \"" + config.getRootElementLocalName() + "\"");
+ }
+ }
+
+ protected SchemaType getRootElementSchemaType(SchemaTypeSystem sts, String schemaNamespace, String schemaTypeName) {
+ SchemaType schemaType = null;
+
+ if (sts == null) {
+ System.out.println("No Schemas to process.");
+ } else {
+ // first check in the global types
+ SchemaType[] globalTypes = sts.globalTypes();
+ for (int i = 0; i < globalTypes.length; i++) {
+ if (schemaNamespace.equals(globalTypes[i].getName().getNamespaceURI())
+ && schemaTypeName.equals(globalTypes[i].getName().getLocalPart())) {
+ schemaType = globalTypes[i];
+ break;
+ }
+ }
+
+ // next check for anonymous types defined inline within elements
+ if (schemaType == null) {
+ SchemaType[] globalElems = sts.documentTypes();
+ for (int i = 0; i < globalElems.length; i++) {
+ if (schemaNamespace.equals(globalElems[i].getDocumentElementName().getNamespaceURI())
+ && schemaTypeName.equals(globalElems[i].getDocumentElementName().getLocalPart())) {
+ schemaType = globalElems[i];
+ break;
+ }
+ }
+ }
+ }
+ return schemaType;
+ }
+
+ public void generateXML(XMLfromXSDConfiguration config) throws Exception {
+ this.config = config;
+ generateXML();
+ }
+
+ public XMLfromXSDConfiguration getConfig() {
+ return config;
+ }
+
+ public void setConfig(XMLfromXSDConfiguration config) {
+ this.config = config;
+ }
+
+ private Definition readInTheWSDLFile(InputStream wsdlStream) throws WSDLException {
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ reader.setFeature("javax.wsdl.importDocuments", true);
+
+ /*
+ * File file = new File(uri); String baseURI;
+ *
+ * if (uri.startsWith("http://")){ baseURI = uri; } else{ if(file.getParentFile() == null){ try { baseURI = new
+ * File(".").getCanonicalFile().toURI().toString(); } catch (IOException e) { throw new RuntimeException(e); } } else { baseURI =
+ * file.getParentFile().toURI().toString(); } }
+ */
+ // Document doc;
+ InputSource inputSource;
+ try {
+
+ // doc = XMLUtils.newDocument(wsdlStream);
+ inputSource = new InputSource(wsdlStream);
+ /*
+ * } catch (ParserConfigurationException e) { throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Error", e); }
+ * catch (SAXException e) { throw new WSDLException(WSDLException.PARSER_ERROR, "Parser SAX Error", e);
+ */
+ } catch (Exception e) {
+ throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
+ }
+
+ // return reader.readWSDL(config.getRootElementNamespaceURI(), doc);
+ return reader.readWSDL(config.getRootElementNamespaceURI(), inputSource);
+ }
+
+ protected InputStream[] getXSDsFromWSDL(InputStream xsdInputStream) throws Exception {
+ Definition defn = readInTheWSDLFile(xsdInputStream);
+ List list = defn.getTypes().getExtensibilityElements();
+
+ InputStream[] xsdFragments = new InputStream[list.size()];
+
+ Iterator iterator = list.iterator();
+ Schema schemaElement = null;
+
+ for (int count = 0; count < list.size(); ++count) {
+ schemaElement = (Schema) iterator.next();
+ // System.out.println(" *** - " + element.getElementType().getNamespaceURI());
+ // System.out.println(" **** - " + element + " & " + element.getClass().getPackage().getName());
+ // System.out.println(DOM2Writer.nodeToString(element.getElement()));
+ xsdFragments[count] = new ByteArrayInputStream(DOM2Writer.nodeToString(schemaElement.getElement()).getBytes());
+ }
+
+ return xsdFragments;
+ }
+
+ protected SchemaTypeSystem processXSDSources() throws Exception {
+ SchemaTypeSystem sts = null;
+ if (config.getXsdFileName().endsWith(XSD_FILE)) {
+ sts = processXSDs(new InputStream[] { config.getXsdInputStream() });
+ } else if (config.getXsdFileName().endsWith(WSDL_FILE)) {
+ sts = processXSDs(getXSDsFromWSDL(config.getXsdInputStream()));
+ }
+ return sts;
+ }
+
+ protected SchemaTypeSystem processXSDs(InputStream[] inputStreams) {
+ List sdocs = new ArrayList();
+ for (int i = 0; i < inputStreams.length; i++) {
+ try {
+ sdocs.add(XmlObject.Factory.parse(inputStreams[i], (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest()));
+ } catch (Exception e) {
+ System.err.println("Can not load schema file: " + inputStreams[i] + ": ");
+ e.printStackTrace();
+ }
+ }
+
+ XmlObject[] schemas = (XmlObject[]) sdocs.toArray(new XmlObject[sdocs.size()]);
+
+ SchemaTypeSystem sts = null;
+ if (schemas.length > 0) {
+ Collection errors = new ArrayList();
+ XmlOptions compileOptions = new XmlOptions();
+ /*
+ * if (dl) compileOptions.setCompileDownloadUrls(); if (nopvr) compileOptions.setCompileNoPvrRule(); if (noupa)
+ * compileOptions.setCompileNoUpaRule();
+ */
+ try {
+ sts = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), compileOptions);
+ } catch (Exception e) {
+ if (errors.isEmpty() || !(e instanceof XmlException))
+ e.printStackTrace();
+
+ System.out.println("Schema compilation errors: ");
+ for (Iterator i = errors.iterator(); i.hasNext();)
+ System.out.println(i.next());
+ }
+ }
+
+ return sts;
+ }
+
+ private String makeQName(String nameSpace, String localName) {
+ return nameSpace + QNAME_SEPARATOR + localName;
+ }
+
+ private String makeQName(QName qName) {
+ return qName.getNamespaceURI() + QNAME_SEPARATOR + qName.getLocalPart();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGenerator.java
new file mode 100644
index 0000000000..15848158e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGenerator.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import java.util.Hashtable;
+
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * This is the XMLGenerator Interface that will be implemented by various
+ * types of Generators (SDO based, XMLBeans based etc.)
+ *
+ */
+public interface XMLGenerator {
+ public static final int SDO_BASED = 1;
+
+ public static final int XMLBEANS_BASED = 2;
+
+ public static final String XSD_FILE = ".xsd";
+
+ public static final String WSDL_FILE = ".wsdl";
+
+ public void generateXML() throws Exception;
+
+ public void generateXML(XMLfromXSDConfiguration config) throws Exception;
+
+ public void generateXMLIntoOutputStream() throws Exception;
+
+ public String generateXMLAsString() throws Exception;
+
+ public Hashtable<String, XmlObject> generateXmlAll() throws Exception;
+
+ public XMLfromXSDConfiguration getConfig();
+
+ public void setConfig(XMLfromXSDConfiguration config);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGeneratorFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGeneratorFactory.java
new file mode 100644
index 0000000000..e4075557e8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLGeneratorFactory.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+/**
+ * This is a factory for creating XML Generators. The types of XML Generators
+ * are enumerated in the XMLGenerator interface.
+ *
+ */
+public class XMLGeneratorFactory {
+ private static XMLGeneratorFactory factory = null;
+
+ protected XMLGeneratorFactory() {
+
+ }
+
+ public static XMLGeneratorFactory getInstance() {
+ if (factory == null) {
+ factory = new XMLGeneratorFactory();
+ }
+ return factory;
+ }
+
+ public XMLGenerator createGenerator(int generatorType) {
+ XMLGenerator generator = null;
+ switch (generatorType) {
+ case XMLGenerator.SDO_BASED: {
+ // generator = new SDObasedXMLGenerator(new XMLfromXSDConfiguration());
+ break;
+ }
+ case XMLGenerator.XMLBEANS_BASED: {
+ generator = new XBbasedXMLGenerator(new XMLfromXSDConfiguration());
+ break;
+ }
+ }
+
+ return generator;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDConfiguration.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDConfiguration.java
new file mode 100644
index 0000000000..76f6b711bd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDConfiguration.java
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+/**
+ * This class encapsulates the configuration settings for the "XML From XSD" generation.
+ * Presently it contains settings like the XSD to be use, the schematype for which and
+ * xml instance is to be created, the destination for the output etc. All of these
+ * settings are used by the 'generator' classes during the genation of the xml instance.
+ *
+ */
+public class XMLfromXSDConfiguration implements CmdLineArgsHandler {
+ private static int fileCount = 0;
+
+ public static final String DEFAULT_XML_OUTPUT_FILENAME = "XML_FROM_XSD_" + (++fileCount) + ".xml";
+
+ public static final String XSD_FILE_URL_OPTION = "xsd";
+
+ public static final String XML_OUTPUT_LOCATION_OPTION = "o";
+
+ public static final String XML_OUTPUT_FILENAME_OPTION = "of";
+
+ public static final String ROOT_ELEMENT_NAMESPACE_URI_OPTION = "rns";
+
+ public static final String ROOT_ELEMENT_LOCALNAME_OPTION = "rn";
+
+ public static final String SCHEMA_TYPE_NAME = "st";
+
+ public static final String SCHEMA_TYPE_NAMESPACE_URI = "stn";
+
+ public static final String GENERATE_SAMPLE_DATA = "sd";
+
+ protected String xmlOutputLocation = null;
+
+ protected File xmlOutputDirectory = null;
+
+ protected String xsdFileName = null;
+
+ protected String xmlFileName = null;
+
+ protected InputStream xsdInputStream = null;
+
+ protected OutputStream xmlOutputStream = null;
+
+ protected String rootElementNamespaceURI = null;
+
+ protected String rootElementLocalName = null;
+
+ protected String schemaTypeName = null;
+
+ protected String schemaTypeNamespaceURI = null;
+
+ protected boolean generateSampleData = false;
+
+ private void handleXSDInputFileOption(String xsdFileUrl) throws Exception {
+ xsdFileName = xsdFileUrl;
+ // xsdInputStream = new FileInputStream(new File(xsdFileName));
+ URL resourceUrl = Thread.currentThread().getContextClassLoader().getResource(xsdFileName);
+ if (resourceUrl != null) {
+ xsdInputStream = resourceUrl.openStream();
+ } else {
+ File inFile = new File(xsdFileName);
+ xsdFileName = inFile.getName();
+ xsdInputStream = new FileInputStream(inFile);
+ }
+ }
+
+ private void handleXMLOutputLocationOption(String outputLocation) throws Exception {
+ xmlOutputLocation = outputLocation;
+ xmlOutputDirectory = new File(xmlOutputLocation);
+ if (!xmlOutputDirectory.exists()) {
+ xmlOutputDirectory.mkdirs();
+ } else if (!xmlOutputDirectory.isDirectory()) {
+ throw new IllegalArgumentException("The input location for the xml output " + outputLocation + "is not a folder");
+ }
+ }
+
+ private void handleOutputFilenameOption(String outputFileName) throws Exception {
+ xmlFileName = outputFileName;
+
+ // first create a file in the given location
+ File outputFile = new File(xmlOutputDirectory, xmlFileName);
+
+ try {
+ if (!outputFile.exists()) {
+ outputFile.createNewFile();
+ }
+ xmlOutputStream = new FileOutputStream(outputFile);
+ } catch (IOException e) {
+ throw new Exception(e);
+ }
+ }
+
+ public void handleArgument(String optionFlag, String argValue) throws IllegalArgumentException {
+ try {
+ if (XSD_FILE_URL_OPTION.equalsIgnoreCase(optionFlag)) {
+ handleXSDInputFileOption(argValue);
+ } else if (XML_OUTPUT_LOCATION_OPTION.equalsIgnoreCase(optionFlag)) {
+ handleXMLOutputLocationOption(argValue);
+ } else if (XML_OUTPUT_FILENAME_OPTION.equalsIgnoreCase(optionFlag)) {
+ handleOutputFilenameOption(argValue);
+ } else if (ROOT_ELEMENT_NAMESPACE_URI_OPTION.equalsIgnoreCase(optionFlag)) {
+ setRootElementNamespaceURI(argValue);
+ } else if (ROOT_ELEMENT_LOCALNAME_OPTION.equalsIgnoreCase(optionFlag)) {
+ setRootElementLocalName(argValue);
+ } else if (SCHEMA_TYPE_NAME.equalsIgnoreCase(optionFlag)) {
+ setSchemaTypeName(argValue);
+ } else if (SCHEMA_TYPE_NAMESPACE_URI.equalsIgnoreCase(optionFlag)) {
+ setSchemaTypeNamespaceURI(argValue);
+ } else if (GENERATE_SAMPLE_DATA.equalsIgnoreCase(optionFlag)) {
+ setGenerateSampleData(true);
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Exception due to - " + e);
+ }
+ }
+
+ public String getRootElementLocalName() {
+ if (rootElementLocalName == null) {
+ rootElementLocalName = schemaTypeName.toLowerCase();
+ }
+ return rootElementLocalName;
+ }
+
+ public void setRootElementLocalName(String rootElementLocalName) {
+ this.rootElementLocalName = rootElementLocalName;
+ }
+
+ public String getRootElementNamespaceURI() {
+ if (rootElementNamespaceURI == null) {
+ rootElementNamespaceURI = schemaTypeNamespaceURI;
+ }
+ return rootElementNamespaceURI;
+ }
+
+ public void setRootElementNamespaceURI(String rootElementNamespaceURI) {
+ this.rootElementNamespaceURI = rootElementNamespaceURI;
+ }
+
+ public String getXmlFileName() {
+ if (xmlFileName == null) {
+ xmlFileName = getXsdFileName() + ".xml";
+ }
+ return xmlFileName;
+ }
+
+ public void setXmlFileName(String xmlFileName) {
+ this.xmlFileName = xmlFileName;
+ }
+
+ public File getXmlOutputLocation() {
+ return xmlOutputDirectory;
+ }
+
+ public void setXmlOutputLocation(File xmlOutputLocation) {
+ this.xmlOutputDirectory = xmlOutputLocation;
+ }
+
+ public OutputStream getXmlOutputStream() throws Exception {
+ if (xmlOutputStream == null) {
+ if (xmlOutputDirectory == null) {
+ handleXMLOutputLocationOption(System.getProperty("user.dir"));
+ }
+ handleOutputFilenameOption(getXmlFileName());
+ }
+ return xmlOutputStream;
+ }
+
+ public void setXmlOutputStream(OutputStream xmlOutputStream) {
+ this.xmlOutputStream = xmlOutputStream;
+ }
+
+ public String getXsdFileName() {
+ return xsdFileName;
+ }
+
+ public void setXsdFileName(String xsdFileName) throws Exception {
+ this.xsdFileName = xsdFileName;
+ handleXSDInputFileOption(xsdFileName);
+ }
+
+ public InputStream getXsdInputStream() throws Exception {
+ if (xsdInputStream == null) {
+ throw new IllegalArgumentException("XSD Input Source not set....!");
+ }
+ return xsdInputStream;
+ }
+
+ public void setXsdInputStream(InputStream xsdInputStream) {
+ this.xsdInputStream = xsdInputStream;
+ }
+
+ public String getSchemaTypeName() {
+ return schemaTypeName;
+ }
+
+ public void setSchemaTypeName(String schemaTypeName) {
+ this.schemaTypeName = schemaTypeName;
+ }
+
+ public String getSchemaTypeNamespaceURI() {
+ return schemaTypeNamespaceURI;
+ }
+
+ public void setSchemaTypeNamespaceURI(String schemaTypeNamespaceURI) {
+ this.schemaTypeNamespaceURI = schemaTypeNamespaceURI;
+ }
+
+ public void setXmlOutputLocation(String xmlOutputLocation) throws Exception {
+ this.xmlOutputLocation = xmlOutputLocation;
+ handleXMLOutputLocationOption(xmlOutputLocation);
+ }
+
+ public boolean isGenerateSampleData() {
+ return generateSampleData;
+ }
+
+ public void setGenerateSampleData(boolean generateSampleData) {
+ this.generateSampleData = generateSampleData;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGenerator.java
new file mode 100644
index 0000000000..357d4203fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGenerator.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+/**
+ * This class provides a command line tooling functinality for creating an XML
+ * instance from an input XSD.
+ */
+public class XMLfromXSDGenerator {
+ public static int generatorType = XMLGenerator.XMLBEANS_BASED;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ try {
+ new XMLfromXSDGenerator().generateXMLInstance(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println(getPrintUsageMessage());
+ }
+ }
+
+ public void generateXMLInstance(String args[]) throws Exception {
+ // create a configuration object to hold settings for this generation
+ XMLfromXSDConfiguration config = new XMLfromXSDConfiguration();
+
+ // create an argument processor to process the input arguments
+ CmdLineArgsProcessor argsProcessor = new CmdLineArgsProcessor();
+
+ // configure the args processor with the 'config' object that must be populated
+ // with values from the proecessed input arguments
+ argsProcessor.setArgsHandler(config);
+
+ // set the usage message to be output by the args processor if input arguments are not proper
+ argsProcessor.setPrintUsageMessage(getPrintUsageMessage());
+
+ // start processing the arguments
+ argsProcessor.processArgs(args);
+
+ // now that the configuration settings are populated from the input arguments
+ // instantiate the xmlfromsdogenerator with this config object
+
+ XMLGenerator generator = new XMLGeneratorFactory().createGenerator(generatorType);
+ // XBbasedXMLGenerator generator = new XBbasedXMLGenerator(config);
+
+ // generate the xml instance
+ generator.generateXML(config);
+ }
+
+ protected static String getPrintUsageMessage() {
+ StringBuffer strBuffer = new StringBuffer();
+ strBuffer.append("Usage arguments:\n");
+ strBuffer.append(" [ -rns <root element namespace URI> ]\n");
+ strBuffer.append(" [ -rn <root element name> ]\n");
+ strBuffer.append(" [ -xsd <xsd file> ]\n");
+ strBuffer.append(" [ -of <output xml filename> ]\n");
+ strBuffer.append(" [ -o <output location> ]\n");
+ strBuffer.append(" [ -st <name of the schema type to be instantiated as xml> ]\n");
+ strBuffer.append(" [ -stn <namespace URI of the schema type> ]\n");
+ strBuffer.append(" [ -sd (provide this flag if sample data is to be generated)\n");
+
+ return strBuffer.toString();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceCreationException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceCreationException.java
new file mode 100644
index 0000000000..140d3efdb4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceCreationException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+/**
+ * The Exception wrapper class for encasulating exceptions that occur during xml instance creation
+ *
+ */
+public class XmlInstanceCreationException extends Exception {
+
+ public XmlInstanceCreationException(String message) {
+ super(message);
+ }
+
+ public XmlInstanceCreationException(Exception e) {
+ super(e);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistry.java
new file mode 100644
index 0000000000..15f0fcfb73
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistry.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import java.util.Map;
+
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * Interface for system registry of xml instances
+ *
+ */
+public interface XmlInstanceRegistry {
+ public Map<String, XmlObject> getXmlInstance(String wsdlPath) throws XmlInstanceCreationException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistryImpl.java
new file mode 100644
index 0000000000..73b7232eae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XmlInstanceRegistryImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.xmlbeans.XmlObject;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation for the XMLInstnaceRegistry
+ *
+ */
+@Scope("MODULE")
+public class XmlInstanceRegistryImpl implements XmlInstanceRegistry {
+
+ private Hashtable<String, Map<String, XmlObject>> wsdlXmlInstances;
+
+ private XMLGenerator xmlGenerator;
+
+ public XmlInstanceRegistryImpl() {
+ wsdlXmlInstances = new Hashtable<String, Map<String, XmlObject>>();
+
+ XMLfromXSDConfiguration generationConfig = new XMLfromXSDConfiguration();
+ xmlGenerator = XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED);
+ xmlGenerator.setConfig(generationConfig);
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.container.javascript.XmlInstanceRegistry#getXmlInstance(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public Map<String, XmlObject> getXmlInstance(String wsdlPath) throws XmlInstanceCreationException {
+ Map<String, XmlObject> xmlInstanceMap = null;
+ if ((xmlInstanceMap = wsdlXmlInstances.get(wsdlPath)) == null) {
+ try {
+ xmlGenerator.getConfig().setXsdFileName(wsdlPath);
+ xmlInstanceMap = xmlGenerator.generateXmlAll();
+ wsdlXmlInstances.put(wsdlPath, xmlInstanceMap);
+ } catch (Exception e) {
+ throw new XmlInstanceCreationException(e);
+ }
+ }
+ return xmlInstanceMap;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..beb51e4c82
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ JavaScript configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="org.apache.tuscany.launcher.JavaScriptImplementation">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.containers</group>
+ <name>javascript</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="javascript.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="javascript.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.JavaScriptComponentTypeLoader"/>
+ </component>
+
+ <component name="javascript.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.JavaScriptComponentBuilder"/>
+ </component>
+
+ <!-- Xml Instance Registry service -->
+ <component name="xmlInstRegistry">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.utils.xmlfromxsd.XmlInstanceRegistryImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/js.system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/js.system.scdl
new file mode 100644
index 0000000000..914c53c10c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/main/resources/META-INF/sca/js.system.scdl
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ JavaScript configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="org.apache.tuscany.launcher.JavaScriptImplementation">
+
+ <component name="javascript.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="javascript.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.JavaScriptComponentTypeLoader"/>
+ </component>
+
+ <component name="javascript.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.JavaScriptComponentBuilder"/>
+ </component>
+
+ <!-- Xml Instance Registry service -->
+ <component name="xmlInstRegistry">
+ <system:implementation.system class="org.apache.tuscany.container.javascript.utils.xmlfromxsd.XmlInstanceRegistryImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..e0b1ab2303
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.apache.axiom.om.OMElement;
+
+public interface HelloWorldService {
+
+ String sayHello(String s);
+ OMElement sayE4XHello(OMElement xmlObject);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..ac17e29eb0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ public OMElement sayE4XHello(OMElement xmlObject) {
+
+ String helloString = "<hel:getGreetingsResponse xmlns:hel=\"http://helloworld\">"
+ + "<hel:getGreetingsReturn>Hello from Java Implementation to </hel:getGreetingsReturn>NoString</hel:getGreetingsResponse>";
+
+ try {
+ String inputValue = xmlObject.getFirstElement().getText();
+
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(helloString.getBytes()));
+
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader);
+ OMElement response = staxOMBuilder.getDocumentElement();
+ response.getFirstElement().setText(response.getFirstElement().getText() + inputValue);
+
+ return response;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public String sayHello(String s) {
+ return "Hello " + s;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..b7f081bb70
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+/**
+ * Tests for JavaScriptImplementationLoader
+ */
+public class JavaScriptImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private JavaScriptImplementationLoader loader;
+
+ public void testNoScriptAttribute() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn(null);
+ replay(reader);
+ replay(deploymentContext);
+
+ try {
+ loader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ // ok
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.groovy");
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ JavaScriptImplementationLoader mockLoader = new JavaScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.groovy", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.groovy", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadScript() throws LoaderException {
+ String script =
+ loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/javascript/mock/test.js");
+ assertEquals("//Test Script", script);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new JavaScriptImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java
new file mode 100644
index 0000000000..7287d7833f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.javascript.mock.Greeting;
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.spi.wire.WireService;
+import org.apache.tuscany.test.ArtifactFactory;
+
+/**
+ * Tests for component properties
+ */
+public class PropertyTestCase extends TestCase {
+
+ private static final String SCRIPT = "function greet(name){ return property; }";
+
+ private RhinoScript implClass;
+
+ /**
+ * Tests injecting a simple property type on a Javascript implementation instance
+ */
+ public void testPropertyInjection() throws Exception {
+ /*ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put("property", "bar");
+ WireService wireService = ArtifactFactory.createWireService();
+ JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", implClass, services, properties, null, scope, wireService, null);
+ scope.register(context);
+ Greeting greeting = context.getServiceInstance();
+ assertEquals("bar", greeting.greet("foo"));
+ scope.stop();*/
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ implClass = new RhinoScript("test", SCRIPT);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java
new file mode 100644
index 0000000000..3a51a8f619
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import helloworld.HelloWorldService;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.javascript.rhino.RhinoSCAConfig;
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl;
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl;
+
+public class RhinoScriptIntrospectorTestCase extends TestCase {
+
+ private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() {
+ public void readingWSDL(String namespace, URL location) {
+ }
+
+ public void cachingDefinition(String namespace, URL location) {
+ }
+ };
+
+ public void testJavaInterface() throws MissingResourceException, InvalidServiceContractException {
+ RhinoScript rs =
+ new RhinoScript("javaInterfaceTest", "SCA = { javaInterface : 'helloworld.HelloWorldService',};",
+ null, getClass().getClassLoader());
+ RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope());
+ JavaScriptIntrospector introspector =
+ new JavaScriptIntrospector(null, new JavaInterfaceProcessorRegistryImpl());
+ ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader());
+ assertNotNull(comonentType);
+ Map services = comonentType.getServices();
+ assertEquals(1, services.size());
+ ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next();
+ ServiceContract serviceContract = serviceDefinition.getServiceContract();
+ assertTrue(serviceContract instanceof JavaServiceContract);
+ JavaServiceContract javaServiceContract = (JavaServiceContract) serviceContract;
+ assertEquals(HelloWorldService.class, javaServiceContract.getInterfaceClass());
+ }
+
+ public void testWSDLLocation() throws WSDLException {
+// RhinoScript rs = new RhinoScript("wsdlLocation",
+// "SCA = { wsdlLocation : 'src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl',};", null, getClass()
+// .getClassLoader());
+// RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope());
+// JavaScriptIntrospector introspector = new JavaScriptIntrospector(null);
+// ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader());
+// assertNotNull(comonentType);
+// Map services = comonentType.getServices();
+// assertEquals(1, services.size());
+// ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next();
+// ServiceContract serviceContract = serviceDefinition.getServiceContract();
+// assertTrue(serviceContract instanceof WSDLServiceContract);
+// WSDLServiceContract wsdlServiceContract = (WSDLServiceContract) serviceContract;
+// assertEquals(new QName("http://helloworld", "HelloWorld"), wsdlServiceContract.getPortType().getQName());
+ }
+
+ public void testWSDLPortType() throws WSDLException, IOException, MissingResourceException,
+ InvalidServiceContractException {
+ RhinoScript rs = new RhinoScript("wsdlPortType",
+ "SCA = { wsdlPortType : 'HelloWorld', wsdlNamespace : 'http://helloworld',};", null,
+ getClass().getClassLoader());
+ RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope());
+
+ WSDLDefinitionRegistryImpl wsdlReg = new WSDLDefinitionRegistryImpl();
+ wsdlReg.setSchemaRegistry(new XMLSchemaRegistryImpl());
+ wsdlReg.setMonitor(NULL_MONITOR);
+ URL wsdlURL =
+ getClass().getClassLoader().getResource("org/apache/tuscany/container/javascript/rhino/helloworld.wsdl");
+ wsdlReg.loadDefinition("http://helloworld", wsdlURL);
+
+ JavaScriptIntrospector introspector =
+ new JavaScriptIntrospector(wsdlReg, new JavaInterfaceProcessorRegistryImpl());
+ ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader());
+ assertNotNull(comonentType);
+ Map services = comonentType.getServices();
+ assertEquals(1, services.size());
+ ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next();
+ ServiceContract serviceContract = serviceDefinition.getServiceContract();
+ assertTrue(serviceContract instanceof WSDLServiceContract);
+ WSDLServiceContract wsdlServiceContract = (WSDLServiceContract) serviceContract;
+ assertEquals(new QName("http://helloworld", "HelloWorld"), wsdlServiceContract.getPortType().getQName());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java
new file mode 100644
index 0000000000..94835591df
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.javascript.mock.Greeting;
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.test.ArtifactFactory;
+
+/**
+ * Tests for invoker JavaScriptComponents
+ */
+public class ScriptInvokeTestCase extends TestCase {
+
+ private static final String SCRIPT = "function greet(name) { return name }";
+
+ private RhinoScript rhinoScript;
+
+ /**
+ * Tests the invocation of a Groovy "script" as opposed to a class
+ */
+ public void testBasicScriptInvocation() throws Exception {
+// ModuleScopeContainer scope = new ModuleScopeContainer(null);
+// scope.start();
+// List<Class<?>> services = new ArrayList<Class<?>>();
+// services.add(Greeting.class);
+// JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", rhinoScript, services, new HashMap<String, Object>(),
+// null, scope, ArtifactFactory.createWireService(), null);
+// scope.register(context);
+// Greeting object = (Greeting) context.getServiceInstance();
+// assertEquals("foo", object.greet("foo"));
+// scope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ rhinoScript = new RhinoScript("test", SCRIPT);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java
new file mode 100644
index 0000000000..8bf7f8e74a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript;
+
+import static org.easymock.EasyMock.reportMatcher;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.javascript.mock.Greeting;
+import org.apache.tuscany.container.javascript.rhino.RhinoScript;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.test.ArtifactFactory;
+import org.easymock.IArgumentMatcher;
+
+/**
+ * Tests for JavaScript component wiring
+ */
+public class WireTestCase extends TestCase {
+
+ private static final String SCRIPT =
+ " function setWire(ref){" +
+ " wire = ref;" + " }" +
+ " " +
+ " function greet(name){" +
+ " return wire.greet(name); " +
+ " }";
+
+ private static final String SCRIPT2 =
+ " function greet(name){" +
+ " return name; " +
+ " }";
+
+ private RhinoScript implClass1;
+
+ private RhinoScript implClass2;
+
+ /**
+ * Tests a basic invocation down a source wire
+ */
+ public void testReferenceWireInvocation() throws Exception {
+// ModuleScopeContainer scope = new ModuleScopeContainer(null);
+// scope.start();
+//
+// List<Class<?>> services = new ArrayList<Class<?>>();
+// services.add(Greeting.class);
+// JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", implClass1, services, properties, null, scope,
+// ArtifactFactory.createWireService(), null);
+// OutboundWire wire = ArtifactFactory.createOutboundWire("wire", Greeting.class);
+// ArtifactFactory.terminateWire(wire);
+//
+// TargetInvoker invoker = createMock(TargetInvoker.class);
+// expect(invoker.isCacheable()).andReturn(false);
+// Message response = new MessageImpl();
+// response.setBody("foo");
+// expect(invoker.invoke(eqMessage())).andReturn(response);
+// replay(invoker);
+//
+// for (OutboundInvocationChain chain : wire.getInvocationChains().values()) {
+// chain.setTargetInvoker(invoker);
+// }
+// scope.register(context);
+// context.addOutboundWire(wire);
+// Greeting greeting = context.getServiceInstance();
+// assertEquals("foo", greeting.greet("foo"));
+// verify(invoker);
+//
+// scope.stop();
+ }
+
+ // todo this could be generalized and moved to test module
+ public static Message eqMessage() {
+ reportMatcher(new IArgumentMatcher() {
+ public boolean matches(Object object) {
+ if (!(object instanceof Message)) {
+ return false;
+ }
+ final Message msg = (Message) object;
+ Object[] body = (Object[]) msg.getBody();
+ return "foo".equals(body[0]);
+ }
+
+ public void appendTo(StringBuffer stringBuffer) {
+ }
+ });
+ return null;
+ }
+
+ /**
+ * Tests a basic invocation to a target
+ */
+ public void testTargetInvocation() throws Exception {
+ ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ JavaScriptComponent context =
+ new JavaScriptComponent("source", implClass2, new HashMap<String, Object>(), services, null, scope,
+ ArtifactFactory.createWireService(), null);
+ scope.register(context);
+ Operation<Type> operation = new Operation<Type>("greet", null, null, null, false, null);
+ TargetInvoker invoker = context.createTargetInvoker(null, operation);
+ assertEquals("foo", invoker.invokeTarget(new String[]{"foo"}));
+ scope.stop();
+ }
+
+ /**
+ * Tests a basic invocation down a target wire
+ */
+ public void testTargetWireInvocation() throws Exception {
+ ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ JavaScriptComponent context =
+ new JavaScriptComponent("source", implClass2, new HashMap<String, Object>(), services, null, scope,
+ ArtifactFactory.createWireService(), null);
+ scope.register(context);
+
+ InboundWire wire = ArtifactFactory.createInboundWire("Greeting", Greeting.class);
+ ArtifactFactory.terminateWire(wire);
+ for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(context.createTargetInvoker(null, chain.getOperation()));
+ }
+ context.addInboundWire(wire);
+ Greeting greeting = (Greeting) context.getServiceInstance("Greeting");
+ assertEquals("foo", greeting.greet("foo"));
+ scope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ implClass1 = new RhinoScript("script1", SCRIPT);
+ implClass2 = new RhinoScript("script2", SCRIPT2);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java
new file mode 100644
index 0000000000..3db49618e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.function;
+
+import helloworld.HelloWorldService;
+
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends SCATestCase {
+
+ private CompositeContext context;
+
+ protected void setUp() throws Exception {
+ URL base = getClass().getResource("/META-INF/sca/js.system.scdl");
+ addExtension("JavaScriptContainer", new URL(base, "default.scdl"));
+ setApplicationSCDL(getClass().getResource("helloworld.scdl"));
+ super.setUp();
+
+ context = CurrentCompositeContext.getContext();
+ }
+
+ public void testHelloWorld() throws Exception {
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponent");
+ assertEquals(helloWorldService.sayHello("petra"), "Hello petra");
+ }
+
+ public void testIntrospectedHelloWorld() throws Exception {
+ HelloWorldService introspectableService = context.locateService(HelloWorldService.class, "IntrospectableHelloWorldComponent");
+ assertEquals(introspectableService.sayHello("petra"), "Hello petra");
+ }
+
+ public void testE4XImplInvocation() throws Exception {
+ HelloWorldService e4xHelloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponentE4X");
+ String xmlInput = "<hel:getGreetings xmlns:hel=\"http://helloworld\"> " +
+ "<hel:name>TuscanyWorld</hel:name> " +
+ "</hel:getGreetings>";
+
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(
+ new ByteArrayInputStream(xmlInput.getBytes()));
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader);
+ Object response = e4xHelloWorldService.sayE4XHello(staxOMBuilder.getDocumentElement());
+ assertNotNull(response);
+ assertTrue(response instanceof OMElement);
+ assertEquals("e4xHello TuscanyWorld", ((OMElement)response).getFirstElement().getText());
+ //System.out.println(response);
+ }
+
+ public void testE4XRefInvocation() throws Exception
+ {
+ HelloWorldService e4xHelloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponentE4X");
+
+ String initialInput = "JavaClient";
+ String jsAddition = " thro e4x reference";
+ String endSvcImplResponse = "Hello from Java Implementation to ";
+
+ Object response = e4xHelloWorldService.sayHello(initialInput);
+ assertNotNull(response);
+ assertTrue(response instanceof String);
+ assertEquals(endSvcImplResponse + initialInput + jsAddition, response.toString());
+ //System.out.println(response);
+ }
+
+ public void testHelloWorldProperty() throws Exception {
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldProperty");
+ assertEquals(helloWorldService.sayHello("petra"), "Kia ora petra");
+ System.out.println(helloWorldService.sayHello("petra"));
+ }
+
+ public void testHelloWorldPropertyDefault() throws Exception {
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldPropertyDefault");
+ assertEquals(helloWorldService.sayHello("petra"), "Hi petra");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java
new file mode 100644
index 0000000000..b823939e6c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.function;
+
+import java.net.URL;
+
+import helloworld.HelloWorldService;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class ScopeTestCase extends SCATestCase {
+
+ private CompositeContext context;
+
+ protected void setUp() throws Exception {
+ URL base = getClass().getResource("/META-INF/sca/js.system.scdl");
+ addExtension("JavaScriptContainer", new URL(base, "default.scdl"));
+ setApplicationSCDL(getClass().getResource("scopeTest.scdl"));
+ super.setUp();
+
+ context = CurrentCompositeContext.getContext();
+ }
+
+// Composite scope not implemented in core yet
+// public void testComposite() throws Exception {
+// HelloWorldService composoteScopeService = context.locateService(HelloWorldService.class, "ComposoteScopeService");
+// assertEquals("1", composoteScopeService.sayHello(""));
+// assertEquals("2", composoteScopeService.sayHello(""));
+// }
+
+ public void testStateless() throws Exception {
+ HelloWorldService statelessService = context.locateService(HelloWorldService.class, "StatelessComponent");
+ assertEquals("1", statelessService.sayHello(""));
+ // stateless gives a new instance for each request
+ assertEquals("1", statelessService.sayHello(""));
+ }
+
+// Request scope not implemented in core yet
+// public void testRequestState() throws Exception {
+// HelloWorldService requestService = context.locateService(HelloWorldService.class, "RequestComponent");
+// assertEquals("1", requestService.sayHello(""));
+// assertEquals("1", requestService.sayHello(""));
+// }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java
new file mode 100644
index 0000000000..e300f73469
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.mock;
+
+public interface Greeting {
+
+ String setWire(Greeting ref);
+
+ String greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java
new file mode 100644
index 0000000000..397501a23b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+class Foo {
+ private String s;
+
+ public Foo() {
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java
new file mode 100644
index 0000000000..dad61659f3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * Tests for the RhinoFunctionInvoker
+ */
+public class RhinoFunctionInvokerTestCase extends TestCase {
+
+ public RhinoFunctionInvokerTestCase() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testNoArgsInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(null));
+ }
+
+ public void testOneArgInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getS(s) {return s;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getS");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(new Object[] { "petra" }));
+ }
+
+ public void testMultiArgsInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function concat(x, y) {return x + y}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("concat");
+ assertNotNull(invoker);
+ assertEquals("petrasue", invoker.invoke(new Object[] { "petra", "sue" }));
+ }
+
+ public void testNoResponseInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getNull() {}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull");
+ assertNotNull(invoker);
+ assertEquals(null, invoker.invoke(new Object[0]));
+ }
+
+ public void testNullResponseInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getNull() {return null;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull");
+ assertNotNull(invoker);
+ assertEquals(null, invoker.invoke(new Object[0]));
+ }
+
+ public void testResponseTypeDefaultString() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getTrue() {return true;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertTrue(o instanceof String);
+ assertEquals("true", o);
+ }
+
+ public void testResponseTypeBoolean() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getTrue() {return true;}");
+ //rhinoScript.setResponseClass("getTrue", Boolean.class);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue", Boolean.class);
+ assertNotNull(invoker);
+ assertTrue((Boolean) invoker.invoke(new Object[0]));
+ }
+
+ public void testResponseTypeStringArray() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getAs() {var as = new Array(1);as[0]='petra';return as;}");
+ //rhinoScript.setResponseClass("getAs", new String[0].getClass());
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getAs", new String[0].getClass());
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertNotNull(o);
+ assertTrue(o.getClass().isArray());
+ assertEquals("petra", ((Object[]) o)[0]);
+ }
+
+ public void testResponseTypeBooleanArray() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getBs() {var bs = new Array(1);bs[0]=true;return bs;}");
+ rhinoScript.setResponseClass("getBs", new Boolean[0].getClass());
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getBs", new Boolean[0].getClass());
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertNotNull(o);
+ assertTrue(o.getClass().isArray());
+ assertTrue(((Boolean[]) o)[0]);
+ }
+
+ public void testRequestCustomType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getFooS(foo) {return foo.getS();}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFooS");
+ assertNotNull(invoker);
+
+ Foo foo = new Foo();
+ foo.setS("petra");
+ Object o = invoker.invoke(new Object[] { foo });
+ assertEquals(foo.getS(), o);
+ }
+
+ public void testResponseCustomType() {
+ RhinoScript rhinoScript = new RhinoScript("foo",
+ "importClass(Packages.org.apache.tuscany.container.javascript.rhino.Foo);function getFoo(s) {var foo = new Foo(); foo.setS(s);return foo;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFoo");
+ assertNotNull(invoker);
+
+ Object o = invoker.invoke(new Object[] { "petra" });
+ assertNotNull(o);
+ assertEquals("petra", ((Foo) o).getS());
+ }
+
+ public void testXMLRequest() throws XmlException, IOException {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function isXML(x) {return 'xml' == (typeof x);}");
+ //rhinoScript.setResponseClass("isXML", Boolean.class);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("isXML", Boolean.class);
+ assertNotNull(invoker);
+
+ Object xml = XmlObject.Factory.parse("<a><b/></a>");
+ assertTrue((Boolean) invoker.invoke(new Object[] { xml }));
+
+ Object notXML = "notXML";
+ assertFalse((Boolean) invoker.invoke(new Object[] { notXML }));
+ }
+
+ public void testXMLResponse() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getXML(s) {return <a> { s } </a>;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getXML");
+ assertNotNull(invoker);
+
+ Object xml = invoker.invoke(new Object[] { "petra" });
+ assertNotNull(xml);
+ assertTrue(xml instanceof OMElement);
+ assertEquals("<a>petra</a>", ((OMElement) xml).toString());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java
new file mode 100644
index 0000000000..cddaa9c46f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.model.Scope;
+
+public class RhinoSCAConfigTestCase extends TestCase {
+
+ public void testJavaInteface() {
+ RhinoScript rs = new RhinoScript("javaInterface", "SCA = { javaInterface : 'Test' }");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals("Test", scaConfig.getJavaInterface());
+ }
+
+ public void testWSDLLocation() {
+ RhinoScript rs = new RhinoScript("wsdlLocation", "SCA = { wsdlLocation : 'Test' }");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals("Test", scaConfig.getWSDLLocation());
+ }
+
+ public void testWSDLNamespace() {
+ RhinoScript rs = new RhinoScript("wsdlNamespace", "SCA = { wsdlNamespace : 'Test' }");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals("Test", scaConfig.getWSDLNamespace());
+ }
+
+ public void testWSDLPortType() {
+ RhinoScript rs = new RhinoScript("wsdlPortType", "SCA = { wsdlPortType : 'Test' }");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals("Test", scaConfig.getWSDLPortType());
+ }
+
+ public void testScopeStateless() {
+ RhinoScript rs = new RhinoScript("testScopeStateless", "SCA = { scope : 'stateless', javaInterface : 'helloworld.HelloWorldService'}");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals(Scope.STATELESS, scaConfig.getScope());
+ }
+
+ public void testScopeComposite() {
+ RhinoScript rs = new RhinoScript("testScopeComposite", "SCA = { scope : 'composite', javaInterface : 'helloworld.HelloWorldService'}");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals(Scope.MODULE, scaConfig.getScope()); // TODO
+ }
+
+ public void testScopeConversational() {
+ RhinoScript rs = new RhinoScript("testScopeConversational", "SCA = { scope : 'conversational', javaInterface : 'helloworld.HelloWorldService'}");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals(Scope.SESSION, scaConfig.getScope());
+ }
+
+ public void testScopeRequest() {
+ RhinoScript rs = new RhinoScript("testScopeRequest", "SCA = { scope : 'request', javaInterface : 'helloworld.HelloWorldService'}");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(scaConfig.hasSCAConfig());
+ assertEquals(Scope.REQUEST, scaConfig.getScope());
+ }
+
+ public void testBadScope() {
+ RhinoScript rs = new RhinoScript("testScopeStateless", "SCA = { scope : 'rubbish', javaInterface : 'helloworld.HelloWorldService'}");
+ try {
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ fail("expecting bad scope exception: " + scaConfig);
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testNoConfig() {
+ RhinoScript rs = new RhinoScript("javaInterface", "");
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ assertTrue(!scaConfig.hasSCAConfig());
+ }
+
+ public void testNoService() {
+ RhinoScript rs = new RhinoScript("javaInterface", "SCA = {}");
+ try {
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ fail("expecting no service exception: " + scaConfig);
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testDupicateInteface() {
+ RhinoScript rs = new RhinoScript("javaInterface", "SCA = { javaInterface : 'Test', wsdlLocation : 'Test' }");
+ try {
+ RhinoSCAConfig scaConfig = rs.getSCAConfig();
+ fail("expecting multiple service exception: " + scaConfig);
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java
new file mode 100644
index 0000000000..76d6c7c49d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScriptInstance
+ */
+public class RhinoScriptInstanceTestCase extends TestCase {
+
+ public RhinoScriptInstanceTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testInvokeFunction() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("petra", instance.invokeFunction("getPetra", new Object[0]));
+ }
+
+ public void testCreateRhinoFunctionInvoker() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(new Object[0]));
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java
new file mode 100644
index 0000000000..ab684c39ce
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.rhino;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class RhinoScriptTestCase extends TestCase {
+
+ public RhinoScriptTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testSimpleConstructor() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("petra", instance.invokeFunction("getPetra", new Object[0]));
+ }
+
+ public void testFullConstructor() {
+ ClassLoader cl = getClass().getClassLoader();
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("name", "petra");
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getName() {return name;}", contexts, cl);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("petra", instance.invokeFunction("getName", new Object[0]));
+ }
+
+ public void testCreateInstance() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceWithContext() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getName() {return name;}");
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("name", "petra");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(contexts);
+ assertEquals("petra", instance.invokeFunction("getName", new Object[0]));
+ }
+
+ public void testDefaultResponseType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getX() {return 42;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("42", instance.invokeFunction("getX", new Object[0]));
+ }
+
+ public void testSetResponseType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getX() {return 42;}");
+ rhinoScript.setResponseClass("getX", Integer.class);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ Object x = instance.invokeFunction("getX", new Object[0], Integer.class);
+ assertTrue(x instanceof Integer);
+ assertEquals(new Integer(42), x);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java
new file mode 100644
index 0000000000..15752bdaa1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.javascript.utils.xmlfromxsd;
+
+import junit.framework.TestCase;
+
+public class XMLfromXSDGeneratorTestCase extends TestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*public void testXMLInstance_SDO_based_1()
+ {
+ String[] arguments = new String[] { "-xsd", "sequences.xsd",
+ "-st", "MixedQuote",
+ "-stn", "http://www.example.com/sequences",
+ "-o", "target/xmlFromxsd-source",
+ "-of", "sequences_sdo.xml"
+ };
+
+ XMLfromXSDGenerator.main(arguments);
+ //File file = new File("target/java2wsdl-source/CustomerValue.wsdl");
+ //assertTrue(file.exists() && file.isFile());
+ }
+
+ public void testXMLInstance_SDO_based_2()
+ {
+ try
+ {
+ XMLfromXSDConfiguration config = new XMLfromXSDConfiguration();
+ config.setXsdFileName("interopdoc.wsdl");
+ config.setSchemaTypeName("ComplexDocument");
+ config.setSchemaTypeNamespaceURI("http://soapinterop.org/");
+ config.setXmlOutputLocation("target/xmlFromxsd-source");
+ config.setXmlFileName("interopdoc_sdo.xml");
+
+ XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.SDO_BASED).generateXML(config);
+ //XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED).generateXML(config);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testXMLInstance_SDO_based_3()
+ {
+ try
+ {
+ XMLfromXSDConfiguration config = new XMLfromXSDConfiguration();
+ config.setXsdFileName("helloworld.wsdl");
+ //config.setSchemaTypeName("getGreetings");
+ config.setSchemaTypeName("ComplexGreetings");
+ config.setSchemaTypeNamespaceURI("http://helloworldaxis.samples.tuscany.apache.org");
+ config.setXmlOutputLocation("target/xmlFromxsd-source");
+ config.setXmlFileName("helloworld_sdo.xml");
+
+ XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.SDO_BASED).generateXML(config);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }*/
+
+ public void testXMLInstance_XB_based_1() {
+ String[] arguments = new String[] { "-xsd", "src/test/resources/sequences.xsd", "-st", "mixedStockQuote", "-stn",
+ "http://www.example.com/sequences", "-o", "target/xmlFromxsd-source", "-of", "sequences_xb.xml" };
+
+ XMLfromXSDGenerator.generatorType = XMLGenerator.XMLBEANS_BASED;
+ XMLfromXSDGenerator.main(arguments);
+ /*
+ * File file = new File("target/java2wsdl-source/CustomerValue.wsdl"); assertTrue(file.exists() && file.isFile());
+ */
+ }
+
+ public void testXMLInstance_XB_based_2() {
+ try {
+ XMLfromXSDConfiguration config = new XMLfromXSDConfiguration();
+ config.setXsdFileName("interopdoc.wsdl");
+ config.setSchemaTypeName("ComplexDocument");
+ config.setSchemaTypeNamespaceURI("http://soapinterop.org/");
+ config.setXmlOutputLocation("target/xmlFromxsd-source");
+ config.setXmlFileName("interopdoc_xb.xml");
+
+ XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED).generateXML(config);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testXMLInstance_XB_based_3() {
+ try {
+ XMLfromXSDConfiguration config = new XMLfromXSDConfiguration();
+ config.setXsdFileName("org/apache/tuscany/container/javascript/rhino/helloworld.wsdl");
+ // config.setXsdFileName("helloworld.wsdl");
+ config.setSchemaTypeName("getGreetings");
+ // config.setSchemaTypeName("ComplexGreetings");
+ config.setSchemaTypeNamespaceURI("http://helloworld");
+ config.setXmlOutputLocation("target/xmlFromxsd-source");
+ config.setXmlFileName("helloworld_xb.xml");
+
+ XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED).generateXML(config);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl
new file mode 100644
index 0000000000..2a56a3c496
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/Account/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/Account/"
+ targetNamespace="http://www.bigbank.com/Account/"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/Account/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:account="http://www.bigbank.com/Account/"
+ xmlns:sdojava="commonj.sdo/java"
+ sdojava:package="org.apache.tuscany.samples.bigbank.account">
+
+ <xsd:element name="getAccountReportWrapped0">
+ <xsd:complexType>
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportWrapped0Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getAccountReportWrapped1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportWrapped1Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport" type="account:AccountReport"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getAccountReportWrappedN">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="customerID2" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportWrappedNResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport" type="account:AccountReport"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getAccountReportBare0" type="xsd:string"/>
+ <xsd:element name="getAccountReportBare0Response" type="xsd:int"/>
+
+ <xsd:element name="getAccountReportBare1Simple" type="xsd:string"/>
+ <xsd:element name="getAccountReportBare1SimpleResponse" type="xsd:int"/>
+
+ <xsd:element name="getAccountReportBare1Complex" type="account:AccountRequest"/>
+ <xsd:element name="getAccountReportBare1ComplexResponse" type="account:AccountReport"/>
+
+ <xsd:complexType name="AccountRequest">
+ <xsd:sequence>
+ <xsd:element name="customerID" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummaries" type="account:AccountSummary" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:attribute name="accountNumber" type="xsd:string"/>
+ <xsd:attribute name="accountType" type="xsd:string"/>
+ <xsd:attribute name="balance" type="xsd:float"/>
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getAccountReportWrapped0Request">
+ <wsdl:part element="account:getAccountReportWrapped0" name="getAccountReportWrapped0Request"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportWrapped0Response">
+ <wsdl:part element="account:getAccountReportWrapped0Response" name="getAccountReportWrapped0Response"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportWrapped1Request">
+ <wsdl:part element="account:getAccountReportWrapped1" name="getAccountReportWrapped1Request"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportWrapped1Response">
+ <wsdl:part element="account:getAccountReportWrapped1Response" name="getAccountReportWrapped1Response"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportWrappedNRequest">
+ <wsdl:part element="account:getAccountReportWrappedN" name="getAccountReportWrappedNRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportWrappedNResponse">
+ <wsdl:part element="account:getAccountReportWrappedNResponse" name="getAccountReportWrappedNResponse"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportBare0Request">
+ </wsdl:message>
+ <wsdl:message name="getAccountReportBare0Response">
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportBare1SimpleRequest">
+ <wsdl:part element="account:getAccountReportBare1Simple" name="getAccountReportBare1SimpleRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportBare1SimpleResponse">
+ <wsdl:part element="account:getAccountReportBare1SimpleResponse" name="getAccountReportBare1SimpleResponse"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportBare1ComplexRequest">
+ <wsdl:part element="account:getAccountReportBare1Complex" name="getAccountReportBare1ComplexRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportBare1ComplexResponse">
+ <wsdl:part element="account:getAccountReportBare1ComplexResponse" name="getAccountReportBare1ComplexResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Account_Service">
+ <wsdl:operation name="getAccountReportWrapped0">
+ <wsdl:input message="tns:getAccountReportWrapped0Request"/>
+ <wsdl:output message="tns:getAccountReportWrapped0Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrapped1">
+ <wsdl:input message="tns:getAccountReportWrapped1Request"/>
+ <wsdl:output message="tns:getAccountReportWrapped1Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrappedN">
+ <wsdl:input message="tns:getAccountReportWrappedNRequest"/>
+ <wsdl:output message="tns:getAccountReportWrappedNResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare0">
+ <wsdl:input message="tns:getAccountReportBare0Request"/>
+ <wsdl:output message="tns:getAccountReportBare0Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Simple">
+ <wsdl:input message="tns:getAccountReportBare1SimpleRequest"/>
+ <wsdl:output message="tns:getAccountReportBare1SimpleResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Complex">
+ <wsdl:input message="tns:getAccountReportBare1ComplexRequest"/>
+ <wsdl:output message="tns:getAccountReportBare1ComplexResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="AccountServiceSOAP" type="tns:Account_Service">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReportWrapped0">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportWrapped0"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrapped1">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportWrapped1"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrappedN">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportWrappedN"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare0">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportBare0"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Simple">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportBare1Simple"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Complex">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportBare1Complex"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location="http://localhost:8080/sample-account/services/AccountService"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl
new file mode 100644
index 0000000000..820c26ca34
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl
@@ -0,0 +1,180 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<definitions name="InteropTestDoc" targetNamespace="http://soapinterop.org/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+
+ <xsd:schema elementFormDefault="qualified" targetNamespace="http://soapinterop.org/" xmlns:interop="http://soapinterop.org/">
+
+ <xsd:element name="SingleTag">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SingleTag" type="interop:SingleTag"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="SingleTag"/>
+ <xsd:element name="SingleTagResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SingleTag" type="interop:SingleTag"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="SimpleDocument">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SimpleDocument" type="interop:SimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:complexType name="SimpleDocument">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:element name="SimpleDocumentResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SimpleDocument" type="interop:SimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="ComplexDocument">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="ComplexDocument" type="interop:ComplexDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:complexType name="ComplexDocument">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="simpleDoc" type="interop:ArrayOfSimpleDocument"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="child" type="interop:ChildDocument"/>
+ </xsd:sequence>
+ <xsd:attribute name="AnAttribute" type="xsd:string"/>
+ </xsd:complexType>
+ <xsd:complexType name="ArrayOfSimpleDocument">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="SimpleDocument" nillable="true" type="interop:SimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="ChildDocument">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="childSimpleDoc" type="interop:ArrayOfSimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="ComplexDocumentResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="ComplexDocument" type="interop:ComplexDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+
+ </types>
+
+ <message name="SingleTagSoapIn">
+ <part name="parameters" element="tns:SingleTag"/>
+ </message>
+ <message name="SingleTagSoapOut">
+ <part name="outputDoc" element="tns:SingleTagResponse"/>
+ </message>
+ <message name="SimpleDocumentSoapIn">
+ <part name="parameters" element="tns:SimpleDocument"/>
+ </message>
+ <message name="SimpleDocumentSoapOut">
+ <part name="outputDoc" element="tns:SimpleDocumentResponse"/>
+ </message>
+ <message name="ComplexDocumentSoapIn">
+ <part name="parameters" element="tns:ComplexDocument"/>
+ </message>
+ <message name="ComplexDocumentSoapOut">
+ <part name="outputDoc" element="tns:ComplexDocumentResponse"/>
+ </message>
+
+ <portType name="DocTestPortType">
+
+ <operation name="SingleTag">
+ <input message="tns:SingleTagSoapIn"/>
+ <output message="tns:SingleTagSoapOut"/>
+ </operation>
+ <operation name="SimpleDocument">
+ <input message="tns:SimpleDocumentSoapIn"/>
+ <output message="tns:SimpleDocumentSoapOut"/>
+ </operation>
+ <operation name="ComplexDocument">
+ <input message="tns:ComplexDocumentSoapIn"/>
+ <output message="tns:ComplexDocumentSoapOut"/>
+ </operation>
+
+ </portType>
+
+ <binding name="doc_test_binding" type="tns:DocTestPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <operation name="SingleTag">
+ <soap:operation soapAction="http://soapinterop.org/SingleTag"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+
+ <operation name="SimpleDocument">
+ <soap:operation soapAction="http://soapinterop.org/SimpleDocument"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+
+ <operation name="ComplexDocument">
+ <soap:operation soapAction="http://soapinterop.org/ComplexDocument"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="interopDocSvc">
+
+ <port name="interopDocPort" binding="tns:doc_test_binding">
+ <soap:address location="http://www.whitemesa.net/interopdoc"/>
+ </port>
+
+ </service>
+
+</definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType
new file mode 100644
index 0000000000..bd1e9445c1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js
new file mode 100644
index 0000000000..520153329e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+function sayHello(s) {
+ return "Hello " + s;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js
new file mode 100644
index 0000000000..2f6b7e0675
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+SCA = {
+ 'javaInterface' : 'helloworld.HelloWorldService'
+}
+
+function sayHello(s) {
+ return "Hello " + s;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js
new file mode 100644
index 0000000000..4684b89e66
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+SCA = {
+ scope : 'composite',
+ javaInterface : 'helloworld.HelloWorldService'
+}
+
+x = 0;
+
+function sayHello(s) {
+ x = x + 1;
+ return x;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType
new file mode 100644
index 0000000000..8f2d906f58
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+<!-- <interface.wsdl interface="http://integration.rhino.container.tuscany.apache.org#HelloWorld"/> -->
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+
+ <reference name="extHelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+
+
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js
new file mode 100644
index 0000000000..3e9c00fcb9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function sayE4XHello(xmlIn) {
+
+ var greeting = "e4xHello " + xmlIn..*::name;
+ var xmlOut = getXmlObject("http://helloworld","getGreetingsResponse");
+
+ var ns = new Namespace("http://helloworld");
+ xmlOut.ns::getGreetingsReturn = greeting;
+
+ return xmlOut;
+}
+
+
+
+ function sayHello(name) {
+ //create XML Request Object
+ var xmlIn = getXmlObject("http://helloworld","getGreetings");
+ var ns = new Namespace("http://helloworld");
+ xmlIn.ns::name = name + " thro e4x reference";
+
+ //invoke service thro service reference and obtain XML Response
+ var xmlOut = extHelloWorldService.sayE4XHello(xmlIn);
+
+ //extract the content of response XML and return as string
+ var greeting = "" + xmlOut..*::getGreetingsReturn;
+ return greeting;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl
new file mode 100644
index 0000000000..c3c4f5c669
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:js="http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2"
+
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/HelloWorld.js"/>
+ </component>
+
+ <component name="IntrospectableHelloWorldComponent">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js"/>
+ </component>
+
+ <component name="HelloWorldComponentE4X">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/e4x.js"/>
+ <reference name="extHelloWorldService" target="HelloWorldJavaReference">HelloWorldJavaReference</reference>
+ </component>
+
+ <component name="HelloWorldJavaReference">
+ <implementation.java class="helloworld.HelloWorldServiceImpl"/>
+ </component>
+
+ <component name="HelloWorldProperty">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/propertyTest.js"/>
+ <property name="GREETING">Kia ora</property>
+ </component>
+
+ <component name="HelloWorldPropertyDefault">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/propertyTest.js"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType
new file mode 100644
index 0000000000..8e46971ea3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+
+ <property name="GREETING" type="xsd:string">Hi</property>
+
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js
new file mode 100644
index 0000000000..96e21d0c75
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+function sayHello(s) {
+ return GREETING + ' ' + s;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js
new file mode 100644
index 0000000000..bf8f840b91
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+SCA = {
+ scope : 'request',
+ javaInterface : 'helloworld.HelloWorldService'
+}
+
+x = 0;
+
+function sayHello(s) {
+ x = x + 1;
+ return x;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl
new file mode 100644
index 0000000000..3754d69da1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:js="http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2"
+
+ name="HelloWorldComposite">
+
+ <component name="StatelessComponent">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/statelessScope.js"/>
+ </component>
+
+ <!-- component name="RequestComponent">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/requestScope.js"/>
+ </component -->
+
+ <!-- component name="CompositeScopeComponent">
+ <js:implementation.js script="org/apache/tuscany/container/javascript/function/compositeScope.js"/>
+ </component -->
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js
new file mode 100644
index 0000000000..21f5104859
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+SCA = {
+ scope : 'stateless',
+ javaInterface : 'helloworld.HelloWorldService'
+}
+
+x = 0;
+
+function sayHello(s) {
+ x = x + 1;
+ return x;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js
new file mode 100644
index 0000000000..ef2694b475
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js
@@ -0,0 +1 @@
+//Test Script \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl
new file mode 100644
index 0000000000..67067f044a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/sample-helloworldws/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd
new file mode 100644
index 0000000000..a565f3fa65
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:seq="http://www.example.com/sequences"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.example.com/sequences">
+
+ <xsd:element name="mixedStockQuote" type="seq:MixedQuote" />
+ <xsd:element name="rc" type="seq:RepeatingChoice" />
+ <xsd:element name="mrc" type="seq:MixedRepeatingChoice" />
+ <xsd:element name="rc2" type="seq:TwoRCs" />
+ <xsd:element name="mrc2" type="seq:TwoRCsMixed" />
+
+
+
+ <xsd:complexType mixed="true" name="MixedQuote">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string" />
+ <xsd:element name="companyName" type="xsd:string" />
+ <xsd:element name="price" type="xsd:decimal" />
+ <xsd:element name="open1" type="xsd:decimal" />
+ <xsd:element name="high" type="xsd:decimal" />
+ <xsd:element name="low" type="xsd:decimal" />
+ <xsd:element name="volume" type="xsd:double" />
+ <xsd:element name="change1" type="xsd:double" />
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
+ name="quotes" type="seq:MixedQuote" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="RepeatingChoice">
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <xsd:complexType mixed="true" name="MixedRepeatingChoice">
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="TwoRCs">
+ <xsd:sequence>
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+
+ <xsd:element name="split" type="xsd:string" />
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="y" type="xsd:string" />
+ <xsd:element name="z" type="xsd:int" />
+ </xsd:choice>
+
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType mixed="true" name="TwoRCsMixed">
+ <xsd:sequence>
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+
+ <xsd:element name="split" type="xsd:string" />
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="y" type="xsd:string" />
+ <xsd:element name="z" type="xsd:int" />
+ </xsd:choice>
+
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/pom.xml
new file mode 100644
index 0000000000..a46f757503
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>ruby</artifactId>
+ <name>Apache Tuscany Ruby Container</name>
+ <description>Apache Tuscany Ruby Container</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby</artifactId>
+ <version>0.9.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponent.java
new file mode 100644
index 0000000000..7a244b828c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponent.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.container.ruby.rubyscript.RubyScriptInstance;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * The Ruby component implementation.
+ */
+public class RubyComponent extends AtomicComponentExtension {
+
+ private final List<Class<?>> services;
+
+ private final Map<String, Object> properties;
+
+ private RubyScript rubyScript;
+
+ private String rubyClassName;
+
+ public RubyComponent(String name,
+ RubyScript rubyScript,
+ String rubyClassName,
+ List<Class<?>> services,
+ Map<String, Object> propValues,
+ CompositeComponent parent,
+ ScopeContainer scopeContainer,
+ WireService wireService,
+ WorkContext workContext) {
+ super(name, parent, scopeContainer, wireService, workContext, null, 0);
+
+ this.rubyScript = rubyScript;
+ this.rubyClassName = rubyClassName;
+ this.services = services;
+ this.scope = scopeContainer.getScope();
+ //this.properties = new HashMap<String, Object>();
+ this.properties = propValues;
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+
+ Map<String, Object> context = new HashMap<String, Object>(getProperties());
+
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ Object wireProxy = wireService.createProxy(wire);
+ //since all types that may be used in the reference interface may not be known to Rhino
+ //using the wireProxy as is will fail result in type conversion exceptions in cases where
+ //Rhino does not know enough of the tpypes used. Hence introduce a interceptor proxy,
+ //with weak typing (java.lang.Object) so that Rhino's call to the proxy succeeds. Then
+ //within this interceptor proxy perform data mediations required to correctly call the
+ //referenced service.
+ Class<?> businessInterface = wire.getServiceContract().getInterfaceClass();
+ RubyReferenceProxy interceptingProxy = new RubyReferenceProxy(businessInterface,
+ wireProxy,
+ rubyScript.getRubyEngine());
+ context.put(wire.getReferenceName(), interceptingProxy.createProxy());
+ }
+ }
+
+ Object instance = rubyScript.createScriptInstance(context, rubyClassName);
+
+ return instance;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ /*Method[] methods = operation.getServiceContract().getInterfaceClass().getMethods();
+ Method method = findMethod(operation,
+ methods);*/
+ return new RubyInvoker(operation.getName(), this, operation.getOutputType().getPhysical().getClass());
+ }
+
+ // TODO: move all the following up to AtomicComponentExtension?
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public RubyScriptInstance getTargetInstance() throws TargetException {
+ return (RubyScriptInstance) scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getServiceInstance(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getServiceInstance(String service) throws TargetException {
+ InboundWire wire = getInboundWire(service);
+ if (wire == null) {
+ TargetException e = new TargetException("ServiceDefinition not found"); // TODO better error message
+ e.setIdentifier(service);
+ throw e;
+ }
+ return wireService.createProxy(wire);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentBuilder.java
new file mode 100644
index 0000000000..bdbbd1871c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentBuilder.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Extension point for creating {@link RubyComponent}s from an assembly configuration
+ */
+public class RubyComponentBuilder extends ComponentBuilderExtension<RubyImplementation> {
+
+ protected Class<RubyImplementation> getImplementationType() {
+ return RubyImplementation.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<RubyImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ RubyImplementation implementation = componentDefinition.getImplementation();
+ RubyComponentType componentType = implementation.getComponentType();
+
+ // get list of services provided by this component
+ Collection<ServiceDefinition> collection = componentType.getServices().values();
+ List<Class<?>> services = new ArrayList<Class<?>>(collection.size());
+ for (ServiceDefinition serviceDefinition : collection) {
+ services.add(serviceDefinition.getServiceContract().getInterfaceClass());
+ }
+
+ Map<String, Object> propertyValues = new Hashtable<String, Object>();
+ Collection<PropertyValue<?>> propValueSettings = componentDefinition.getPropertyValues().values();
+ for (PropertyValue propertyValue : propValueSettings) {
+ propertyValues.put(propertyValue.getName(),
+ propertyValue.getValueFactory().getInstance());
+ }
+
+ RubyScript rubyScript = implementation.getRubyScript();
+
+ // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method?
+ ScopeContainer scopeContainer;
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ scopeContainer = deploymentContext.getModuleScope();
+ } else {
+ scopeContainer = scopeRegistry.getScopeContainer(scope);
+ }
+
+ return new RubyComponent(name,
+ rubyScript,
+ implementation.getRubyClassName(),
+ services,
+ propertyValues,
+ parent,
+ scopeContainer,
+ wireService,
+ workContext);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentType.java
new file mode 100644
index 0000000000..1b98cf86d6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentType.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+public class RubyComponentType extends
+ ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+
+ private Scope lifecycleScope = Scope.MODULE;
+
+ public RubyComponentType() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public RubyComponentType(ComponentType ct) {
+ // TODO: A bit hacky but this is so the non-Ruby .componentType side file can be used for now
+ setInitLevel(ct.getInitLevel());
+ for (Object property : ct.getProperties().values()) {
+ add((Property) property);
+ }
+ for (Object reference : ct.getReferences().values()) {
+ add((ReferenceDefinition) reference);
+ }
+ for (Object service : ct.getServices().values()) {
+ add((ServiceDefinition) service);
+ }
+ }
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentTypeLoader.java
new file mode 100644
index 0000000000..6fc5f87c68
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyComponentTypeLoader.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.net.URL;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubySCAConfig;
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ComponentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RubyComponentTypeLoader extends ComponentTypeLoaderExtension<RubyImplementation> {
+
+ private JavaInterfaceProcessorRegistry processorRegistry;
+
+ public RubyComponentTypeLoader(@Autowire
+ JavaInterfaceProcessorRegistry processorRegistry) {
+ this.processorRegistry = processorRegistry;
+ }
+
+ @Override
+ protected Class<RubyImplementation> getImplementationClass() {
+ return RubyImplementation.class;
+ }
+
+ protected RubyComponentType loadByIntrospection(CompositeComponent parent,
+ RubyImplementation implementation,
+ DeploymentContext deploymentContext) throws
+ MissingResourceException,
+ InvalidServiceContractException {
+
+ RubyScript rubyScript = implementation.getRubyScript();
+ RubySCAConfig scaConfig = rubyScript.getSCAConfig();
+ if (!scaConfig.hasSCAConfig()) {
+ throw new IllegalArgumentException(
+ "must use either .componentType side file or Ruby Global variable $SCA definition");
+ }
+
+ // FIXME this should be a system service, not instantiated here
+ RubyComponentType componentType = new RubyIntrospector(null, processorRegistry)
+ .introspectScript(scaConfig, rubyScript.getClassLoader());
+
+ return componentType;
+ }
+
+ protected String getResourceName(RubyImplementation implementation) {
+ return implementation.getRubyScript().getScriptName();
+ }
+
+ // TODO: must be possible to move all the following up in to ComponentTypeLoaderExtension
+
+ public void load(CompositeComponent parent,
+ RubyImplementation implementation,
+ DeploymentContext deploymentContext) throws LoaderException {
+
+ URL resource = implementation.getRubyScript().getClassLoader().getResource(getSideFileName(implementation));
+ RubyComponentType componentType;
+ if (resource == null) {
+ try {
+ componentType = loadByIntrospection(parent, implementation, deploymentContext);
+ } catch (InvalidServiceContractException e) {
+ throw new LoaderException("Invalid service contract", e);
+ }
+ } else {
+ componentType = loadFromSidefile(resource, deploymentContext);
+ }
+
+ implementation.setComponentType(componentType);
+
+
+ }
+
+ protected RubyComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException {
+ ComponentType ct = loaderRegistry.load(null,
+ url,
+ ComponentType.class,
+ deploymentContext);
+ RubyComponentType jsct = new RubyComponentType(ct);
+ return jsct;
+ }
+
+ private String getSideFileName(RubyImplementation implementation) {
+ String baseName = getResourceName(implementation);
+ int lastDot = baseName.lastIndexOf('.');
+ if (lastDot != -1) {
+ baseName = baseName.substring(0,
+ lastDot);
+ }
+ return baseName + ".componentType";
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementation.java
new file mode 100644
index 0000000000..6f07399d0a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementation.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a JavaScript implementation.
+ */
+public class RubyImplementation extends AtomicImplementation<RubyComponentType> {
+
+ private RubyScript rubyScript;
+
+ private String rubyClassName;
+
+ public String getRubyClassName() {
+ return rubyClassName;
+ }
+
+ public void setRubyClassName(String rubyClassName) {
+ this.rubyClassName = rubyClassName;
+ }
+
+ public RubyScript getRubyScript() {
+ return rubyScript;
+ }
+
+ public void setRubyScript(RubyScript rubyScript) {
+ this.rubyScript = rubyScript;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java
new file mode 100644
index 0000000000..322e3d84e8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling JavaScript <js:implementation.js> elements.
+ */
+public class RubyImplementationLoader extends LoaderExtension<RubyImplementation> {
+ private static final QName IMPLEMENTATION_RUBY = new QName(
+ "http://incubator.apache.org/tuscany/xmlns/container/rb/1.0-incubator-M2", "implementation.rb");
+
+ @Constructor({"registry"})
+ public RubyImplementationLoader(@Autowire
+ LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_RUBY;
+ }
+
+ public RubyImplementation load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException,
+ LoaderException {
+
+ String script = reader.getAttributeValue(null,
+ "script");
+ String rubyClassName = reader.getAttributeValue(null,"class");
+
+ if ( script == null ) {
+ throw new MissingResourceException("No script supplied");
+ }
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String source = loadSource(cl,
+ script);
+
+ LoaderUtil.skipToEndElement(reader);
+
+ RubyImplementation implementation = new RubyImplementation();
+ RubyScript rubyScript = new RubyScript(script, source, null, cl);
+ implementation.setRubyScript(rubyScript);
+ implementation.setRubyClassName(rubyClassName);
+ registry.loadComponentType(parent,
+ implementation,
+ deploymentContext);
+ return implementation;
+ }
+
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ URL url = cl.getResource(resource);
+ if (url == null) {
+ throw new MissingResourceException(resource);
+ }
+ InputStream is;
+ try {
+ is = url.openStream();
+ } catch (IOException e) {
+ MissingResourceException mre = new MissingResourceException(resource, e);
+ mre.setIdentifier(resource);
+ throw mre;
+ }
+ try {
+ Reader reader = new InputStreamReader(is, "UTF-8");
+ char[] buffer = new char[1024];
+ StringBuilder source = new StringBuilder();
+ int count;
+ while ((count = reader.read(buffer)) > 0) {
+ source.append(buffer,
+ 0,
+ count);
+ }
+ return source.toString();
+ } catch (IOException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(resource);
+ throw le;
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyIntrospector.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyIntrospector.java
new file mode 100644
index 0000000000..d5ef41d835
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyIntrospector.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubySCAConfig;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Introspects JavaScript files for SCA configuration
+ */
+public class RubyIntrospector {
+
+ private WSDLDefinitionRegistry wsdlRegistry;
+ private JavaInterfaceProcessorRegistry processorRegistry;
+
+ public RubyIntrospector(@Autowire WSDLDefinitionRegistry wsdlRegistry,
+ @Autowire JavaInterfaceProcessorRegistry processorRegistry) {
+ this.wsdlRegistry = wsdlRegistry;
+ this.processorRegistry = processorRegistry;
+ }
+
+ public RubyComponentType introspectScript(RubySCAConfig scaConfig, ClassLoader cl)
+ throws MissingResourceException, InvalidServiceContractException {
+ RubyComponentType componentType = new RubyComponentType();
+ introspectJavaInterface(componentType, cl, scaConfig.getJavaInterface());
+ introspectWSDLInterface(componentType, cl, scaConfig.getWSDLNamespace(), scaConfig.getWSDLPortType(),
+ scaConfig.getWSDLLocation());
+ introspectReferences(componentType, cl, scaConfig.getReferences());
+ introspectProperties(componentType, cl, scaConfig.getProperties());
+ introspectScope(componentType, scaConfig.getScope());
+ return componentType;
+ }
+
+ private void introspectScope(RubyComponentType componentType, Scope scope) {
+ if (scope != null) {
+ componentType.setLifecycleScope(scope);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void introspectJavaInterface(ComponentType componentType, ClassLoader cl, String serviceClass)
+ throws MissingResourceException, InvalidServiceContractException {
+ if (serviceClass != null) {
+ ServiceDefinition service = new ServiceDefinition();
+ try {
+ ServiceContract<?> sc = processorRegistry.introspect(Class.forName(serviceClass));
+ service.setServiceContract(sc);
+ componentType.add(service);
+ } catch (ClassNotFoundException e) {
+ throw new MissingResourceException("Interface not found", e);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void introspectWSDLInterface(ComponentType componentType, ClassLoader cl, String wsdlNamespace,
+ String wsdlPortType, String wsdlLocation) {
+ if (wsdlNamespace == null && wsdlPortType == null && wsdlLocation == null) {
+ return;
+ }
+
+ PortType portType = null;
+ if (wsdlLocation != null) {
+ portType = readWSDLPortType(wsdlNamespace, wsdlPortType, wsdlLocation, portType);
+ } else {
+ portType = getPortType(wsdlNamespace, wsdlPortType);
+ }
+
+ ServiceDefinition service = new ServiceDefinition();
+ WSDLServiceContract wsdlSC = new WSDLServiceContract();
+ wsdlSC.setPortType(portType);
+ service.setServiceContract(wsdlSC);
+ componentType.add(service);
+ }
+
+ private PortType readWSDLPortType(String wsdlNamespace, String wsdlPortType, String wsdlLocation,
+ PortType portType) {
+ Definition wsdlDefinition;
+ try {
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ wsdlDefinition = reader.readWSDL(wsdlLocation.toString());
+ } catch (WSDLException e) {
+ throw new RuntimeException(e);
+
+ }
+ Map portTypes = wsdlDefinition.getPortTypes();
+ for (Iterator i = portTypes.keySet().iterator(); i.hasNext();) {
+ QName portTypeQN = (QName) i.next();
+ if (wsdlNamespace != null) {
+ if (!portTypeQN.getNamespaceURI().equals(wsdlNamespace)) {
+ continue;
+ }
+ }
+ if (wsdlPortType != null) {
+ if (!portTypeQN.getLocalPart().equals(wsdlPortType)) {
+ continue;
+ }
+ }
+ if (portType != null) {
+ throw new RuntimeException("multiple matching portTypes in wsdl: " + wsdlLocation);
+ }
+ portType = (PortType) portTypes.get(portTypeQN);
+ }
+ if (portType == null) {
+ throw new RuntimeException("portType not found in wsdl: " + wsdlLocation);
+ }
+ return portType;
+ }
+
+ private PortType getPortType(String wsdlNamespace, String wsdlPortType) {
+ if (wsdlPortType == null) {
+ throw new IllegalArgumentException("must specify the wsdlPortType in script SCA config");
+ }
+ PortType portType = null;
+ if (wsdlNamespace != null) {
+ QName portTypeQN = new QName(wsdlNamespace.toString(), wsdlPortType.toString());
+ portType = wsdlRegistry.getPortType(portTypeQN);
+ if (portType == null) {
+ throw new IllegalArgumentException("no WSDL registered for portType: " + portTypeQN);
+ }
+ } else {
+ // wsdlRegistry.getPortType(wsdlPortType.toString());
+ if (portType == null) {
+ throw new IllegalArgumentException("no WSDL registered for portType:" + wsdlPortType);
+ }
+ }
+ return portType;
+ }
+
+
+ private void introspectProperties(ComponentType componentType, ClassLoader cl, Map properties) {
+ }
+
+ private void introspectReferences(ComponentType componentType, ClassLoader cl, Map references) {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInvoker.java
new file mode 100644
index 0000000000..a40f04612e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInvoker.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubyScriptInstance;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Dispatches to a JavaScript implementation instance
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class RubyInvoker extends TargetInvokerExtension {
+
+ private RubyComponent context;
+
+ private String functionName;
+
+ private Class returnType;
+
+ public RubyInvoker(String functionName, RubyComponent context, Class returnType) {
+ this.functionName = functionName;
+ this.context = context;
+ this.returnType = returnType;
+ }
+
+ /**
+ * Invokes a function on a script instance
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ RubyScriptInstance target = context.getTargetInstance();
+ return target.invokeFunction(functionName,
+ (Object[]) payload,
+ returnType);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyRefInvocInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyRefInvocInterceptor.java
new file mode 100644
index 0000000000..bf62d1fcab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyRefInvocInterceptor.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.jruby.IRuby;
+import org.jruby.RubyObject;
+import org.jruby.javasupport.JavaUtil;
+
+/**
+ * This Interceptor encasulates the data mediation required by the JavaScriptReferenceProxy. The
+ * invocation handler of this class traps the javascript reference calls, performs data mediation
+ * and calls then calls the actual referred service. This classes implementation is subject to
+ * review and change when the DataMediation infrastructure of Tuscany is ready.
+ *
+ */
+public class RubyRefInvocInterceptor implements InvocationHandler {
+ private Object actualProxy;
+
+ private Class wireInterface;
+
+ private IRuby rubyEngine;
+
+ RubyRefInvocInterceptor(Object wireProxy, Class wireIfc, IRuby rubyEng) {
+ this.actualProxy = wireProxy;
+ this.wireInterface = wireIfc;
+ this.rubyEngine = rubyEng;
+ }
+
+ public Object invoke(Object arg0, Method method, Object[] args) throws Throwable {
+ if ( method.getName().equals("hashCode"))
+ return new Integer(1);
+
+ Method invokedMethod = getInvokedMethod(method.getName());
+ Object[] tranformedArgs = new Object[args.length];
+ for (int count = 0; count < args.length; ++count) {
+ tranformedArgs[count] = fromRubyToJava(invokedMethod.getParameterTypes()[count], args[count]);
+ }
+
+ Object response = invokedMethod.invoke(actualProxy, tranformedArgs);
+ response = fromJavaToRuby(response);
+ return response;
+ }
+
+ private Method getInvokedMethod(String methodName) {
+ Method[] methods = wireInterface.getMethods();
+
+ for (int count = 0; count < methods.length; ++count) {
+ if (methods[count].getName().equals(methodName)) {
+ return methods[count];
+ }
+ }
+ throw new RuntimeException("Unable to find invocation method");
+ }
+
+ protected Object fromRubyToJava(Class reqArgType, Object rubyArg) throws Exception {
+ Object javaArg = null;
+
+ //for known cases the JRuby runtime handles the conversion before calling the Java objects
+ //so nothing to do. When it cannot convert it simply passed the instance of RubyObject
+ if ( rubyArg instanceof RubyObject ) {
+ //need to deal with this
+ } else {
+ javaArg = rubyArg;
+ }
+
+ return javaArg;
+ }
+
+ protected Object fromJavaToRuby(Object retVal) throws RuntimeException {
+ Object rubyRetVal = JavaUtil.convertJavaToRuby(rubyEngine, retVal, retVal.getClass());
+ return rubyRetVal;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyReferenceProxy.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyReferenceProxy.java
new file mode 100644
index 0000000000..4d91194484
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyReferenceProxy.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.jruby.IRuby;
+import org.jruby.RubyException;
+
+import net.sf.cglib.asm.ClassWriter;
+import net.sf.cglib.asm.CodeVisitor;
+import net.sf.cglib.asm.Constants;
+import net.sf.cglib.asm.Type;
+
+/**
+ * This is a proxy that will mediate reference calls from the JavaScript. The mediation code here will be reviewed when the DataMediation
+ * infrastructure is ready. This proxy assmes that there is no verloading of service methods on the reference interface i.e. there are no two service
+ * methods that have the same method name or operation name.
+ */
+public class RubyReferenceProxy {
+
+ private Class interfaze;
+
+ private Object wireProxy;
+
+ private IRuby rubyEngine;
+
+ public RubyReferenceProxy(Class interfaze, Object wireProxy, IRuby rubyEng) {
+ this.interfaze = interfaze;
+ this.wireProxy = wireProxy;
+ this.rubyEngine = rubyEng;
+ }
+
+ public Object createProxy() {
+ try {
+ GenericProxyClassLoader classloader = new GenericProxyClassLoader();
+ final byte[] byteCode = generateGenericInterface(interfaze);
+
+ Class genericInterface = classloader.defineClass(byteCode);
+ InvocationHandler proxyHandler = new RubyRefInvocInterceptor(wireProxy, interfaze, rubyEngine);
+ // return genericInterface.cast(Proxy.newProxyInstance(classloader, new Class[]{genericInterface}, proxyHandler));
+ return Proxy.newProxyInstance(classloader,
+ new Class[]{genericInterface},
+ proxyHandler);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static byte[] generateGenericInterface(Class serviceInterface) {
+ String interfazeName = serviceInterface.getCanonicalName();
+ ClassWriter cw = new ClassWriter(false);
+
+ cw.visit(Constants.V1_5,
+ Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE,
+ interfazeName.replace('.',
+ '/'),
+ "java/lang/Object",
+ null,
+ serviceInterface.getSimpleName() + ".java");
+
+ StringBuffer argsAndReturn = new StringBuffer("(");
+ Method[] methods = serviceInterface.getMethods();
+ for (int count = 0; count < methods.length; ++count) {
+ argsAndReturn = new StringBuffer("(");
+ Class[] paramTypes = methods[count].getParameterTypes();
+ Class returnType = methods[count].getReturnType();
+
+ for (int paramCount = 0; paramCount < paramTypes.length; ++paramCount) {
+ argsAndReturn.append(Type.getType(Object.class));
+ }
+ argsAndReturn.append(")");
+ argsAndReturn.append(Type.getType(Object.class));
+
+ Class[] exceptionTypes = methods[count].getExceptionTypes();
+ String[] exceptions = new String[exceptionTypes.length];
+ for (int excCount = 0; excCount < exceptionTypes.length; ++excCount) {
+ exceptions[excCount] = exceptionTypes[excCount].getName();
+ exceptions[excCount] = exceptions[excCount].replace('.',
+ '/');
+ }
+
+ CodeVisitor cv = cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT,
+ methods[count].getName(),
+ argsAndReturn.toString(),
+ exceptions,
+ null);
+ cw.visitEnd();
+ }
+
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+
+ private class GenericProxyClassLoader extends ClassLoader {
+ public Class defineClass(byte[] byteArray) {
+ try {
+ return defineClass(null,
+ byteArray,
+ 0,
+ byteArray.length);
+ } catch (Throwable e) {
+ return null;
+ }
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubySCAConfig.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubySCAConfig.java
new file mode 100644
index 0000000000..4d14d8a56a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubySCAConfig.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby.rubyscript;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Scope;
+import org.jruby.RubyHash;
+import org.jruby.RubyObject;
+import org.jruby.internal.runtime.GlobalVariables;
+import org.jruby.runtime.builtin.IRubyObject;
+
+/**
+ * Represents the variable defining the SCA aspects of the script
+ * <code>
+ * SCA = {
+ * javaInterface : "my.pkg.ClassName",
+ * wsdlPortType : "wsdlPortTypeName",
+ * wsdlNameSpace : "http://my.namespace.com",
+ * wsdlLocation : "\wsdl\mywsdl.txt",
+ * properties : { "foo" : ["java.lang.String", "defaultValue"],},
+ * references : {},
+ * scope : 'stateless'|'request'|'conversational'|'composite',
+ * }
+ * </code>
+ * The config must define the service with either javaInterface or wsdl. When
+ * using wsdl the three parameters are optional. If wsdlLocation is used that is the
+ * WSDL document used, and the namespace and portType parameters are only required if
+ * the WSDL definition defines multiple portTypes.
+ */
+public class RubySCAConfig {
+
+ private boolean hasSCAConfig;
+
+ private String javaInterface;
+
+ private String wsdlLocation;
+
+ private String wsdlNamespace;
+
+ private String wsdlPortType;
+
+ private Map properties;
+
+ private Map references;
+
+ private Scope scope;
+
+ public RubySCAConfig(GlobalVariables globalVariables) {
+ IRubyObject rubyObject = globalVariables.get("$SCA");
+ if (rubyObject != null && !rubyObject.isNil()) {
+ hasSCAConfig = true;
+ RubyHash scaVar = (RubyHash) rubyObject;
+ Object o = scaVar.get("javaInterface");
+ if ( o != null ) {
+ this.javaInterface = o.toString();
+ }
+ o = scaVar.get("wsdlLocation");
+ if (o != null ) {
+ this.wsdlLocation = o.toString();
+ }
+ o = scaVar.get("wsdlPortType");
+ if (o != null ) {
+ this.wsdlPortType = o.toString();
+ }
+ o = scaVar.get("wsdlNamespace");
+ if (o != null ) {
+ this.wsdlNamespace = o.toString();
+ }
+ if (javaInterface != null) {
+ if (wsdlLocation != null || wsdlPortType != null || wsdlNamespace != null) {
+ throw new IllegalArgumentException("script SCA config defines both Java and WSDL service interface");
+ }
+ } else {
+ if (wsdlLocation == null && wsdlPortType == null && wsdlNamespace == null) {
+ throw new IllegalArgumentException("script SCA config must define either Java or WSDL service interface");
+ }
+ }
+
+ this.properties = new HashMap();
+ o = scaVar.get("properties");
+ if (o != null ) {
+ // TODO parse properties
+ }
+
+ this.references = new HashMap();
+ o = scaVar.get("references");
+ if (o != null ) {
+ // TODO parse references
+ }
+
+ o = scaVar.get("scope");
+ if (o != null ) {
+ if ("stateless".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.STATELESS;
+ } else if ("request".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.REQUEST;
+ } else if ("conversational".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.SESSION; // TODO: where's CONVERSATIONAL?
+ } else if ("composite".equalsIgnoreCase(String.valueOf(o))) {
+ this.scope = Scope.MODULE; // TODO: composite = MODULE for now?
+ } else {
+ throw new IllegalArgumentException("invalid scope value: " + o);
+ }
+ }
+
+ }
+ }
+
+ public boolean hasSCAConfig() {
+ return hasSCAConfig;
+ }
+
+ public String getJavaInterface() {
+ return javaInterface;
+ }
+
+ public Map getProperties() {
+ return properties;
+ }
+
+ public Map getReferences() {
+ return references;
+ }
+
+ public String getWSDLLocation() {
+ return wsdlLocation;
+ }
+
+ public String getWSDLNamespace() {
+ return wsdlNamespace;
+ }
+
+ public String getWSDLPortType() {
+ return wsdlPortType;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScript.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScript.java
new file mode 100644
index 0000000000..87d995eabd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScript.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby.rubyscript;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+import org.jruby.IRuby;
+import org.jruby.RubyString;
+import org.jruby.javasupport.JavaEmbedUtils;
+import org.jruby.javasupport.JavaUtil;
+import org.jruby.runtime.builtin.IRubyObject;
+
+/**
+ * A RhinoScript represents a compiled JavaScript script
+ */
+public class RubyScript {
+ protected final String NEW = ".new";
+ protected final String EQUAL = "=";
+
+ protected String scriptName;
+
+ protected String script;
+
+ protected Map<String, Class> responseClasses;
+
+ protected ClassLoader classLoader;
+
+ private IRuby rubyEngine = JavaEmbedUtils.initialize(new Vector());
+
+ /**
+ * Create a new RubyScript.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ */
+ public RubyScript(String scriptName, String script) {
+ this(scriptName, script, (Map) null, null);
+ }
+
+ /**
+ * Create a new RubyScript.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ * @param context
+ * name-value pairs that are added in to the scope where the script is compiled. May be null. The value objects are made available to
+ * the script by using a variable with the name.
+ * @param classLoader
+ * the ClassLoader to be used to locate any user Java classes used in the script
+ */
+ public RubyScript(String scriptName, String script, Map context, ClassLoader classLoader) {
+ this.scriptName = scriptName;
+ this.script = script;
+ this.responseClasses = new HashMap<String, Class>();
+ this.classLoader = classLoader;
+ rubyEngine.loadScript((RubyString) JavaUtil.convertJavaToRuby(rubyEngine,
+ "MyScript.rb",
+ String.class),
+ (RubyString) JavaUtil.convertJavaToRuby(rubyEngine,
+ this.script,
+ String.class),
+ false);
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @return a IRubyObject
+ */
+public RubyScriptInstance createScriptInstance(Map<String, Object> context, String rubyClassName) {
+ if ( rubyClassName == null ) {
+ return new RubyScriptInstance(rubyEngine.evalScript(script), responseClasses);
+ }
+ else {
+ IRubyObject rubyObject = rubyEngine.evalScript(rubyClassName + NEW);
+
+ Iterator<String> keyIterator = context.keySet().iterator();
+ String key = null;
+ Object value = null;
+ while ( keyIterator.hasNext()) {
+ key = keyIterator.next();
+ value = JavaUtil.convertJavaToRuby(rubyEngine,
+ context.get(key),
+ context.get(key).getClass());
+
+ JavaEmbedUtils.invokeMethod(rubyEngine,
+ rubyObject,
+ key + EQUAL,
+ new Object[]{value}, null);
+ }
+
+ return new RubyScriptInstance(rubyObject, responseClasses);
+ }
+ }
+ public String getScript() {
+ return script;
+ }
+
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public Map<String, Class> getResponseClasses() {
+ return responseClasses;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ /**
+ * Set the Java type of a response value. JavaScript is dynamically typed so Rhino cannot always work out what the intended Java type of a
+ * response should be, for example should the statement "return 42" be a Java int, or Integer or Double etc. When Rhino can't determine the type
+ * it will default to returning a String, using this method enables overriding the Rhino default to use a specific Java type.
+ */
+ public void setResponseClass(String functionName, Class responseClasses) {
+ this.responseClasses.put(functionName,
+ responseClasses);
+ }
+
+ public RubySCAConfig getSCAConfig() {
+ return new RubySCAConfig(rubyEngine.getGlobalVariables());
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+ public IRuby getRubyEngine() {
+ return rubyEngine;
+ }
+
+ public void setRubyEngine(IRuby rubyEngine) {
+ this.rubyEngine = rubyEngine;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScriptInstance.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScriptInstance.java
new file mode 100644
index 0000000000..2d93c57fc9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyScriptInstance.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby.rubyscript;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jruby.javasupport.JavaEmbedUtils;
+import org.jruby.runtime.builtin.IRubyObject;
+
+/**
+ * An invokeable instance of a JavaScript script.
+ */
+public class RubyScriptInstance {
+
+ private IRubyObject rubyInstance;
+
+ private Map<String, Class> responseClasses;
+
+ public RubyScriptInstance(IRubyObject rubyInstance, Map<String, Class> responseClasses) {
+ this.rubyInstance = rubyInstance;
+ this.responseClasses = responseClasses;
+ if (this.responseClasses == null) {
+ this.responseClasses = new HashMap<String, Class>();
+ }
+ }
+
+ public Object invokeFunction(String functionName, Object[] args, Class returnType) {
+ Object[] rubyArgs = RubyUtils.fromJavaToRuby(rubyInstance.getRuntime(), args);
+
+ Object rubyResponse = JavaEmbedUtils.invokeMethod(rubyInstance.getRuntime(),
+ rubyInstance,
+ functionName,
+ rubyArgs,
+ returnType);
+ Object response = RubyUtils.fromRubyToJava(rubyInstance.getRuntime(),
+ returnType,
+ rubyResponse);
+ return response;
+ }
+
+
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyUtils.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyUtils.java
new file mode 100644
index 0000000000..c19f233b94
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/java/org/apache/tuscany/container/ruby/rubyscript/RubyUtils.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby.rubyscript;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.jruby.IRuby;
+import org.jruby.RubyObject;
+import org.jruby.javasupport.JavaUtil;
+
+/**
+ * @author administrator
+ *
+ */
+public class RubyUtils {
+ public static Object fromRubyToJava(IRuby rubyEngine, Class reqArgType, Object rubyArg) {
+ Object javaArg = null;
+
+ //for known cases the JRuby runtime handles the conversion before calling the Java objects
+ //so nothing to do. When it cannot convert it simply passed the instance of RubyObject
+ if ( rubyArg instanceof RubyObject ) {
+ //need to deal with this
+ } else {
+ javaArg = rubyArg;
+ }
+
+ return javaArg;
+ }
+
+ public static Object[] fromJavaToRuby(IRuby rubyEngine, Object[] arg) {
+ Object[] jsArgs;
+ if (arg == null) {
+ jsArgs = new Object[0];
+ } else {
+ jsArgs = new Object[arg.length];
+ for (int i = 0; i < jsArgs.length; i++) {
+ jsArgs[i] = fromJavaToRuby(rubyEngine, arg[i]);
+ }
+ }
+
+ return jsArgs;
+ }
+
+ public static Object fromJavaToRuby(IRuby rubyEngine, Object javaObj) {
+ Object rubyObj = JavaUtil.convertJavaToRuby(rubyEngine, javaObj, javaObj.getClass());
+ return rubyObj;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..7a329afb7a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Ruby configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="org.apache.tuscany.launcher.RubyImplementation">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.containers</group>
+ <name>ruby</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="ruby.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.ruby.RubyImplementationLoader"/>
+ </component>
+
+ <component name="ruby.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.ruby.RubyComponentTypeLoader"/>
+ </component>
+
+ <component name="ruby.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.ruby.RubyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/ruby.system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/ruby.system.scdl
new file mode 100644
index 0000000000..686e1ea308
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/main/resources/META-INF/sca/ruby.system.scdl
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Ruby configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="org.apache.tuscany.launcher.RubyImplementation">
+
+ <component name="ruby.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.ruby.RubyImplementationLoader"/>
+ </component>
+
+ <component name="ruby.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.ruby.RubyComponentTypeLoader"/>
+ </component>
+
+ <component name="ruby.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.ruby.RubyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..7e99f6f720
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldService.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+
+public interface HelloWorldService {
+ String sayHello(String s);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..be804d3540
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/helloworld/HelloWorldServiceImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Property;
+
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ @Property
+ public String greeting = "Default hello";
+
+ public String getGreeting() {
+ return greeting;
+ }
+
+
+ public void setGreeting(String greeting) {
+ this.greeting = greeting;
+ }
+
+ public String sayHello(String s) {
+ //return greeting + s + " from the JavaWorld!";
+ return greeting + " from Java Reference " + s ; //+ " from " + helloSayer.firstName + " " + helloSayer.lastName;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyImplementationLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..289a187461
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyImplementationLoaderTestCase.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+/**
+ * Tests for RubyImplementationLoader
+ */
+public class RubyImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private RubyImplementationLoader loader;
+
+ public void testNoScriptAttribute() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn(null);
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ replay(reader);
+ replay(deploymentContext);
+
+ try {
+ loader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ // ok
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.groovy");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ RubyImplementationLoader mockLoader = new RubyImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.groovy", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.groovy", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadScript() throws LoaderException {
+ String script =
+ loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/ruby/mock/test.rb");
+ assertEquals("//Test Script", script);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new RubyImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptIntrospectorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptIntrospectorTestCase.java
new file mode 100644
index 0000000000..4f4869355d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptIntrospectorTestCase.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import helloworld.HelloWorldService;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubySCAConfig;
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl;
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+public class RubyScriptIntrospectorTestCase extends TestCase {
+
+ private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() {
+ public void readingWSDL(String namespace, URL location) {
+ }
+
+ public void cachingDefinition(String namespace, URL location) {
+ }
+ };
+
+ public void testJavaInterface() throws MissingResourceException,
+ InvalidServiceContractException {
+ RubyScript rs = new RubyScript("javaInterfaceTest",
+ "$SCA = { 'javaInterface' => 'helloworld.HelloWorldService'}",
+ null,
+ getClass().getClassLoader());
+ RubySCAConfig scaConfig = new RubySCAConfig(rs.getRubyEngine().getGlobalVariables());
+ RubyIntrospector introspector = new RubyIntrospector(null,
+ new JavaInterfaceProcessorRegistryImpl());
+ ComponentType comonentType = introspector.introspectScript(scaConfig,
+ rs.getClassLoader());
+ assertNotNull(comonentType);
+ Map services = comonentType.getServices();
+ assertEquals(1,
+ services.size());
+ ServiceDefinition serviceDefinition = (ServiceDefinition) services.values()
+ .iterator()
+ .next();
+ ServiceContract serviceContract = serviceDefinition.getServiceContract();
+ assertTrue(serviceContract instanceof JavaServiceContract);
+ JavaServiceContract javaServiceContract = (JavaServiceContract) serviceContract;
+ assertEquals(HelloWorldService.class,
+ javaServiceContract.getInterfaceClass());
+ }
+
+ public void testWSDLLocation() throws WSDLException {
+ // RhinoScript rs = new RhinoScript("wsdlLocation",
+ // "SCA = { wsdlLocation : 'src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl',};", null, getClass()
+ // .getClassLoader());
+ // RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope());
+ // JavaScriptIntrospector introspector = new JavaScriptIntrospector(null);
+ // ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader());
+ // assertNotNull(comonentType);
+ // Map services = comonentType.getServices();
+ // assertEquals(1, services.size());
+ // ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next();
+ // ServiceContract serviceContract = serviceDefinition.getServiceContract();
+ // assertTrue(serviceContract instanceof WSDLServiceContract);
+ // WSDLServiceContract wsdlServiceContract = (WSDLServiceContract) serviceContract;
+ // assertEquals(new QName("http://helloworld", "HelloWorld"), wsdlServiceContract.getPortType().getQName());
+ }
+
+ public void testWSDLPortType() throws WSDLException,
+ IOException,
+ MissingResourceException,
+ InvalidServiceContractException {
+ RubyScript rs = new RubyScript("wsdlPortType",
+ "$SCA = { 'wsdlPortType' => 'HelloWorld', 'wsdlNamespace' => 'http://helloworld'}",
+ null,
+ getClass().getClassLoader());
+ RubySCAConfig scaConfig = new RubySCAConfig(rs.getRubyEngine().getGlobalVariables());
+
+ WSDLDefinitionRegistryImpl wsdlReg = new WSDLDefinitionRegistryImpl();
+ wsdlReg.setMonitor(NULL_MONITOR);
+ URL wsdlURL = getClass().getClassLoader()
+ .getResource("org/apache/tuscany/container/ruby/jruby/helloworld.wsdl");
+ wsdlReg.loadDefinition("http://helloworld",
+ wsdlURL);
+
+ RubyIntrospector introspector = new RubyIntrospector(wsdlReg,
+ new JavaInterfaceProcessorRegistryImpl());
+ ComponentType comonentType = introspector.introspectScript(scaConfig,
+ rs.getClassLoader());
+ assertNotNull(comonentType);
+ Map services = comonentType.getServices();
+ assertEquals(1,
+ services.size());
+ ServiceDefinition serviceDefinition = (ServiceDefinition) services.values()
+ .iterator()
+ .next();
+ ServiceContract serviceContract = serviceDefinition.getServiceContract();
+ assertTrue(serviceContract instanceof WSDLServiceContract);
+ WSDLServiceContract wsdlServiceContract = (WSDLServiceContract) serviceContract;
+ assertEquals(new QName("http://helloworld", "HelloWorld"),
+ wsdlServiceContract.getPortType().getQName());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptInvokeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptInvokeTestCase.java
new file mode 100644
index 0000000000..c83605eecb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptInvokeTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+
+/**
+ * Tests for invoker JavaScriptComponents
+ */
+public class ScriptInvokeTestCase extends TestCase {
+
+ private static final String SCRIPT = "def greet(name) \n return name \n end \n";
+
+ private RubyScript rubyScript;
+
+ /**
+ * Tests the invocation of a Groovy "script" as opposed to a class
+ */
+ public void testBasicScriptInvocation() throws Exception {
+// ModuleScopeContainer scope = new ModuleScopeContainer(null);
+// scope.start();
+// List<Class<?>> services = new ArrayList<Class<?>>();
+// services.add(Greeting.class);
+// RubyComponent<Greeting> context = new RubyComponent<Greeting>("source", rhinoScript, services, new HashMap<String, Object>(),
+// null, scope, ArtifactFactory.createWireService(), null);
+// scope.register(context);
+// Greeting object = (Greeting) context.getServiceInstance();
+// assertEquals("foo", object.greet("foo"));
+// scope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ rubyScript = new RubyScript("test", SCRIPT);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/WireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/WireTestCase.java
new file mode 100644
index 0000000000..3794eb82f7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/WireTestCase.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby;
+
+import static org.easymock.EasyMock.reportMatcher;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.ruby.mock.Greeting;
+import org.apache.tuscany.container.ruby.rubyscript.RubyScript;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.test.ArtifactFactory;
+import org.easymock.IArgumentMatcher;
+
+/**
+ * Tests for JavaScript component wiring
+ */
+public class WireTestCase extends TestCase {
+
+ private static final String SCRIPT = " def setWire(ref)\n" + " wire = ref\n"
+ + "end \n" + " def greet(name)\n" + " return wire.greet(name) \n"
+ + " end\n";
+
+ private static final String SCRIPT2 = " def greet(name)\n" + " return name \n"
+ + "end \n";
+
+ private RubyScript implClass1;
+
+ private RubyScript implClass2;
+
+ /**
+ * Tests a basic invocation down a source wire
+ */
+ public void testReferenceWireInvocation() throws Exception {
+ // ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ // scope.start();
+ //
+ // List<Class<?>> services = new ArrayList<Class<?>>();
+ // services.add(Greeting.class);
+ // JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", implClass1, services, properties, null, scope,
+ // ArtifactFactory.createWireService(), null);
+ // OutboundWire<?> wire = ArtifactFactory.createOutboundWire("wire", Greeting.class);
+ // ArtifactFactory.terminateWire(wire);
+ //
+ // TargetInvoker invoker = createMock(TargetInvoker.class);
+ // expect(invoker.isCacheable()).andReturn(false);
+ // Message response = new MessageImpl();
+ // response.setBody("foo");
+ // expect(invoker.invoke(eqMessage())).andReturn(response);
+ // replay(invoker);
+ //
+ // for (OutboundInvocationChain chain : wire.getInvocationChains().values()) {
+ // chain.setTargetInvoker(invoker);
+ // }
+ // scope.register(context);
+ // context.addOutboundWire(wire);
+ // Greeting greeting = context.getServiceInstance();
+ // assertEquals("foo", greeting.greet("foo"));
+ // verify(invoker);
+ //
+ // scope.stop();
+ }
+
+ // todo this could be generalized and moved to test module
+ public static Message eqMessage() {
+ reportMatcher(new IArgumentMatcher() {
+ public boolean matches(Object object) {
+ if (!(object instanceof Message)) {
+ return false;
+ }
+ final Message msg = (Message) object;
+ Object[] body = (Object[]) msg.getBody();
+ return "foo".equals(body[0]);
+ }
+
+ public void appendTo(StringBuffer stringBuffer) {
+ }
+ });
+ return null;
+ }
+
+ /**
+ * Tests a basic invocation to a target
+ */
+ public void testTargetInvocation() throws Exception {
+ ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ Map<String, Object> properties = new Hashtable<String,Object>();
+ properties.put("greeting","HeyThere");
+
+ RubyComponent context = new RubyComponent("source",
+ implClass2,
+ null,
+ services,
+ properties,
+ null,
+ scope,
+ ArtifactFactory.createWireService(),
+ null);
+ scope.register(context);
+ DataType<String> returnDataType = new DataType<String>(String.class, String.class.getName());
+// Operation<String> operation = new Operation<String>("greet",
+// returnDataType,
+// null,
+// null,
+// false,
+// null);
+//
+// TargetInvoker invoker = context.createTargetInvoker(null,
+// operation);
+// assertEquals("foo",
+// invoker.invokeTarget(new String[]{"foo"}));
+ scope.stop();
+ }
+
+ /**
+ * Tests a basic invocation down a target wire
+ */
+ public void testTargetWireInvocation() throws Exception {
+ ModuleScopeContainer scope = new ModuleScopeContainer(null);
+ scope.start();
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ Map<String, Object> properties = new Hashtable<String,Object>();
+ properties.put("greeting","HeyThere");
+ RubyComponent context = new RubyComponent("source",
+ implClass2,
+ null,
+ services,
+ properties,
+ null,
+ scope,
+ ArtifactFactory.createWireService(),
+ null);
+ scope.register(context);
+
+ InboundWire wire = ArtifactFactory.createInboundWire("Greeting",
+ Greeting.class);
+ ArtifactFactory.terminateWire(wire);
+ for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(context.createTargetInvoker(null,
+ chain.getOperation()));
+ }
+ context.addInboundWire(wire);
+ Greeting greeting = (Greeting) context.getServiceInstance("Greeting");
+ assertEquals("foo",
+ greeting.greet("foo"));
+ scope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ implClass1 = new RubyScript("script1", SCRIPT);
+ implClass2 = new RubyScript("script2", SCRIPT2);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/function/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/function/HelloWorldTestCase.java
new file mode 100644
index 0000000000..c2af5b9b10
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/function/HelloWorldTestCase.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby.function;
+
+import java.net.URL;
+
+import helloworld.HelloWorldService;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends SCATestCase {
+
+ private HelloWorldService helloWorldService;
+ private CompositeContext context = null;
+
+
+ protected void setUp() throws Exception {
+ URL base = getClass().getResource("/META-INF/sca/ruby.system.scdl");
+ addExtension("RubyContainer", new URL(base, "default.scdl"));
+ setApplicationSCDL(getClass().getResource("helloworld.scdl"));
+ super.setUp();
+
+ context = CurrentCompositeContext.getContext();
+ helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldRubyComponent");
+
+ //helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldJavaReference");
+ }
+
+ public void testHelloWorldWithClass() throws Exception {
+ assertEquals(helloWorldService.sayHello("petra"), "Hey Howdy from Java Reference petra");
+ //System.out.println(helloWorldService.sayHello("petra"));
+ }
+
+ public void testHelloWorldGlobal() throws Exception {
+ assertEquals(helloWorldService.sayHello("artep"), "Hey Howdy from Java Reference artep");
+ //System.out.println(helloWorldService.sayHello("artep"));
+ }
+
+ public void testHelloWorldProperty() throws Exception {
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldProperty");
+ assertEquals(helloWorldService.sayHello("petra"), "Namaskaar petra");
+ //System.out.println(helloWorldService.sayHello("petra"));
+ }
+
+ public void testHelloWorldPropertyDefault() throws Exception {
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldPropertyDefault");
+ assertEquals(helloWorldService.sayHello("petra"), "Bow Wow petra");
+ //System.out.println(helloWorldService.sayHello("petra"));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Greeting.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Greeting.java
new file mode 100644
index 0000000000..acf71f152b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Greeting.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.ruby.mock;
+
+public interface Greeting {
+
+ String setWire(Greeting ref);
+
+ String greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.componentType
new file mode 100644
index 0000000000..d52b63226c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.componentType
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+ <reference name="extHelloWorld">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+ <property name="greeting" type="xsd:string">Hullow</property>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.rb b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.rb
new file mode 100644
index 0000000000..3f1a053b15
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/HelloWorld.rb
@@ -0,0 +1,33 @@
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+
+class Helloworld
+
+ def sayHello(s)
+ return "Hello to " + s + " from the Ruby World!"
+ end
+
+end
+
+class HelloWorldServiceRubyImpl
+ attr_writer :extHelloWorld
+ attr_writer :greeting
+
+ def sayHello(s)
+ return @greeting + " " + @extHelloWorld.sayHello(s);
+ end
+end
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/IntrospectableHelloWorld.rb b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/IntrospectableHelloWorld.rb
new file mode 100644
index 0000000000..d4edb7a100
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/IntrospectableHelloWorld.rb
@@ -0,0 +1,30 @@
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+
+$SCA = {
+ 'javaInterface' => 'helloworld.HelloWorldService'
+}
+
+def sayHello(s)
+ return "Hello to " + s + " from the Ruby World!"
+end
+
+class HelloWorldServiceRubyImpl
+ def sayHello(s)
+ return "Hello to " + s + " from the Ruby World!"
+ end
+end
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/helloworld.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/helloworld.scdl
new file mode 100644
index 0000000000..222beac543
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/helloworld.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:rb="http://incubator.apache.org/tuscany/xmlns/container/rb/1.0-incubator-M2"
+
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldRubyComponent">
+ <rb:implementation.rb script="org/apache/tuscany/container/ruby/function/HelloWorld.rb" class="HelloWorldServiceRubyImpl"/>
+ <reference name="extHelloWorld" target="HelloWorldJavaReference">HelloWorldJavaReference</reference>
+ <property name="greeting">Hey</property>
+ </component>
+
+ <component name="HelloWorldJavaReference">
+ <implementation.java class="helloworld.HelloWorldServiceImpl"/>
+ <property name="greeting">Howdy</property>
+ </component>
+
+ <component name="HelloWorldProperty">
+ <rb:implementation.rb script="org/apache/tuscany/container/ruby/function/propertyTest.rb" class="HelloWorldPropertyTest"/>
+ <property name="GREETING">Namaskaar</property>
+ </component>
+
+ <component name="HelloWorldPropertyDefault">
+ <rb:implementation.rb script="org/apache/tuscany/container/ruby/function/propertyTest.rb" class="HelloWorldPropertyTest"/>
+ </component>
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.componentType b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.componentType
new file mode 100644
index 0000000000..6b37990b8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.componentType
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+ <property name="GREETING" type="xsd:string">Bow Wow</property>
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.rb b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.rb
new file mode 100644
index 0000000000..7aa0f3e8ea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/function/propertyTest.rb
@@ -0,0 +1,24 @@
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+
+class HelloWorldPropertyTest
+ attr_writer :GREETING
+
+ def sayHello(s)
+ return @GREETING + " " + s;
+ end
+end \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/jruby/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/jruby/helloworld.wsdl
new file mode 100644
index 0000000000..67067f044a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/jruby/helloworld.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/sample-helloworldws/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/mock/test.rb b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/mock/test.rb
new file mode 100644
index 0000000000..ef2694b475
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.ruby/src/test/resources/org/apache/tuscany/container/ruby/mock/test.rb
@@ -0,0 +1 @@
+//Test Script \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/LICENSE.txt
new file mode 100755
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/README.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/README.txt
new file mode 100755
index 0000000000..9b26d1690a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/pom.xml
new file mode 100755
index 0000000000..057f5b7d61
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>spring</artifactId>
+ <name>Apache Tuscany Spring Framework Container</name>
+ <description>Container for managing Spring composites</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.runtime</groupId>
+ <artifactId>webapp</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..047d2b4ad1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/SCANamespaceHandlerResolver.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.config;
+
+import org.apache.tuscany.spi.model.CompositeComponentType;
+
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandler;
+import org.springframework.sca.config.ScaNamespaceHandler;
+
+/**
+ * Overrides the default Spring namespace resolver to automatically register {@link SCANamespaceHandler} instead of
+ * requiring a value to be supplied in a Spring configuration
+ * <p/>
+ * TODO: Figure out how to activate this impl
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SCANamespaceHandlerResolver extends DefaultNamespaceHandlerResolver {
+
+ private static final String SCA_NAMESPACE = "http://www.springframework.org/schema/sca";
+
+ private ScaNamespaceHandler handler;
+
+ public SCANamespaceHandlerResolver(ClassLoader classLoader, CompositeComponentType componentType) {
+ super(classLoader);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ public SCANamespaceHandlerResolver(String handlerMappingsLocation,
+ ClassLoader classLoader,
+ CompositeComponentType componentType) {
+ super(classLoader, handlerMappingsLocation);
+ handler = new ScaNamespaceHandler(/*componentType*/);
+ }
+
+ public NamespaceHandler resolve(String namespaceUri) {
+ if (SCA_NAMESPACE.equals(namespaceUri)) {
+ return handler;
+ }
+ return super.resolve(namespaceUri);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
new file mode 100644
index 0000000000..cdf33b0ea1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/config/ScaApplicationContext.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.config;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.sca.ScaAdapterAware;
+import org.springframework.sca.ScaAdapterPostProcessor;
+
+import org.apache.tuscany.container.spring.impl.SpringScaAdapter;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class ScaApplicationContext extends AbstractXmlApplicationContext {
+ public static final String APP_CONTEXT_PROP = "org.springframework.sca.application.context";
+ private Resource appXml;
+ private SpringComponentType componentType;
+
+ public ScaApplicationContext(Resource appXml, SpringComponentType componentType) {
+ this(null, appXml, componentType);
+ }
+
+ public ScaApplicationContext(ApplicationContext parent, Resource appXml, SpringComponentType componentType) {
+ super(parent);
+ this.appXml = appXml;
+ this.componentType = componentType;
+ refresh();
+ }
+
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
+ // beanDefinitionReader.setEntityResolver(null);
+ beanDefinitionReader
+ .setNamespaceHandlerResolver(new SCANamespaceHandlerResolver(getClassLoader(), componentType));
+ }
+
+ protected Resource[] getConfigResources() {
+ return new Resource[]{appXml};
+ }
+
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ super.postProcessBeanFactory(beanFactory);
+ beanFactory.addBeanPostProcessor(new ScaAdapterPostProcessor(new SpringScaAdapter(componentType)));
+ beanFactory.ignoreDependencyInterface(ScaAdapterAware.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
new file mode 100644
index 0000000000..fa815eee78
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringComponentTypeLoader.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.sca.ScaServiceExporter;
+
+import org.apache.tuscany.container.spring.config.ScaApplicationContext;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.container.spring.model.SpringImplementation;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.host.RuntimeInfo;
+
+/**
+ * Loads a component type for a Spring <code>ApplicationContext</code>. The implementation creates a new instance of a
+ * Spring application context which is configured with SCA namespace handlers for generating component type information
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public class SpringComponentTypeLoader extends ComponentTypeLoaderExtension<SpringImplementation> {
+ public static final String SERVICE_BEAN_SUFFIX = ".SCAService";
+
+ private org.apache.tuscany.host.RuntimeInfo runtimeInfo;
+
+ public SpringComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry, @Autowire RuntimeInfo runtimeInfo) {
+ super(loaderRegistry);
+ this.runtimeInfo = runtimeInfo;
+ }
+
+ @Override
+ protected Class<SpringImplementation> getImplementationClass() {
+ return SpringImplementation.class;
+ }
+
+ /**
+ * Responsible for loading the Spring composite component type. The the application context is instantiated here as
+ * it is needed to derive component type information. Since the component type is loaded per SCDL entry (i.e.
+ * composite use) one application context instance will be created per Spring composite instance.
+ */
+ @SuppressWarnings("unchecked")
+ public void load(CompositeComponent parent,
+ SpringImplementation implementation,
+ DeploymentContext deploymentContext) throws LoaderException {
+ if (implementation.getComponentType() != null) {
+ // FIXME hack since the builder registry loads the implementation type and the Spring implementation loader
+ // needs to as well. The second call is done by the builder registry and we just ignore it.
+ return;
+ }
+ Resource resource = implementation.getApplicationResource();
+ SpringComponentType componentType = new SpringComponentType();
+ // REVIEW andyp -- pass in deploymentContext.getClassLoader()?
+ AbstractRefreshableApplicationContext ctx;
+ if (runtimeInfo instanceof SpringRuntimeInfo) {
+ ctx = ((SpringRuntimeInfo) runtimeInfo).getApplicationContext();
+ } else {
+ ctx = new ScaApplicationContext(resource, componentType);
+ }
+ componentType.setApplicationContext(ctx); // FIXME andyp@bea.com -- don't do this!
+
+ // If there are <sca:service> elements, they define (and limit) the services exposed
+ // in the componentType.
+ String [] serviceBeanNames = ctx.getBeanNamesForType(ScaServiceExporter.class);
+ for (String serviceBeanName : serviceBeanNames) {
+ int nSuffix = serviceBeanName.indexOf(SERVICE_BEAN_SUFFIX);
+ if (nSuffix == -1) {
+ continue;
+ }
+
+ String serviceName = serviceBeanName.substring(0, nSuffix);
+ ScaServiceExporter serviceBean = (ScaServiceExporter) ctx.getBean(serviceName);
+ // REVIEW andyp -- use the class directly?
+ String serviceTypeName = serviceBean.getServiceType().getName();
+ try {
+ Class serviceInterface = Class.forName(serviceTypeName, true, deploymentContext.getClassLoader());
+ componentType.addServiceType(serviceName, serviceInterface);
+ //ServiceDefinition service = createService(serviceInterface);
+ //componentType.getServices().put(serviceName, service);
+ } catch (ClassNotFoundException e) {
+ throw new LoaderException(e);
+ }
+ }
+ // if no service tags are specified, expose all beans
+ componentType.setExposeAllBeans(componentType.getServiceTypes().isEmpty());
+ implementation.setComponentType(componentType);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
new file mode 100644
index 0000000000..6ec5d8fdd7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilder.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import org.apache.tuscany.container.spring.model.SpringImplementation;
+import org.springframework.context.support.AbstractApplicationContext;
+
+/**
+ * Creates a {@link org.apache.tuscany.container.spring.impl.SpringCompositeComponent} from an assembly model
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringCompositeBuilder extends ComponentBuilderExtension<SpringImplementation> {
+
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<SpringImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+ String name = componentDefinition.getName();
+ SpringImplementation implementation = componentDefinition.getImplementation();
+ AbstractApplicationContext applicationContext = implementation.getComponentType().getApplicationContext();
+ SpringCompositeComponent component =
+ new SpringCompositeComponent(name, applicationContext, parent, connector, null);
+ CompositeComponentType<BoundServiceDefinition<? extends Binding>,
+ BoundReferenceDefinition<? extends Binding>,
+ ? extends Property> componentType = implementation.getComponentType();
+
+ // We still need to set the target invoker as opposed to having the connector do it since the
+ // Spring context is "opaque" to the wiring fabric. In other words, the Spring context does not expose
+ // its beans as SCA components to the connector to wire the services to
+ for (BoundServiceDefinition<? extends Binding> serviceDefinition : componentType.getServices().values()) {
+ // call back into builder registry to handle building of services
+ Service service = (Service) builderRegistry.build(parent, serviceDefinition, deploymentContext);
+ // wire serviceDefinition to bean invokers
+ InboundWire wire = service.getInboundWire();
+ QualifiedName targetName = new QualifiedName(serviceDefinition.getTarget().getPath());
+ for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
+ // FIXME this should go to the connector and get policy and be invoked from SpringComposite.prepare()
+ chain.addInterceptor(new SpringInterceptor());
+ chain.setTargetInvoker(component.createTargetInvoker(targetName.getPartName(), chain.getOperation()));
+ }
+ component.register(service);
+ }
+ for (BoundReferenceDefinition<?> referenceDefinition : componentType.getReferences().values()) {
+ // call back into builder registry to handle building of references
+ Reference reference = (Reference) builderRegistry.build(parent, referenceDefinition, deploymentContext);
+ connector.connect(reference);
+ component.register(reference);
+ }
+ return component;
+ }
+
+ protected Class<SpringImplementation> getImplementationType() {
+ return SpringImplementation.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
new file mode 100644
index 0000000000..b30202cb96
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponent.java
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Locale;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.extension.CompositeComponentExtension;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.core.io.Resource;
+
+/**
+ * A composite implementation responsible for managing Spring application contexts.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringCompositeComponent extends CompositeComponentExtension {
+ private static final String[] EMPTY_ARRAY = new String[0];
+ private AbstractApplicationContext springContext;
+
+ /**
+ * Creates a new composite
+ *
+ * @param name the name of the SCA composite
+ * @param springContext the pre-instantiated Spring applicaiton context
+ * @param parent the SCA composite parent
+ * @param connector the connector to use for wiring children
+ * @param propertyValues the values of this composite's Properties
+ */
+ public SpringCompositeComponent(String name,
+ AbstractApplicationContext springContext,
+ CompositeComponent parent,
+ Connector connector,
+ Map<String, Document> propertyValues) {
+ super(name, parent, connector, propertyValues);
+ SCAApplicationContext scaApplicationContext = new SCAApplicationContext();
+ springContext.setParent(scaApplicationContext);
+ // REVIEW we need to refresh to pick up the parent but this is not optimal
+ springContext.refresh();
+ this.springContext = springContext;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ ServiceContract contract = operation.getServiceContract();
+ Method[] methods = contract.getInterfaceClass().getMethods();
+ Method method = findMethod(operation, methods);
+ // FIXME test m == null
+ // Treat the serviceName as the Spring bean name to look up
+ return new SpringInvoker(targetName, method, springContext);
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ // not needed
+ }
+
+ public ConfigurableApplicationContext getApplicationContext() {
+ return springContext;
+ }
+
+ public void prepare() {
+ // TODO handle only references with a composite binding
+ }
+
+ public void start() {
+ super.start();
+ for (SCAObject child : children.values()) {
+ child.start();
+ }
+ springContext.start();
+ }
+
+ public void stop() {
+ super.stop();
+ springContext.stop();
+ }
+
+ public <T> T locateService(Class<T> serviceInterface, String name) {
+ return serviceInterface.cast(springContext.getBean(name));
+ }
+
+ /**
+ * An inner class is required to act as the Spring application context parent as opposed to implementing the
+ * interface since the return types for {@link org.springframework.context.ApplicationContext#getParent()} and
+ * {@link org.apache.tuscany.spi.component.CompositeComponent#getParent()} clash
+ */
+ private class SCAApplicationContext implements ApplicationContext {
+
+ public Object getBean(String name) throws BeansException {
+ return getBean(name, null);
+ }
+
+ public Object getBean(String name, Class requiredType) throws BeansException {
+ SCAObject object = children.get(name); // keep cast due to compiler error
+ if (object == null) {
+ return null;
+ }
+ Class<?> type;
+ if (object instanceof Reference) {
+ type = ((Reference) object).getInterface();
+ } else if (object instanceof Service) {
+ type = ((Service) object).getInterface();
+ } else {
+ throw new AssertionError("Illegal object type [" + name + "]");
+ }
+ if (requiredType != null && requiredType.isAssignableFrom(type)) {
+ // need null check since Spring may pass in a null
+ throw new BeanNotOfRequiredTypeException(name, requiredType, type);
+ }
+ return object.getServiceInstance();
+ }
+
+ public boolean containsBean(String name) {
+ return children.get(name) != null;
+ }
+
+ public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+ return children.get(name) != null;
+ }
+
+ public Class getType(String name) throws NoSuchBeanDefinitionException {
+ return null;
+ }
+
+ public String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+ return EMPTY_ARRAY;
+ }
+
+ public ApplicationContext getParent() {
+ return null;
+ }
+
+ public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
+ return null;
+ }
+
+ public String getDisplayName() {
+ return getName();
+ }
+
+ public long getStartupDate() {
+ return 0;
+ }
+
+ public boolean containsBeanDefinition(String beanName) {
+ return false;
+ }
+
+ public int getBeanDefinitionCount() {
+ return 0;
+ }
+
+ public String[] getBeanDefinitionNames() {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type) {
+ return new String[0];
+ }
+
+ public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean includeFactoryBeans) {
+ return new String[0];
+ }
+
+ public Map getBeansOfType(Class type) throws BeansException {
+ return null;
+ }
+
+ public Map getBeansOfType(Class type, boolean includePrototypes, boolean includeFactoryBeans)
+ throws BeansException {
+ return null;
+ }
+
+ public BeanFactory getParentBeanFactory() {
+ return null;
+ }
+
+ public boolean containsLocalBean(String name) {
+ return false;
+ }
+
+ public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
+ return null;
+ }
+
+ public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
+ return null;
+ }
+
+ public void publishEvent(ApplicationEvent event) {
+
+ }
+
+ public Resource[] getResources(String locationPattern) throws IOException {
+ return new Resource[0];
+ }
+
+ public Resource getResource(String location) {
+ return null;
+ }
+
+ public ClassLoader getClassLoader() {
+ // REVIEW: this is almost certainly flawed, but it's not clear how the SCA runtime's
+ // resource loading mechanism is exposed right now.
+ return this.getClass().getClassLoader();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java
new file mode 100644
index 0000000000..c95375cad2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringImplementationLoader.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.container.spring.model.SpringImplementation;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * Loader for handling Spring <spring:implementation.spring> elements.
+ */
+public class SpringImplementationLoader extends LoaderExtension<SpringImplementation> {
+ private static final QName IMPLEMENTATION_SPRING = new QName("http://www.osoa.org/xmlns/sca/1.0",
+ "implementation.spring");
+
+ private static final String APPLICATION_CONTEXT = "application-context.xml";
+
+ private static final QName SERVICE_ELEMENT = new QName(XML_NAMESPACE_1_0, "service");
+ private static final QName REFERENCE_ELEMENT = new QName(XML_NAMESPACE_1_0, "reference");
+
+ private final RuntimeInfo runtimeInfo;
+
+ public SpringImplementationLoader(@Autowire LoaderRegistry registry, @Autowire RuntimeInfo runtimeInfo) {
+ super(registry);
+ this.runtimeInfo = runtimeInfo;
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_SPRING;
+ }
+
+ @SuppressWarnings("unchecked")
+ public SpringImplementation load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ String locationAttr = reader.getAttributeValue(null, "location");
+ if (locationAttr == null && !contextProvided()) {
+ throw new MissingResourceException("No location supplied");
+ }
+
+ SpringImplementation implementation = new SpringImplementation();
+ ClassLoader classLoader = deploymentContext.getClassLoader();
+ if (!contextProvided()) {
+ implementation.setApplicationResource(getApplicationContextResource(locationAttr, classLoader));
+ }
+ registry.loadComponentType(parent, implementation, deploymentContext);
+ SpringComponentType type = implementation.getComponentType();
+ while (true) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ if (SERVICE_ELEMENT.equals(qname)) {
+ BoundServiceDefinition service =
+ (BoundServiceDefinition) registry.load(parent, reader, deploymentContext);
+ if (!type.isExposeAllBeans()) {
+ String name = service.getName();
+ if (!type.getServiceTypes().containsKey(name)) {
+ LoaderException e = new LoaderException("No service defined in Spring context for ");
+ e.setIdentifier(name);
+ throw e;
+ }
+ }
+ type.getDeclaredServices().put(service.getName(), service);
+ } else if (REFERENCE_ELEMENT.equals(qname)) {
+ BoundReferenceDefinition reference =
+ (BoundReferenceDefinition) registry.load(parent, reader, deploymentContext);
+ type.getDeclaredReferences().put(reference.getName(), reference);
+ }
+ break;
+ case END_ELEMENT:
+ if (IMPLEMENTATION_SPRING.equals(reader.getName())) {
+ return implementation;
+ }
+ }
+ }
+ }
+
+ protected Resource getApplicationContextResource(String locationAttr, ClassLoader cl) throws LoaderException {
+ assert runtimeInfo != null;
+ File manifestFile = null;
+ File appXmlFile;
+ File locationFile = new File(locationAttr);
+
+ if (!locationFile.isAbsolute()) {
+ locationFile = new File(runtimeInfo.getApplicationRootDirectory(), locationAttr);
+ }
+ if (!locationFile.exists()) {
+ // FIXME hack
+ URL url = cl.getResource(locationAttr);
+ if (url != null) {
+ return new UrlResource(url);
+ }
+ throw new MissingResourceException(locationFile.toString());
+ }
+
+ if (locationFile.isDirectory()) {
+ try {
+ manifestFile = new File(locationFile, "META-INF/MANIFEST.MF");
+ if (manifestFile.exists()) {
+ Manifest mf = new Manifest(new FileInputStream(manifestFile));
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ appXmlFile = new File(locationFile, appCtxPath);
+ if (appXmlFile.exists()) {
+ return new UrlResource(appXmlFile.toURL());
+ }
+ }
+ }
+ // no manifest-specified Spring context, use default
+ appXmlFile = new File(locationFile, APPLICATION_CONTEXT);
+ if (appXmlFile.exists()) {
+ return new UrlResource(appXmlFile.toURL());
+ }
+ } catch (IOException e) {
+ throw new LoaderException("Error reading manifest " + manifestFile);
+ }
+ } else {
+ try {
+ JarFile jf = new JarFile(locationFile);
+ JarEntry je;
+ Manifest mf = jf.getManifest();
+ if (mf != null) {
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ je = jf.getJarEntry(appCtxPath);
+ if (je != null) {
+ // TODO return a Spring specific Resouce type for jars
+ return new UrlResource(new URL("jar:" + locationFile.toURL() + "!/" + appCtxPath));
+ }
+ }
+ }
+ je = jf.getJarEntry(APPLICATION_CONTEXT);
+ if (je != null) {
+ return new UrlResource(new URL("jar:" + locationFile.toURI().toURL() + "!" + APPLICATION_CONTEXT));
+ }
+ } catch (IOException e) {
+ // bad archive
+ // TODO: create a more appropriate exception type
+ throw new MissingResourceException(locationAttr, e);
+ }
+ }
+ throw new MissingResourceException(APPLICATION_CONTEXT);
+ }
+
+ private boolean contextProvided() {
+ return runtimeInfo instanceof SpringRuntimeInfo;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInterceptor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInterceptor.java
new file mode 100644
index 0000000000..fb7f0bd99c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInterceptor.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * A temporary interceptor until the connector is updated
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ TargetInvoker invoker = msg.getTargetInvoker();
+ if (invoker == null) {
+ throw new InvocationRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last one in an target interceptor chain");
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java
new file mode 100644
index 0000000000..6e05c888ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringInvoker.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Dispatches to an operation on a Spring bean. Since Spring manages bean lifecycle and scope through resolution in the
+ * target proxy, the invoker can safely cache the target proxy.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringInvoker implements TargetInvoker {
+ private ApplicationContext springContext;
+ // default to true since Spring handles resolution
+ private boolean cacheable = true;
+ private String beanName;
+ private Method method;
+ // caching is thread-safe since Spring handles resolution
+ private Object bean;
+
+ public SpringInvoker(String beanName, Method method, ApplicationContext context) {
+ this.beanName = beanName;
+ this.method = method;
+ springContext = context;
+ }
+
+ public Object invokeTarget(final Object object) throws InvocationTargetException {
+ if (bean == null) {
+ try {
+ bean = springContext.getBean(beanName);
+ } catch (BeansException e) {
+ throw new TargetException(e);
+ }
+ }
+ try {
+ if (object != null && !object.getClass().isArray()) {
+ return method.invoke(bean, object);
+ } else {
+ return method.invoke(bean, (Object[]) object);
+ }
+ } catch (IllegalAccessException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+
+ public SpringInvoker clone() throws CloneNotSupportedException {
+ SpringInvoker invoker = (SpringInvoker) super.clone();
+ invoker.bean = null;
+ return invoker;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringRuntimeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringRuntimeInfo.java
new file mode 100644
index 0000000000..8b4f0ac905
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringRuntimeInfo.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.tuscany.host.RuntimeInfo;
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class SpringRuntimeInfo implements RuntimeInfo {
+ private AbstractRefreshableApplicationContext applicationContext;
+ private File appRootDir;
+
+ public SpringRuntimeInfo(File appRootDir, AbstractRefreshableApplicationContext applicationContext) {
+ this.appRootDir = appRootDir;
+ this.applicationContext = applicationContext;
+ }
+
+ public AbstractRefreshableApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public void setApplicationContext(AbstractRefreshableApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ public File getInstallDirectory() {
+ return null;
+ }
+
+ public File getApplicationRootDirectory() {
+ return appRootDir;
+ }
+
+ public URL getBaseURL() {
+ return null;
+ }
+
+ public boolean isOnline() {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
new file mode 100644
index 0000000000..ca645db823
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/impl/SpringScaAdapter.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.springframework.sca.ScaAdapter;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class SpringScaAdapter implements ScaAdapter {
+ //private final SpringComponentType componentType;
+
+ public SpringScaAdapter(SpringComponentType componentType) {
+ //this.componentType = componentType;
+ }
+
+ public Object getServiceReference(String referenceName, Class referenceType, String moduleName,
+ String defaultServiceName) {
+ /*
+ ReferenceDefinition reference = null;
+ componentType.getReferences().put(referenceName, reference);
+ */
+ return null;
+ }
+
+ public Object getPropertyReference(String propertyName, Class propertyType, String moduleName) {
+ return null;
+ }
+
+ public void publishAsService(Object serviceImplementation, Class serviceInterface, String serviceName,
+ String moduleName) {
+ /*
+ componentType.addServiceType(serviceName, serviceInterface);
+ ServiceDefinition service = null;
+ componentType.getServices().put(serviceName, service);
+ */
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
new file mode 100644
index 0000000000..d8758ffdb7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringComponentType.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import org.springframework.context.support.AbstractApplicationContext;
+
+/**
+ * Component type information for a Spring composite component implementation type. A component type is associated with
+ * a Spring application context
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringComponentType<S extends ServiceDefinition,
+ R extends ReferenceDefinition,
+ P extends Property<?>> extends CompositeComponentType<S, R, P> {
+
+ private AbstractApplicationContext applicationContext;
+ private Map<String, Class<?>> serviceTypes = new HashMap<String, Class<?>>();
+ private boolean exposeAllBeans;
+
+ public SpringComponentType(AbstractApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ public SpringComponentType() {
+ }
+
+ // FIXME andyp@bea.com -- this is a component type it should NOT contain bean instances!
+
+ /**
+ * Returns the application context for the component type
+ */
+ public AbstractApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public void setApplicationContext(AbstractApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ /**
+ * Returns a collection of service types defined by <code>sca:service</code> elements in a Spring configuration.
+ * Service types define beans that can be targets of services defined in the SCDL Spring composite declaration. For
+ * each service type, there must be a corresponding service definition as part of the Spring composite declaration
+ * per the SCA specification.
+ */
+ public Map<String, Class<?>> getServiceTypes() {
+ return serviceTypes;
+ }
+
+ /**
+ * Adds a service type to the component declaration defined by <code>sca:service</code> elements in a Spring
+ * configuration.
+ *
+ * @param name the name of the service
+ * @param type the interface type of the target bean
+ */
+ public void addServiceType(String name, Class<?> type) {
+ this.serviceTypes.put(name, type);
+ }
+
+ /**
+ * Returns true if all beans in the Spring application context may be service targets or false if service types are
+ * defined
+ */
+ public boolean isExposeAllBeans() {
+ return exposeAllBeans;
+ }
+
+ /**
+ * Sets if all beans in the Spring application context may be service targets or false if service types are defined
+ */
+ public void setExposeAllBeans(boolean exposeAllBeans) {
+ this.exposeAllBeans = exposeAllBeans;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringImplementation.java
new file mode 100644
index 0000000000..7780894f56
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringImplementation.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.model;
+
+import org.apache.tuscany.spi.model.Binding;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Property;
+
+import org.springframework.core.io.Resource;
+
+/**
+ * Represents a composite whose implementation type is a Spring application context.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringImplementation extends Implementation<SpringComponentType<BoundServiceDefinition<? extends Binding>,
+ BoundReferenceDefinition<? extends Binding>, ? extends Property>> {
+
+ private String location;
+ private Resource applicationResource;
+
+ public SpringImplementation() {
+ }
+
+ public SpringImplementation(SpringComponentType<
+ BoundServiceDefinition<? extends Binding>,
+ BoundReferenceDefinition<? extends Binding>,
+ ? extends Property> componentType) {
+ super(componentType);
+ }
+
+ /**
+ * Returns the path of the Spring application context configuration
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Sets the path of the Spring application context configuration
+ */
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ /**
+ * Returns the Spring configuration resource for the application context
+ */
+ public Resource getApplicationResource() {
+ return applicationResource;
+ }
+
+ /**
+ * Sets the Spring configuration resource for the application context
+ */
+ public void setApplicationResource(Resource applicationXml) {
+ this.applicationResource = applicationXml;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringServiceContract.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringServiceContract.java
new file mode 100644
index 0000000000..3a88991e4b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/model/SpringServiceContract.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.model;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringServiceContract extends ServiceContract {
+
+ public SpringServiceContract(String interfaceName) {
+ super(interfaceName);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/ScaWebApplicationContext.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/ScaWebApplicationContext.java
new file mode 100644
index 0000000000..2284d32201
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/ScaWebApplicationContext.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.webapp;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+import org.apache.tuscany.container.spring.config.SCANamespaceHandlerResolver;
+import org.apache.tuscany.container.spring.impl.SpringScaAdapter;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.runtime.webapp.WebappRuntime;
+import org.apache.tuscany.runtime.webapp.WebappUtil;
+import org.apache.tuscany.runtime.webapp.WebappUtilImpl;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.core.io.Resource;
+import org.springframework.sca.ScaAdapterAware;
+import org.springframework.sca.ScaAdapterPostProcessor;
+import org.springframework.util.Assert;
+import org.springframework.web.context.ConfigurableWebApplicationContext;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+
+/**
+ * WebApplicationContext implementation that understands SCA extensions.
+ * This class is not very complicated, the key issue is getting hold of a reference
+ * to the Tuscany runtime which the webapp is using.
+ *
+ * @author Andy Piper
+ */
+public class ScaWebApplicationContext extends XmlWebApplicationContext
+ implements ConfigurableWebApplicationContext {
+ private WebappRuntime runtime;
+ private SpringComponentType componentType;
+
+ public ScaWebApplicationContext() {
+ }
+
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
+// beanDefinitionReader.setEntityResolver(null);
+ beanDefinitionReader
+ .setNamespaceHandlerResolver(new SCANamespaceHandlerResolver(getClassLoader(), componentType));
+ }
+
+ public Resource getResource(String location) {
+ Assert.notNull(location, "location is required");
+ return super.getResource(location);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.context.support.AbstractApplicationContext#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
+ */
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ super.postProcessBeanFactory(beanFactory);
+ beanFactory.addBeanPostProcessor(new ScaAdapterPostProcessor
+ (new SpringScaAdapter(componentType)));
+ beanFactory.ignoreDependencyInterface(ScaAdapterAware.class);
+ }
+
+ protected void onRefresh() {
+ if (runtime != null) { // egregious hack to prevent recursion in refresh()
+ return;
+ }
+ ServletContext servletContext = getServletContext();
+ WebappUtil utils = getUtils(servletContext);
+
+ try {
+ ClassLoader webappClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader bootClassLoader = utils.getBootClassLoader(webappClassLoader);
+ runtime = utils.getRuntime(bootClassLoader);
+ URL systemScdl = utils.getSystemScdl(bootClassLoader);
+ URL applicationScdl = utils.getApplicationScdl(webappClassLoader);
+
+ runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
+ runtime.setApplicationName(utils.getApplicationName());
+ runtime.setServletContext(servletContext);
+ runtime.setHostClassLoader(webappClassLoader);
+ runtime.setSystemScdl(systemScdl);
+ runtime.setApplicationScdl(applicationScdl);
+ runtime.setRuntimeInfo(new SpringWebappRuntimeInfo(getApplicationRootDirectory(), this));
+ runtime.initialize();
+ } catch (TuscanyRuntimeException e) {
+ servletContext.log(e.getMessage(), e);
+ throw e;
+ }
+ }
+
+ protected WebappUtil getUtils(ServletContext servletContext) {
+ return new WebappUtilImpl(servletContext);
+ }
+
+ protected void onClose() {
+ if (runtime != null) {
+ runtime.destroy();
+ runtime = null;
+ }
+ }
+
+ /**
+ * What does this do and why to we need it?
+ * @return
+ */
+ private File getApplicationRootDirectory() {
+ String property = System.getProperty("tuscany.applicationRootDir");
+ if (property != null) {
+ return new File(property);
+ }
+
+ return new File(System.getProperty("user.dir"));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/SpringWebappRuntimeInfo.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/SpringWebappRuntimeInfo.java
new file mode 100644
index 0000000000..a860049462
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/apache/tuscany/container/spring/webapp/SpringWebappRuntimeInfo.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.webapp;
+
+import java.io.File;
+import javax.servlet.ServletContext;
+
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+
+import org.apache.tuscany.container.spring.impl.SpringRuntimeInfo;
+import org.apache.tuscany.runtime.webapp.WebappRuntimeInfo;
+
+/**
+ * @author Andy Piper
+ */
+public class SpringWebappRuntimeInfo extends SpringRuntimeInfo implements WebappRuntimeInfo {
+ public SpringWebappRuntimeInfo(File appRootDir, XmlWebApplicationContext applicationContext) {
+ super(appRootDir, applicationContext);
+ }
+
+ public ServletContext getServletContext() {
+ return ((WebApplicationContext) getApplicationContext()).getServletContext();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
new file mode 100644
index 0000000000..e2071e27c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/DefaultScaAdapter.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 11-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+/**
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class DefaultScaAdapter implements ScaAdapter {
+
+ public Object getServiceReference(String referenceName,
+ Class referenceType,
+ String moduleName,
+ String defaultServiceName) {
+ // TODO
+ return new Object();
+ }
+
+ public Object getPropertyReference(String propertyName, Class propertyType, String moduleName) {
+ // TODO
+ return new Object();
+ }
+
+ public void publishAsService(Object serviceImplementation,
+ Class serviceInterface,
+ String serviceName,
+ String moduleName) {
+ // TODO
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
new file mode 100644
index 0000000000..e5aae6f0a2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapter.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 11-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+/**
+ * Encapsulates interaction with an SCA runtime
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public interface ScaAdapter {
+
+ Object getServiceReference(
+ String referenceName,
+ Class referenceType,
+ String moduleName,
+ String defaultServiceName);
+
+ Object getPropertyReference(
+ String propertyName,
+ Class propertyType,
+ String moduleName);
+
+ void publishAsService(
+ Object serviceImplementation,
+ Class serviceInterface,
+ String serviceName,
+ String moduleName);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
new file mode 100644
index 0000000000..abe975c936
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterAware.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.springframework.sca;
+
+/**
+ * /** Interface that enables beans to find the ScaAdapter they are defined with.
+ * <p/>
+ * Note that in most circumstances there is no need for a bean to implement this interface.
+ *
+ * @author Andy Piper
+ * @since 2.1
+ */
+public interface ScaAdapterAware {
+ void setScaAdapter(ScaAdapter adapter);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
new file mode 100644
index 0000000000..b07be8f452
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaAdapterPostProcessor.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+/**
+ * @author Andy Piper
+ * @since 2.1
+ */
+public class ScaAdapterPostProcessor implements BeanPostProcessor {
+ private ScaAdapter scaAdapter;
+
+ public ScaAdapterPostProcessor(ScaAdapter adapter) {
+ this.scaAdapter = adapter;
+ }
+
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ if (bean instanceof ScaAdapterAware) {
+ if (this.scaAdapter == null) {
+ throw new IllegalStateException("Cannot satisfy ScaAdapterAware for bean '"
+ + beanName + "' without ScaAdapater");
+ }
+ ((ScaAdapterAware) bean).setScaAdapter(scaAdapter);
+ }
+ return bean;
+ }
+
+ public Object postProcessAfterInitialization(Object object, String string) throws BeansException {
+ return object;
+ }
+
+ public ScaAdapter getScaAdapter() {
+ return scaAdapter;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
new file mode 100644
index 0000000000..e12e763d9f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaComposite.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Bean that represents an Sca composite component. An instance of this bean is created when the &lt;sca:composite
+ * module-id="xxx"/&gt; element is declared.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaComposite implements InitializingBean {
+
+ private String component;
+ private ScaAdapter scaAdapter = new DefaultScaAdapter();
+
+ public String getComponent() {
+ return this.component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
+
+ public void setScaAdapter(ScaAdapter scaAdapter) {
+ this.scaAdapter = scaAdapter;
+ }
+
+ public void setScaAdapterClass(Class adapterClass) {
+ if (!ScaAdapter.class.isAssignableFrom(adapterClass)) {
+ throw new IllegalArgumentException(
+ "Adapter class '" + adapterClass + "' specified for ScaComposite bean "
+ + "does not implement the ScaApapter interface"
+ );
+ }
+ try {
+ this.scaAdapter = (ScaAdapter) adapterClass.newInstance();
+ } catch (Exception ex) {
+ // many exceptions may be thrown by the above, we treat them all
+ // the same
+ throw new IllegalStateException("Unable to create instance of ScaAdapter class '"
+ + adapterClass.getName() + "'", ex);
+ }
+ }
+
+ public ScaAdapter getScaAdapter() {
+ return this.scaAdapter;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.component == null) {
+ throw new IllegalArgumentException("Required property moduleId was not set");
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
new file mode 100644
index 0000000000..f96af00584
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPostProcessor.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.sca;
+
+import java.beans.PropertyDescriptor;
+
+import org.springframework.aop.framework.ProxyFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.PropertyValues;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.sca.intercept.OneWayAdvisor;
+import org.springframework.sca.metadata.DeploymentMetadata;
+import org.springframework.sca.metadata.Injection;
+import org.springframework.sca.metadata.NoSuchServiceException;
+import org.springframework.sca.metadata.ServiceMetadata;
+
+/**
+ * Spring bean post processor that looks up service metadata by name for each bean definition and performs SCA
+ * injection.
+ * <p/>
+ * Also performs proxying for OneWay.
+ *
+ * @author Rod Johnson
+ */
+public class ScaPostProcessor implements InstantiationAwareBeanPostProcessor, ApplicationContextAware {
+
+ private DeploymentMetadata deploymentMetadata;
+
+ private ApplicationContext applicationContext;
+
+ private TaskExecutor taskExecutor;
+
+ //private ScaAdapter scaAdapter;
+
+
+ /**
+ * @param taskExecutor The taskExecutor to set.
+ */
+ public void setTaskExecutor(TaskExecutor taskExecutor) {
+ this.taskExecutor = taskExecutor;
+ }
+
+ // TODO would process side files when container starts up
+
+ public void setDeploymentMetadata(DeploymentMetadata deploymentMetadata) {
+ this.deploymentMetadata = deploymentMetadata;
+ }
+
+ /**
+ * @param scaAdapter the ScaAdapter for use to export services if necessary
+ */
+ public void setScaAdapter(ScaAdapter scaAdapter) {
+ //this.scaAdapter = scaAdapter;
+ }
+
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ public Object postProcessBeforeInstantiation(Class beanClass,
+ String beanName) throws BeansException {
+ return null;
+ }
+
+ public boolean postProcessAfterInstantiation(Object bean, String beanName)
+ throws BeansException {
+ try {
+ ServiceMetadata smd = deploymentMetadata.getServiceMetadata(beanName);
+ doScaInjection(bean, smd);
+ } catch (NoSuchServiceException ex) {
+ //
+ }
+ return true;
+ }
+
+ public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
+ String beanName) throws BeansException {
+ return pvs;
+ }
+
+ public PropertyValues postProcessPropertyValues(PropertyValues propertyValues, Object object, String string)
+ throws BeansException {
+ return propertyValues;
+ }
+
+ protected void doScaInjection(Object bean, ServiceMetadata smd) {
+ for (Injection injection : smd.getInjections()) {
+ injection.apply(applicationContext, bean);
+ }
+ }
+
+ public Object postProcessBeforeInitialization(Object bean, String beanName)
+ throws BeansException {
+ return bean;
+ }
+
+ public Object postProcessAfterInitialization(Object bean, String beanName)
+ throws BeansException {
+ try {
+ ServiceMetadata smd = deploymentMetadata.getServiceMetadata(beanName);
+ return createScaProxy(bean, smd);
+ } catch (NoSuchServiceException ex) {
+ return bean;
+ }
+
+ // TODO validate required injections here or earlier
+
+ // TODO publish if necessary, using adapter
+ }
+
+ protected Object createScaProxy(Object bean, ServiceMetadata smd) {
+ ProxyFactory pf = new ProxyFactory(bean);
+ for (Class intf : smd.getServiceInterfaces()) {
+ pf.addInterface(intf);
+ }
+
+//pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
+//pf.addAdvisor(new ExposeBeanNameAdvisor(smd.getServiceName()));
+ // TODO enforce call by value
+
+ if (!smd.getOneWayMethods().isEmpty()) {
+ pf.addAdvisor(new OneWayAdvisor(smd, this.taskExecutor));
+ }
+
+ return pf.getProxy();
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
new file mode 100644
index 0000000000..e89072466a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaPropertyProxyFactoryBean.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Factory bean that returns a reference to an SCA property obtained by asking the SCA runtime for the property with the
+ * given name for the given component.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaPropertyProxyFactoryBean implements InitializingBean, FactoryBean {
+
+ /**
+ * the type of the property
+ */
+ private Class propertyType;
+
+ /**
+ * the name of the property to look up
+ */
+ private String propertyName;
+
+ /**
+ * the SCA component we should present ourselves as when asking for a service reference
+ */
+ private ScaComposite scaComposite;
+
+ private Object resolvedPropertyVal;
+
+ public void setPropertyType(Class serviceType) {
+ this.propertyType = serviceType;
+ }
+
+ public Class getPropertyType() {
+ return this.propertyType;
+ }
+
+ public void setPropertyName(String name) {
+ this.propertyName = name;
+ }
+
+ public String getPropertyName() {
+ return this.propertyName;
+ }
+
+ public void setScaComposite(ScaComposite scaComposite) {
+ this.scaComposite = scaComposite;
+ }
+
+ public ScaComposite getScaComposite() {
+ return this.scaComposite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.propertyType == null) {
+ throw new IllegalArgumentException("Required property serviceType was not set");
+ }
+ if (this.scaComposite == null) {
+ throw new IllegalArgumentException("Required property scaComposite was not set");
+ }
+ if (this.propertyName == null) {
+ throw new IllegalArgumentException("Required property referenceName was not set");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObject()
+ */
+ public Object getObject() throws Exception {
+ if (this.resolvedPropertyVal != null) {
+ return this.resolvedPropertyVal;
+ }
+
+ String moduleName = this.scaComposite.getComponent();
+ // TODO: AMC is there any merit in proxying this with a lazy target source?
+ Object propertyVal =
+ this.scaComposite.getScaAdapter().getPropertyReference(this.propertyName, this.propertyType, moduleName);
+ if (!this.propertyType.isAssignableFrom(propertyVal.getClass())) {
+ throw new IllegalStateException("Property value '" + propertyVal.toString() + "'"
+ + " of type '" + propertyVal.getClass().getName() + "' "
+ + " is not of expected type '" + this.propertyType.getName() + "'");
+ }
+ this.resolvedPropertyVal = propertyVal;
+ return this.resolvedPropertyVal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class getObjectType() {
+ return this.propertyType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
new file mode 100644
index 0000000000..0155dd9646
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceExporter.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Exposes a bean instance to SCA to using the given service name.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaServiceExporter implements InitializingBean, BeanFactoryAware, ScaAdapterAware {
+
+ /**
+ * the name of the service we want to advertise
+ */
+ private String serviceName;
+
+ /**
+ * the type the service should be published with
+ */
+ private Class serviceType;
+
+ /**
+ * the bean to be published
+ */
+ private Object target;
+
+ /**
+ * for resolving the bean name
+ */
+ private BeanFactory beanFactory;
+ private ScaAdapter scaAdapter;
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceName() {
+ return this.serviceName;
+ }
+
+ public void setServiceType(Class serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public Class getServiceType() {
+ return this.serviceType;
+ }
+
+ public void setTarget(Object targetBean) {
+ this.target = targetBean;
+ }
+
+ public Object getTarget() {
+ return this.target;
+ }
+
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = beanFactory;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ if (this.serviceType == null) {
+ throw new IllegalArgumentException("Required property serviceType was not set");
+ }
+ if (this.target == null) {
+ throw new IllegalArgumentException("Required property target was not set");
+ }
+ if (this.beanFactory == null) {
+ throw new IllegalArgumentException("Required property beanFactory was not set");
+ }
+ if (this.serviceName == null) {
+ throw new IllegalArgumentException("Required property serviceName was not set");
+ }
+ publishScaService();
+ }
+
+ private void publishScaService() {
+ scaAdapter.publishAsService(target, serviceType, serviceName, null);
+ }
+
+ public void setScaAdapter(ScaAdapter adapter) {
+ this.scaAdapter = adapter;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
new file mode 100644
index 0000000000..01ca5671d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/ScaServiceProxyFactoryBean.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Factory bean that returns a reference to an SCA service obtained by asking the SCA runtime for the service with the
+ * given name for the given component.
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaServiceProxyFactoryBean
+ implements InitializingBean, FactoryBean, ApplicationContextAware, ScaAdapterAware {
+
+ /**
+ * the public interface type of the service (may be a class...)
+ */
+ private Class serviceType;
+
+ /**
+ * the name of the reference to look up
+ */
+ private String referenceName;
+
+ /**
+ * the default service name to resolve the reference too
+ */
+ private String defaultServiceName;
+
+ private Object resolvedServiceReference;
+ private ApplicationContext applicationContext;
+ //private ScaAdapter scaAdapter;
+
+ public void setServiceType(Class serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public Class getServiceType() {
+ return this.serviceType;
+ }
+
+ public void setReferenceName(String name) {
+ this.referenceName = name;
+ }
+
+ public String getReferenceName() {
+ return this.referenceName;
+ }
+
+ public void setDefaultServiceName(String defaultService) {
+ this.defaultServiceName = defaultService;
+ }
+
+ public String getDefaultServiceName() {
+ return this.defaultServiceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ if (this.serviceType == null) {
+ throw new IllegalArgumentException("Required property serviceType was not set");
+ }
+ if (this.referenceName == null) {
+ throw new IllegalArgumentException("Required property referenceName was not set");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObject()
+ */
+ public Object getObject() throws Exception {
+ if (this.resolvedServiceReference != null) {
+ return this.resolvedServiceReference;
+ }
+
+ // TODO: AMC is there any merit in proxying this with a lazy target source?
+ // should the returned service ref be proxied? Only seems to add value
+ // if SCA gives us any lifecycle events we can subscribe to and take
+ // meaningful action on...
+ // See OsgiServiceProxyFactoryBean for an example of how to do the
+ // proxying if needed.
+ Object scaServiceRef;
+ if (this.applicationContext.getParent() == null) {
+ return null;
+ }
+
+ if (!this.applicationContext.getParent().containsBean(this.referenceName)) {
+ return new Object();
+ //scaServiceRef = this.applicationContext.getParent().getBean(this.defaultServiceName);
+ } else {
+ scaServiceRef = this.applicationContext.getParent().getBean(this.referenceName);
+ }
+ if (!this.serviceType.isAssignableFrom(scaServiceRef.getClass())) {
+ throw new IllegalStateException("...");
+ }
+ this.resolvedServiceReference = scaServiceRef;
+ return this.resolvedServiceReference;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class getObjectType() {
+ return this.serviceType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return false;
+ }
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ public void setScaAdapter(ScaAdapter adapter) {
+ // this.scaAdapter = adapter;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
new file mode 100644
index 0000000000..9c6ac633f7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaCompositeBeanDefinitionParser.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.sca.ScaComposite;
+
+/**
+ * Parser for &lt;sca:composite&gt; elements
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaCompositeBeanDefinitionParser implements BeanDefinitionParser {
+
+ static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
+ private static final String MODULE_ATTRIBUTE_NAME = "component";
+ private static final String MODULE_ID = "component";
+ private static final String ADAPTER_ATTRIBUTE = "sca-adapter-class";
+ private static final String ADAPTER_CLASS_PROPERTY = "scaAdapterClass";
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ if (registry.containsBeanDefinition(SCA_COMPOSITE_BEAN_NAME)) {
+ throw new IllegalArgumentException(
+ "At most one <sca:composite> element can be declared in a bean factory");
+ }
+ BeanDefinition beanDef = createScaCompositeBeanDefinition(element);
+ registry.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, beanDef);
+ return beanDef;
+ }
+
+ private BeanDefinition createScaCompositeBeanDefinition(Element element) {
+ RootBeanDefinition beanDefinition = new RootBeanDefinition();
+ beanDefinition.setBeanClass(ScaComposite.class);
+ MutablePropertyValues props = new MutablePropertyValues();
+ props.addPropertyValue(MODULE_ID, element.getAttribute(MODULE_ATTRIBUTE_NAME));
+ if (element.hasAttribute(ADAPTER_ATTRIBUTE)) {
+ props.addPropertyValue(ADAPTER_CLASS_PROPERTY, element.getAttribute(ADAPTER_ATTRIBUTE));
+ }
+ beanDefinition.setPropertyValues(props);
+ return beanDefinition;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
new file mode 100644
index 0000000000..3446aaf462
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaContextBuilder.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.sca.ScaAdapter;
+import org.springframework.sca.ScaComposite;
+
+/**
+ * @author Hal Hildebrand Date: Apr 11, 2006 Time: 4:33:33 PM
+ */
+public class ScaContextBuilder {
+ private static final String MODULE_ID = "moduleId";
+
+ private static final String SCA_ADAPTER = "scaAdapter";
+
+ private static final String SCA_COMPOSITE_BEAN_NAME = "scaComposite";
+
+ private String moduleId;
+
+ private ScaAdapter scaAdapter;
+
+ public String getModuleId() {
+ return this.moduleId;
+ }
+
+ public void setModuleId(String moduleId) {
+ this.moduleId = moduleId;
+ }
+
+ public void setScaAdapter(ScaAdapter scaAdapter) {
+ this.scaAdapter = scaAdapter;
+ }
+
+ public ScaAdapter getScaAdapter() {
+ return this.scaAdapter;
+ }
+
+ public ApplicationContext construct() {
+ GenericApplicationContext parent = new GenericApplicationContext();
+ BeanDefinition bd = new RootBeanDefinition(ScaComposite.class, true);
+
+ bd.getPropertyValues().addPropertyValue(new PropertyValue(MODULE_ID, moduleId));
+ bd.getPropertyValues().addPropertyValue(new PropertyValue(SCA_ADAPTER, scaAdapter));
+ parent.registerBeanDefinition(SCA_COMPOSITE_BEAN_NAME, bd);
+ parent.refresh();
+ return parent;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..878267813a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaNamespaceHandler.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Handler for the &lt;sca:&gt; namespace. Handles: <ul> <li>&lt;sca:composite module="xxxxx"/&gt;</li>
+ * <li>&lt;sca:reference name="xxx" type="yyy" default-service="zzz"/&gt;</li> <li>&lt;sca:property name="xxx"
+ * type="yyy"/&gt;</li> <li>&lt;sca:service name="xxx" type="yyyy" target="zzz"/&gt; </ul>
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaNamespaceHandler extends NamespaceHandlerSupport {
+
+ public ScaNamespaceHandler() {
+ // FIXME JFM
+ init();
+ }
+
+ public final void init() {
+ registerBeanDefinitionParser("composite", new ScaCompositeBeanDefinitionParser());
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..55413b69da
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.sca.ScaPropertyProxyFactoryBean;
+
+/**
+ * Parser for the &lt;sca:property/&gt; element
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaPropertyBeanDefinitionParser implements BeanDefinitionParser {
+
+ private static final String PROPERTY_NAME_ATTRIBUTE = "name";
+ private static final String PROPERTY_NAME_PROPERTY = "propertyName";
+ private static final String PROPERTY_TYPE_PROPERTY = "propertyType";
+ private static final String TYPE_ATTRIBUTE = "type";
+ private static final String ID_ATTRIBUTE = "id";
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ // needs service type, reference name, sca component, and optionally default service name
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ String beanName = element.getAttribute(ID_ATTRIBUTE);
+ BeanDefinition beanDef = createBeanDefinition(element);
+ registry.registerBeanDefinition(beanName, beanDef);
+ return beanDef;
+ }
+
+ private BeanDefinition createBeanDefinition(Element element) {
+ RootBeanDefinition beanDefinition = new RootBeanDefinition();
+ beanDefinition.setBeanClass(ScaPropertyProxyFactoryBean.class);
+ MutablePropertyValues props = new MutablePropertyValues();
+ props.addPropertyValue(PROPERTY_NAME_PROPERTY, element.getAttribute(PROPERTY_NAME_ATTRIBUTE));
+ props.addPropertyValue(PROPERTY_TYPE_PROPERTY, element.getAttribute(TYPE_ATTRIBUTE));
+ beanDefinition.setPropertyValues(props);
+ return beanDefinition;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..4f4d196571
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.sca.ScaServiceProxyFactoryBean;
+
+/**
+ * Parser for the &lt;sca:reference&gt; element
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaReferenceBeanDefinitionParser implements BeanDefinitionParser {
+
+ private static final String REFERENCE_NAME_ATTRIBUTE = "name";
+ private static final String REFERENCE_NAME_PROPERTY = "referenceName";
+ private static final String TYPE_ATTRIBUTE = "type";
+ private static final String SERVICE_TYPE_PROPERTY = "serviceType";
+ private static final String DEFAULT_SERVICE_ATTRIBUTE = "default";
+ private static final String DEFAULT_SERVICE_PROPERTY = "defaultServiceName";
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ // needs service type, reference name, sca component, and optionally default service name
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ String referenceName = element.getAttribute(REFERENCE_NAME_ATTRIBUTE);
+ BeanDefinition beanDef = createBeanDefinition(element);
+ registry.registerBeanDefinition(referenceName, beanDef);
+ return beanDef;
+ }
+
+ private BeanDefinition createBeanDefinition(Element element) {
+ RootBeanDefinition beanDefinition = new RootBeanDefinition();
+ beanDefinition.setBeanClass(ScaServiceProxyFactoryBean.class);
+ MutablePropertyValues props = new MutablePropertyValues();
+ props.addPropertyValue(REFERENCE_NAME_PROPERTY, element.getAttribute(REFERENCE_NAME_ATTRIBUTE));
+ props.addPropertyValue(SERVICE_TYPE_PROPERTY, element.getAttribute(TYPE_ATTRIBUTE));
+ if (element.hasAttribute(DEFAULT_SERVICE_ATTRIBUTE)) {
+ props.addPropertyValue(DEFAULT_SERVICE_PROPERTY, element.getAttribute(DEFAULT_SERVICE_ATTRIBUTE));
+ }
+ beanDefinition.setPropertyValues(props);
+ return beanDefinition;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..5867236faa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/config/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 10-Apr-2006 by Adrian Colyer
+ */
+package org.springframework.sca.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.sca.ScaServiceExporter;
+
+/**
+ * Parser for the &lt;sca:service/&gt; element
+ *
+ * @author Adrian Colyer
+ * @since 2.0
+ */
+public class ScaServiceBeanDefinitionParser implements BeanDefinitionParser {
+
+ private static final String SERVICE_NAME_ATTRIBUTE = "name";
+ private static final String TYPE_ATTRIBUTE = "type";
+ private static final String TARGET_ATTRIBUTE = "target";
+ private static final String SERVICE_NAME_PROPERTY = "serviceName";
+ private static final String SERVICE_TYPE_PROPERTY = "serviceType";
+ private static final String TARGET_PROPERTY = "target";
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ String serviceName = element.getAttribute(SERVICE_NAME_ATTRIBUTE);
+ BeanDefinition beanDef = createBeanDefinition(element);
+ registry.registerBeanDefinition(serviceName, beanDef);
+ return beanDef;
+ }
+
+ private BeanDefinition createBeanDefinition(Element element) {
+ RootBeanDefinition beanDefinition = new RootBeanDefinition();
+ beanDefinition.setBeanClass(ScaServiceExporter.class);
+ MutablePropertyValues props = new MutablePropertyValues();
+ props.addPropertyValue(SERVICE_TYPE_PROPERTY, element.getAttribute(TYPE_ATTRIBUTE));
+ props.addPropertyValue(TARGET_PROPERTY, new RuntimeBeanReference(element.getAttribute(TARGET_ATTRIBUTE)));
+ props.addPropertyValue(SERVICE_NAME_PROPERTY, element.getAttribute(SERVICE_NAME_ATTRIBUTE));
+ beanDefinition.setPropertyValues(props);
+ return beanDefinition;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/intercept/OneWayAdvisor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/intercept/OneWayAdvisor.java
new file mode 100644
index 0000000000..60bf2a344d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/intercept/OneWayAdvisor.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.sca.intercept;
+
+import java.lang.reflect.Method;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.aop.framework.ReflectiveMethodInvocation;
+import org.springframework.aop.support.DefaultPointcutAdvisor;
+import org.springframework.aop.support.StaticMethodMatcherPointcut;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.sca.metadata.ServiceMetadata;
+
+/**
+ * An AOP Alliance MethodInterceptor, rather than AspectJ aspect, as there's no value in typed pointcuts. Oh, if it were
+ * only annotations...
+ *
+ * @author Rod Johnson
+ */
+
+public class OneWayAdvisor extends DefaultPointcutAdvisor {
+
+ private TaskExecutor taskExecutor;
+
+ private final ServiceMetadata smd;
+
+ public OneWayAdvisor(final ServiceMetadata aSmd, TaskExecutor taskExecutor) {
+ this.smd = aSmd;
+ setPointcut(new StaticMethodMatcherPointcut() {
+ public boolean matches(Method method, Class targetClass) {
+ for (Method m : smd.getOneWayMethods()) {
+ if (m.getName().equals(method.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+ setAdvice(new OneWayInterceptor());
+ this.taskExecutor = taskExecutor;
+ }
+
+
+ private class OneWayInterceptor implements MethodInterceptor {
+ public Object invoke(MethodInvocation mi) throws Throwable {
+ try {
+ // TODO this is not right
+ ReflectiveMethodInvocation rmi = (ReflectiveMethodInvocation) mi;
+ final MethodInvocation clone = rmi.invocableClone();
+ System.out.println("EXECUTE DEFERRED");
+ taskExecutor.execute(new Runnable() {
+ public void run() {
+ try {
+ clone.proceed();
+ } catch (Throwable ex) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+ }
+ });
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return null;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/AnnotationServiceMetadata.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/AnnotationServiceMetadata.java
new file mode 100644
index 0000000000..9a04831ab8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/AnnotationServiceMetadata.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.sca.metadata;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Service;
+
+import org.springframework.util.ReflectionUtils;
+
+/**
+ * TODO not the way to get this
+ *
+ * @author Rod Johnson
+ */
+public class AnnotationServiceMetadata implements ServiceMetadata {
+
+ private final String name;
+
+ private final Class<?> serviceClass;
+
+ public AnnotationServiceMetadata(String name, Class<?> serviceClass) throws NoSuchServiceException {
+ if (!serviceClass.isAnnotationPresent(Service.class)) {
+ throw new NoSuchServiceException();
+ }
+ this.name = name;
+ this.serviceClass = serviceClass;
+ }
+
+ public String getServiceName() {
+ return name;
+ }
+
+ public Class<?>[] getServiceInterfaces() {
+ return serviceClass.getAnnotation(Service.class).interfaces();
+ }
+
+ public List<Method> getOneWayMethods() {
+ List<Method> oneWayMethods = new LinkedList<Method>();
+ for (Method m : serviceClass.getMethods()) {
+ if (m.isAnnotationPresent(OneWay.class)) {
+ oneWayMethods.add(m);
+ }
+ }
+
+ // TODO fields
+
+ return oneWayMethods;
+ }
+
+ public List<Injection> getInjections() {
+ final List<Injection> injections = new LinkedList<Injection>();
+ for (Method m : serviceClass.getMethods()) {
+ if (m.isAnnotationPresent(Property.class)) {
+ injections.add(new MethodInjection(m));
+ }
+ }
+
+ // TODO fields propertly
+
+ ReflectionUtils.doWithFields(serviceClass, new ReflectionUtils.FieldCallback() {
+ public void doWith(Field f) throws IllegalArgumentException {
+ if (f.isAnnotationPresent(ComponentName.class)) {
+ Injection componentNameInjection = new FieldInjection(f);
+ componentNameInjection.setLiteralValue(name);
+ injections.add(componentNameInjection);
+ }
+ }
+ });
+
+ return injections;
+ }
+
+ // TODO reference
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/BeanFactoryDeploymentMetadata.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/BeanFactoryDeploymentMetadata.java
new file mode 100644
index 0000000000..b819ad8f8d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/BeanFactoryDeploymentMetadata.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.sca.metadata;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+
+/**
+ * DeploymentMetadata implementation backed by Spring BeanFactory metadata
+ *
+ * @author Rod Johnson
+ */
+public class BeanFactoryDeploymentMetadata implements BeanFactoryAware, DeploymentMetadata {
+
+ private BeanFactory beanFactory;
+
+ private Map<String, ServiceMetadata> serviceNameToMetadataMap = new HashMap<String, ServiceMetadata>();
+
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = beanFactory;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.sca.metadata.DeploymentMetadata#getServiceMetadata(java.lang.String)
+ */
+ public synchronized ServiceMetadata getServiceMetadata(String serviceName) throws NoSuchServiceException {
+ ServiceMetadata sm = serviceNameToMetadataMap.get(serviceName);
+ if (sm == null) {
+ Class clazz = beanFactory.getType(serviceName);
+ sm = new AnnotationServiceMetadata(serviceName, clazz);
+ serviceNameToMetadataMap.put(serviceName, sm);
+ }
+ return sm;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/DeploymentMetadata.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/DeploymentMetadata.java
new file mode 100644
index 0000000000..950e5e3786
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/DeploymentMetadata.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.sca.metadata;
+
+/**
+ * Source of ServiceMetadata by name
+ *
+ * @author Rod Johnson
+ */
+public interface DeploymentMetadata {
+
+ ServiceMetadata getServiceMetadata(String serviceName) throws NoSuchServiceException;
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/FieldInjection.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/FieldInjection.java
new file mode 100644
index 0000000000..3d9f1b6e79
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/FieldInjection.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.sca.metadata;
+
+import java.lang.reflect.Field;
+
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * @author Rod Johnson
+ */
+public class FieldInjection extends Injection {
+
+ private final Field field;
+
+ public FieldInjection(Field field, String lookupName) {
+ super(lookupName);
+ this.field = field;
+ }
+
+ public FieldInjection(Field field) {
+ Reference annotation = field.getAnnotation(Reference.class);
+
+ this.field = field;
+
+ if (annotation == null) {
+ //throw new IllegalArgumentException("Field " + field + " not annotated");
+ return;
+ }
+
+ if ("".equals(annotation.name())) {
+ setLookupName(field.getName());
+ } else {
+ setLookupName(annotation.name());
+ }
+ }
+
+ @Override
+ protected void injectValue(Object target, Object value) {
+ try {
+ if (!field.isAccessible()) {
+ field.setAccessible(true);
+ }
+ field.set(target, value);
+ } catch (IllegalArgumentException ex) {
+ // TODO
+ throw new UnsupportedOperationException();
+ } catch (IllegalAccessException ex) {
+ // TODO
+ ex.printStackTrace();
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/Injection.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/Injection.java
new file mode 100644
index 0000000000..2e81516d56
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/Injection.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.sca.metadata;
+
+import org.springframework.beans.factory.BeanFactory;
+
+/**
+ * @author Rod Johnson
+ */
+public abstract class Injection {
+
+ private String lookupName;
+
+ /**
+ * Is it a literal value?
+ */
+ private boolean literal;
+
+ /**
+ * Literal value if it's a literal
+ */
+ private Object literalValue;
+
+ protected Injection() {
+
+ }
+
+ protected Injection(String lookupName) {
+ this.lookupName = lookupName;
+ }
+
+ public Object getLiteralValue() {
+ return literalValue;
+ }
+
+ public void setLiteralValue(Object literalValue) {
+ this.literal = true;
+ this.literalValue = literalValue;
+ }
+
+ public boolean isLiteral() {
+ return literal;
+ }
+
+ protected void setLookupName(String lookupName) {
+ this.lookupName = lookupName;
+ }
+
+ public String getLookupName() {
+ return lookupName;
+ }
+
+ public void apply(BeanFactory owner, Object target) {
+ Object value = literalValue;
+ if (!isLiteral()) {
+ value = owner.getBean(lookupName);
+ }
+ injectValue(target, value);
+ }
+
+ protected abstract void injectValue(Object target, Object value);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/MethodInjection.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/MethodInjection.java
new file mode 100644
index 0000000000..df01d1428d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/MethodInjection.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.sca.metadata;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.osoa.sca.annotations.Property;
+
+/**
+ * @author Rod Johnson
+ */
+public class MethodInjection extends Injection {
+
+ private final Method method;
+
+ public MethodInjection(Method method, String lookupName) {
+ super(lookupName);
+ this.method = method;
+ }
+
+ public MethodInjection(Method method) {
+ // TODO reference also
+ Property annotation = method.getAnnotation(Property.class);
+ if (annotation == null) {
+ throw new IllegalArgumentException("Method " + method + " not annotated");
+ }
+ this.method = method;
+ if ("".equals(annotation.name())) {
+ setLookupName(method.getName());
+ } else {
+ setLookupName(annotation.name());
+ }
+ }
+
+ @Override
+ protected void injectValue(Object target, Object value) {
+ try {
+ method.invoke(target, value);
+ } catch (IllegalArgumentException ex) {
+ // TODO
+ throw new UnsupportedOperationException();
+ } catch (IllegalAccessException ex) {
+ // TODO
+ throw new UnsupportedOperationException();
+ } catch (InvocationTargetException ex) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/NoSuchServiceException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/NoSuchServiceException.java
new file mode 100644
index 0000000000..b7ffdfeee6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/NoSuchServiceException.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.sca.metadata;
+
+/**
+ * @author Rod Johnson
+ */
+public class NoSuchServiceException extends Exception {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/ServiceMetadata.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/ServiceMetadata.java
new file mode 100644
index 0000000000..5d23c499e4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/java/org/springframework/sca/metadata/ServiceMetadata.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.sca.metadata;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * Metadata for an SCA component.
+ *
+ * @author Rod Johnson
+ */
+public interface ServiceMetadata {
+
+ /**
+ * Return the service name
+ *
+ * @return the service name of the component
+ */
+ String getServiceName();
+
+ /**
+ * Return the service interfaces implemented by the component
+ *
+ * @return interfaces implemented by the component
+ */
+ Class<?>[] getServiceInterfaces();
+
+ /**
+ * Return a list of OneWay methods
+ *
+ * @return never returns null
+ */
+ List<Method> getOneWayMethods();
+
+ /**
+ * Return a list of SCA injections
+ * @return a list of SCA injections. Never returns null.
+ */
+ List<Injection> getInjections();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/sca/spring.system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/sca/spring.system.scdl
new file mode 100644
index 0000000000..cbd7138f0d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/sca/spring.system.scdl
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<!--
+ Spring implementation extension configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="org.apache.tuscany.launcher.SpringImplementation">
+
+ <component name="spring.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.spring.impl.SpringImplementationLoader"/>
+ </component>
+
+ <component name="spring.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.spring.impl.SpringComponentTypeLoader"/>
+ </component>
+
+ <component name="spring.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.spring.impl.SpringCompositeBuilder"/>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.handlers b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..689b49e2ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1,3 @@
+http\://www.springframework.org/schema/sca=org.springframework.sca.config.ScaNamespaceHandler
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.schemas b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..33f7004be9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/sca/spring-sca.xsd=org/springframework/sca/xml/spring-sca.xsd
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/org/springframework/sca/xml/spring-sca.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
new file mode 100644
index 0000000000..b4eeadbb74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xsd:schema xmlns="http://www.springframework.org/schema/sca"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified"
+ elementFormDefault="qualified"
+ targetNamespace="http://www.springframework.org/schema/sca">
+
+ <xsd:element name="composite">
+ <xsd:complexType>
+ <xsd:attribute name="component" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="sca-adapter-class" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="reference">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="default" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="service">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="type" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="target" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
new file mode 100644
index 0000000000..80b22d6784
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.container.spring.config.ScaApplicationContext;
+import org.apache.tuscany.container.spring.mock.TestReference;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.sca.ScaServiceExporter;
+import org.springframework.sca.ScaServiceProxyFactoryBean;
+
+/**
+ * Tests the SCA extensible schema elements for Spring's XML configuration files
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public class SpringConfigSchemaTestCase extends TestCase {
+
+ private ConfigurableApplicationContext applicationContext;
+
+ public void setUp() {
+ applicationContext =
+ new ScaApplicationContext(null,
+ new ClassPathResource("org/apache/tuscany/container/spring/SpringConfigSchemaTest.xml"), null);
+ }
+
+ public void testSCAService() {
+ ScaServiceExporter service = (ScaServiceExporter) applicationContext.getBean("fooService");
+ // FIXME andyp -- this is not really right.
+// TestBean service = (TestBean) applicationContext.getBean("fooService");
+// assertEquals("call me", service.echo("call me"));
+ }
+
+ public void testSCAReference() {
+ ScaServiceProxyFactoryBean pf = (ScaServiceProxyFactoryBean) applicationContext.getBean("&fooReference");
+ assertEquals("fooReference", pf.getReferenceName());
+ TestReference ref = (TestReference) applicationContext.getBean("fooReference");
+// assertNotNull(ref);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
new file mode 100644
index 0000000000..3d07c753de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.container.spring.mock.TestBeanImpl;
+import org.apache.tuscany.test.ArtifactFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.support.GenericApplicationContext;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+
+public final class SpringTestUtils {
+ private SpringTestUtils() {
+ }
+
+ public static <T> Service createService(String name,
+ Class<T> serviceInterface,
+ CompositeComponent parent,
+ WireService wireService) throws InvalidServiceContractException {
+ Service service = new ServiceExtension(name, serviceInterface, parent, wireService);
+ InboundWire inboundWire = ArtifactFactory.createInboundWire(name, serviceInterface);
+ OutboundWire outboundWire = ArtifactFactory.createOutboundWire(name, serviceInterface);
+ ArtifactFactory.terminateWire(outboundWire);
+ service.setInboundWire(inboundWire);
+ service.setOutboundWire(outboundWire);
+ outboundWire.setTargetName(new QualifiedName("foo"));
+ Connector connector = ArtifactFactory.createConnector();
+ connector.connect(service);
+ ArtifactFactory.terminateWire(inboundWire);
+ return service;
+ }
+
+
+ public static GenericApplicationContext createContext() {
+ GenericApplicationContext ctx = new GenericApplicationContext();
+ BeanDefinition definition = new RootBeanDefinition(TestBeanImpl.class);
+ ctx.registerBeanDefinition("foo", definition);
+ return ctx;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java
new file mode 100644
index 0000000000..ff5a564ee8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceInvocationTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.spi.component.Reference;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.container.spring.mock.TestBean;
+import org.apache.tuscany.container.spring.mock.TestBeanImpl;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.StaticApplicationContext;
+
+/**
+ * Verifies wiring from a Spring bean to an SCA composite reference
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ReferenceInvocationTestCase extends TestCase {
+
+ public void testInvocation() throws Exception {
+ AbstractApplicationContext ctx = createSpringContext();
+ SpringCompositeComponent parent = new SpringCompositeComponent("spring", ctx, null, null, null);
+ parent.start();
+ TestBean referenceTarget = new TestBeanImpl();
+ Reference reference = createMock(Reference.class);
+ expect(reference.getName()).andReturn("bar").anyTimes();
+ expect(reference.isSystem()).andReturn(false).atLeastOnce();
+ expect(reference.getInterface()).andStubReturn(TestBean.class);
+ expect(reference.getServiceInstance()).andStubReturn(referenceTarget);
+ replay(reference);
+ parent.register(reference);
+ ctx.getBean("foo");
+ }
+
+ private AbstractApplicationContext createSpringContext() {
+ StaticApplicationContext beanFactory = new StaticApplicationContext();
+ RootBeanDefinition definition = new RootBeanDefinition(TestBeanImpl.class);
+ //REVIEW we need to figure out how to handle eager init components
+ definition.setLazyInit(true);
+ RuntimeBeanReference ref = new RuntimeBeanReference("bar");
+ PropertyValue val = new PropertyValue("bean", ref);
+ definition.getPropertyValues().addPropertyValue(val);
+ beanFactory.registerBeanDefinition("foo", definition);
+ return beanFactory;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
new file mode 100644
index 0000000000..596d9f1181
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.QualifiedName;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.container.spring.mock.TestBean;
+import org.apache.tuscany.container.spring.mock.TestBeanImpl;
+import org.apache.tuscany.test.ArtifactFactory;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.StaticApplicationContext;
+
+/**
+ * Tests a simple invocation through a service to a Spring bean
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ServiceInvocationTestCase extends TestCase {
+
+ public void testInvocation() throws InvalidServiceContractException {
+ AbstractApplicationContext springContext = createSpringContext();
+ SpringCompositeComponent composite = new SpringCompositeComponent("parent", springContext, null, null, null);
+ InboundWire inboundWire = ArtifactFactory.createInboundWire("fooService", TestBean.class);
+ OutboundWire outboundWire = ArtifactFactory.createOutboundWire("fooService", TestBean.class);
+ outboundWire.setTargetName(new QualifiedName("foo"));
+ ArtifactFactory.terminateWire(outboundWire);
+ Service service =
+ new ServiceExtension("fooService", TestBean.class, composite, createWireService());
+ service.setInboundWire(inboundWire);
+ service.setOutboundWire(outboundWire);
+ Connector connector = ArtifactFactory.createConnector();
+ connector.connect(inboundWire, outboundWire, true);
+ for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
+ chain.setTargetInvoker(composite.createTargetInvoker("foo", chain.getOperation()));
+ }
+ composite.register(service);
+ TestBean serviceInstance = (TestBean) composite.getService("fooService").getServiceInstance();
+ assertEquals("bar", serviceInstance.echo("bar"));
+ }
+
+
+ private AbstractApplicationContext createSpringContext() {
+ StaticApplicationContext beanFactory = new StaticApplicationContext();
+ RootBeanDefinition definition = new RootBeanDefinition(TestBeanImpl.class);
+ definition.setLazyInit(true);
+ beanFactory.registerBeanDefinition("foo", definition);
+ return beanFactory;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java
new file mode 100644
index 0000000000..50ce9a7b75
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import static org.apache.tuscany.container.spring.SpringTestUtils.createContext;
+import org.apache.tuscany.container.spring.mock.TestBean;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.container.spring.model.SpringImplementation;
+import org.apache.tuscany.test.ArtifactFactory;
+import org.apache.tuscany.test.binding.TestBinding;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringCompositeBuilderTestCase extends TestCase {
+
+ /**
+ * Verfies basic build of a spring context
+ */
+ @SuppressWarnings("unchecked")
+ public void testBuild() throws Exception {
+ // Create an assembly model consisting of a component implemented by Spring
+ SpringImplementation impl = new SpringImplementation(new SpringComponentType(createContext()));
+ ComponentDefinition<SpringImplementation> componentDefinition =
+ new ComponentDefinition<SpringImplementation>("spring", impl);
+
+ // Configure the mock builder registry
+ BuilderRegistry registry = createNiceMock(BuilderRegistry.class);
+
+ // Test the SpringCompositeBuilder
+ SpringCompositeBuilder builder = new SpringCompositeBuilder();
+ builder.setBuilderRegistry(registry);
+ CompositeComponent parent = createNiceMock(CompositeComponent.class);
+ DeploymentContext context = createNiceMock(DeploymentContext.class);
+ SpringCompositeComponent component =
+ (SpringCompositeComponent) builder.build(parent, componentDefinition, context);
+ TestBean bean = (TestBean) component.getApplicationContext().getBean("foo");
+ assertEquals("call foo", bean.echo("call foo"));
+ }
+
+ /**
+ * Verifies that the builder calls back into the registry to load services and wires them to bean targets when no
+ * <code>sca:service</code> tag is specified in the Spring application.xml
+ */
+ @SuppressWarnings("unchecked")
+ public void testImplicitServiceWiring() throws Exception {
+ // Create an assembly model consisting of a component implemented by Spring
+ SpringImplementation impl = new SpringImplementation(createComponentType());
+ ComponentDefinition<SpringImplementation> componentDefinition =
+ new ComponentDefinition<SpringImplementation>("spring", impl);
+
+ // Create a service instance that the mock builder registry will return
+ WireService wireService = ArtifactFactory.createWireService();
+ ServiceExtension serviceContext =
+ new ServiceExtension("fooService", TestBean.class, null, wireService);
+ InboundWire inboundWire = ArtifactFactory.createInboundWire("fooService", TestBean.class);
+ OutboundWire outboundWire = ArtifactFactory.createOutboundWire("fooService", TestBean.class);
+ ArtifactFactory.terminateWire(outboundWire);
+ serviceContext.setInboundWire(inboundWire);
+ serviceContext.setOutboundWire(outboundWire);
+ Connector connector = ArtifactFactory.createConnector();
+ connector.connect(inboundWire, outboundWire, true);
+
+ // Configure the mock builder registry
+ BuilderRegistry registry = createMock(BuilderRegistry.class);
+ expect(registry.build(isA(CompositeComponent.class),
+ isA(BoundServiceDefinition.class),
+ isA(DeploymentContext.class))).andStubReturn(serviceContext);
+ replay(registry);
+
+ // Test the SpringCompositeBuilder
+ SpringCompositeBuilder builder = new SpringCompositeBuilder();
+ builder.setWireService(wireService);
+ builder.setBuilderRegistry(registry);
+ CompositeComponent parent = createNiceMock(CompositeComponent.class);
+ DeploymentContext context = createNiceMock(DeploymentContext.class);
+ CompositeComponent component = (CompositeComponent) builder.build(parent, componentDefinition, context);
+ Service service = component.getService("fooService");
+ TestBean bean = (TestBean) service.getServiceInstance();
+ assertEquals("call foo", bean.echo("call foo"));
+ verify(registry);
+ }
+
+ @SuppressWarnings("unchecked")
+ private SpringComponentType createComponentType() {
+ SpringComponentType componentType = new SpringComponentType(createContext());
+ BoundServiceDefinition<TestBinding> serviceDefinition = new BoundServiceDefinition<TestBinding>();
+ serviceDefinition.setName("fooService");
+ serviceDefinition.setBinding(new TestBinding());
+ try {
+ serviceDefinition.setTarget(new URI("foo"));
+ } catch (URISyntaxException e) {
+ throw new AssertionError();
+ }
+ componentType.add(serviceDefinition);
+ return componentType;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java
new file mode 100644
index 0000000000..f3ac13d030
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.spi.component.Service;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.expect;
+import org.easymock.classextension.EasyMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringCompositeComponentTestCase extends TestCase {
+
+ public void testAppContextStart() {
+ AbstractApplicationContext appContext = EasyMock.createMock(AbstractApplicationContext.class);
+ appContext.refresh();
+ appContext.setParent(EasyMock.isA(ApplicationContext.class));
+ appContext.start();
+ replay(appContext);
+ SpringCompositeComponent component = new SpringCompositeComponent("spring", appContext, null, null, null);
+ component.start();
+ verify(appContext);
+ }
+
+ public void testChildStart() {
+ AbstractApplicationContext appContext = EasyMock.createNiceMock(AbstractApplicationContext.class);
+ replay(appContext);
+ Service service = EasyMock.createMock(Service.class);
+ EasyMock.expect(service.getName()).andReturn("foo").anyTimes();
+ service.start();
+ service.getInterface();
+ EasyMock.expectLastCall().andReturn(Object.class);
+ expect(service.isSystem()).andReturn(false).atLeastOnce();
+ replay(service);
+ SpringCompositeComponent component = new SpringCompositeComponent("spring", appContext, null, null, null);
+ component.register(service);
+ component.start();
+ verify(service);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java
new file mode 100644
index 0000000000..b110852a54
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.impl;
+
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Verifies a simple invocation on a Spring bean
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringInvocationTestCase extends TestCase {
+
+ /**
+ * Verifies the invoker can resolve a bean in an application context and call a method l
+ */
+ public void testInvocation() throws Exception {
+ TestBean bean = createMock(TestBean.class);
+ bean.test("bar");
+ expectLastCall();
+ replay(bean);
+ ApplicationContext context = createMock(ApplicationContext.class);
+ expect(context.getBean("foo")).andReturn(bean);
+ replay(context);
+ SpringInvoker invoker = new SpringInvoker("foo", TestBean.class.getMethod("test", String.class), context);
+ Message msg = new MessageImpl();
+ msg.setBody(new String[]{"bar"});
+ invoker.invoke(msg);
+ verify(context);
+ verify(bean);
+ }
+
+
+ private interface TestBean {
+ void test(String msg);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/integration/BootstrapTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/integration/BootstrapTestCase.java
new file mode 100644
index 0000000000..c5758cb2ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/integration/BootstrapTestCase.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.integration;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import org.apache.tuscany.spi.component.Service;
+
+import org.apache.tuscany.container.spring.impl.SpringCompositeComponent;
+import org.apache.tuscany.container.spring.mock.TestBean;
+import org.apache.tuscany.test.Bootstrapper;
+
+/**
+ * Bootstraps a simple scenario where a service can invoke a Spring bean. This test case is intended to be temporary and
+ * replaced when the SPI test harness is finished.
+ * <p/>
+ * <bold>PLEASE DO NOT EMULATE</bold>
+ *
+ * @version $Rev$ $Date$
+ */
+public class BootstrapTestCase extends Bootstrapper {
+
+ private CompositeContext context;
+
+ public void testDemoBoot() {
+ SpringCompositeComponent comp = (SpringCompositeComponent) component.getChild("Spring");
+ Service service = (Service) comp.getChild("fooService");
+ TestBean bean = (TestBean) service.getServiceInstance();
+ bean.echo("foo");
+ bean.getBean().echo("foo");
+ }
+
+ protected void setUp() throws Exception {
+ addExtension("spring.extension", getClass().getClassLoader().getResource("META-INF/sca/spring.system.scdl"));
+ super.setUp();
+ context = CurrentCompositeContext.getContext();
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java
new file mode 100644
index 0000000000..1c768e53cc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface TestBean {
+ String echo(String msg);
+
+ TestBean getBean();
+
+ void setBean(TestBean bean);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java
new file mode 100644
index 0000000000..db04d8bcad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class TestBeanImpl implements TestBean {
+
+ private TestBean bean;
+
+ public TestBeanImpl() {
+ }
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public TestBean getBean() {
+ return bean;
+ }
+
+ public void setBean(TestBean bean) {
+ this.bean = bean;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java
new file mode 100644
index 0000000000..7d1a519be6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.spring.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface TestReference {
+ String echo(String msg);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/application-context.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/application-context.xml
new file mode 100644
index 0000000000..6ccd3963a9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/application-context.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd">
+
+ <bean id="testBean" class="org.apache.tuscany.container.spring.mock.TestBeanImpl" lazy-init="true">
+ <property name="bean" ref="testReference"/>
+ </bean>
+ <!-- <sca:reference name="testReference" type="org.apache.tuscany.container.spring.mock.TestReference"/> -->
+
+</beans>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..0b2c92c667
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/META-INF/sca/default.scdl
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="spring.test">
+
+ <component name="Spring">
+ <implementation.spring location="META-INF/sca/application-context.xml">
+ <service name="fooService">
+ <binding.test/>
+ <interface.java class="org.apache.tuscany.container.spring.mock.TestBean"/>
+ <reference>testBean</reference>
+ </service>
+ <reference name="testReference">
+ <interface.java class="org.apache.tuscany.container.spring.mock.TestBean"/>
+ <binding.test/>
+ </reference>
+ </implementation.spring>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/ExplicitSpring.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/ExplicitSpring.xml
new file mode 100644
index 0000000000..211211511b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/ExplicitSpring.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd">
+
+ <sca:service name="fooBean" type="org.apache.tuscany.container.spring.mock.TestBeanImpl" target="testBean"/>
+
+ <bean id="testBean" class="org.apache.tuscany.container.spring.mock.TestBeanImpl">
+ </bean>
+
+</beans>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/SpringConfigSchemaTest.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/SpringConfigSchemaTest.xml
new file mode 100644
index 0000000000..96a3e1ed46
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/org/apache/tuscany/container/spring/SpringConfigSchemaTest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd">
+
+ <bean id="testBean" class="org.apache.tuscany.container.spring.mock.TestBeanImpl">
+ </bean>
+
+ <sca:service name="fooService" type="org.apache.tuscany.container.spring.mock.TestBean" target="testBean"/>
+
+ <sca:reference name="fooReference" type="org.apache.tuscany.container.spring.mock.TestReference"/>
+
+
+</beans>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/test.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/test.xml
new file mode 100644
index 0000000000..d438b88577
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.spring/src/test/resources/test.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd">
+
+ <bean id="testBean" class="org.apache.tuscany.container.spring.mock.TestBeanImpl"/>
+
+</beans>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/pom.xml
new file mode 100644
index 0000000000..4bd5db50a5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Containers</name>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>container.groovy</module>
+ <module>container.javascript</module>
+ <module>container.ruby</module>
+ <module>container.spring</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>release</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>container.javascript</module>
+ <module>container.ruby</module>
+ <module>container.spring</module>
+ </modules>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/pom.xml
new file mode 100755
index 0000000000..c92cb94b88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>databinding-axiom</artifactId>
+ <name>Apache Tuscany Data Binding for Axiom</name>
+ <description>Tuscany Axiom Data Binding</description>
+
+ <repositories>
+ <repository>
+ <id>apache.m1.snapshots</id>
+ <name>Apache M1 Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m1-snapshot-repository</url>
+ <layout>legacy</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java
new file mode 100644
index 0000000000..6a43d25847
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.axiom;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * DataBinding for AXIOM
+ */
+@Service(DataBinding.class)
+public class AxiomDataBinding extends DataBindingExtension {
+
+ public static final String NAME = OMElement.class.getName();
+
+ public AxiomDataBinding() {
+ super(OMElement.class);
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.extension.DataBindingExtension#getWrapperHandler()
+ */
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return new OMElementWrapperHandler();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java
new file mode 100644
index 0000000000..91b1f4da90
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.SimpleType2JavaTransformer;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transformer to convert data from a simple java bject to OMElement
+ */
+@Service(Transformer.class)
+public class OMElement2Object extends SimpleType2JavaTransformer<OMElement> {
+
+ @Override
+ protected String getText(OMElement source) {
+ return source.getText();
+ }
+
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java
new file mode 100755
index 0000000000..52be08537d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transformer to convert data from an OMElement to XML String
+ */
+@Service(Transformer.class)
+public class OMElement2String extends TransformerExtension<OMElement, String> implements PullTransformer<OMElement, String> {
+ // private XmlOptions options;
+
+ public String transform(OMElement source, TransformationContext context) {
+ try {
+ StringWriter writer = new StringWriter();
+ source.serialize(writer);
+ return writer.toString();
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+
+ public Class getTargetType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java
new file mode 100755
index 0000000000..343408a027
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class OMElement2XMLStreamReader extends TransformerExtension<OMElement, XMLStreamReader> implements PullTransformer<OMElement, XMLStreamReader> {
+ // private XmlOptions options;
+
+ public XMLStreamReader transform(OMElement source, TransformationContext context) {
+ return source.getXMLStreamReader();
+ }
+
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java
new file mode 100644
index 0000000000..0ba2863735
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.axiom;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.idl.ElementInfo;
+
+/**
+ * OMElement wrapper handler implementation
+ */
+public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
+
+ private OMFactory factory;
+
+ public OMElementWrapperHandler() {
+ super();
+ this.factory = OMAbstractFactory.getOMFactory();
+ }
+
+ public OMElement create(ElementInfo element, TransformationContext context) {
+ OMElement wrapper = factory.createOMElement(element.getQName(), null);
+ return wrapper;
+ }
+
+ public Object getChild(OMElement wrapper, int i, ElementInfo element) {
+ int index = 0;
+ for (Iterator e = wrapper.getChildElements(); e.hasNext();) {
+ OMElement child = (OMElement) e.next();
+ if (index != i) {
+ index++;
+ continue;
+ }
+ if (child.getQName().equals(element.getQName())) {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ public void setChild(OMElement wrapper, int i, ElementInfo childElement, Object value) {
+ wrapper.addChild((OMElement) value);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java
new file mode 100644
index 0000000000..5416b5239e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.Java2SimpleTypeTransformer;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transformer to convert data from an simple OMElement to Java Object
+ */
+@Service(Transformer.class)
+public class Object2OMElement extends Java2SimpleTypeTransformer<OMElement> {
+
+ private OMFactory factory;
+
+ public Object2OMElement() {
+ super();
+ factory = OMAbstractFactory.getOMFactory();
+ }
+
+ protected OMElement createElement(ElementInfo element, String text, TransformationContext context) {
+ OMElement omElement = factory.createOMElement(element.getQName(), null);
+ factory.createOMText(omElement, text);
+ return omElement;
+ }
+
+ @Override
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java
new file mode 100755
index 0000000000..59ac5423d7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class String2OMElement extends TransformerExtension<String, OMElement> implements
+ PullTransformer<String, OMElement> {
+
+ @SuppressWarnings("unchecked")
+ public OMElement transform(String source, TransformationContext context) {
+ try {
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(source.getBytes()));
+ OMElement element = builder.getDocumentElement();
+ adjustElementName(context, element);
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ private void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object targetQName = dataType == null ? null : dataType.getLogical();
+ if (!(targetQName instanceof QName)) {
+ return;
+ }
+ if (!element.getQName().equals(targetQName)) {
+ // TODO: Throw expection or switch to the new Element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = (QName)targetQName;
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+ public Class getSourceType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java
new file mode 100755
index 0000000000..5b2c89b443
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class XMLStreamReader2OMElement extends TransformerExtension<XMLStreamReader, OMElement> implements
+ PullTransformer<XMLStreamReader, OMElement> {
+
+ public XMLStreamReader2OMElement() {
+ super();
+ }
+
+ public OMElement transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ StAXOMBuilder builder = new StAXOMBuilder(source);
+ OMElement element = builder.getDocumentElement();
+ adjustElementName(context, element);
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ private void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object targetQName = dataType == null ? null : dataType.getLogical();
+ if (!(targetQName instanceof QName)) {
+ return;
+ }
+ if (!element.getQName().equals(targetQName)) {
+ // TODO: Throw expection or switch to the new Element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = (QName)targetQName;
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl
new file mode 100644
index 0000000000..0954b5a90f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!-- This is the copy ot be included by other extensions -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.axiom.include">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="databinding.axiom">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.AxiomDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.String2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.String2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2String" />
+ </component>
+
+ <component name="transformer.Object2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.Object2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2Object">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2Object" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..25e5a04c5c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.axiom">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="databinding.axiom">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.AxiomDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.String2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.String2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2String" />
+ </component>
+
+ <component name="transformer.Object2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.Object2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2Object">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2Object" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/java/org/apache/tuscany/databinding/axiom/OMElementTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/java/org/apache/tuscany/databinding/axiom/OMElementTestCase.java
new file mode 100755
index 0000000000..5a2793225b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/java/org/apache/tuscany/databinding/axiom/OMElementTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.axiom;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMElement;
+
+public class OMElementTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\"" + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">" + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>" + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>" + " </shipTo>" + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>" + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>" + " <state>PA</state>" + " <zip>95819</zip>" + " </billTo>"
+ + " <items>" + " <item partNum=\"833-AA\">" + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>" + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>" + " </item>" + " </items>" + "</ipo:purchaseOrder>";
+
+ public final void testStringTransform() {
+ String2OMElement t1 = new String2OMElement();
+ OMElement element = t1.transform(IPO_XML, null);
+ OMElement2String t2 = new OMElement2String();
+ String xml = t2.transform(element, null);
+ Assert.assertNotNull(xml);
+ Assert.assertNotNull(xml.indexOf("<ipo:comment>") != -1);
+ }
+
+ public final void testStAXTransform() {
+ String2OMElement t1 = new String2OMElement();
+ OMElement element = t1.transform(IPO_XML, null);
+
+ OMElement2XMLStreamReader t2 = new OMElement2XMLStreamReader();
+ XMLStreamReader reader = t2.transform(element, null);
+
+ XMLStreamReader2OMElement t3 = new XMLStreamReader2OMElement();
+ OMElement element2 = t3.transform(reader, null);
+
+ Assert.assertEquals(element2.getQName(), element.getQName());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "purchaseOrder"), element2.getQName());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xml
new file mode 100755
index 0000000000..df901d183d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ipo:purchaseOrder
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ipo="http://www.example.com/IPO"
+ xsi:schemaLocation="http://www.example.com/IPO ipo.xsd"
+ orderDate="1999-12-01">
+
+ <shipTo exportCode="1" xsi:type="ipo:UKAddress">
+ <name>Helen Zoe</name>
+ <street>47 Eden Street</street>
+ <city>Cambridge</city>
+ <postcode>CB1 1JR</postcode>
+ </shipTo>
+
+ <billTo xsi:type="ipo:USAddress">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+
+ <items>
+ <item partNum="833-AA">
+ <productName>Lapis necklace</productName>
+ <quantity>1</quantity>
+ <USPrice>99.95</USPrice>
+ <ipo:comment>Want this for the holidays</ipo:comment>
+ <shipDate>1999-12-05</shipDate>
+ </item>
+ </items>
+</ipo:purchaseOrder>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/order.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/order.wsdl
new file mode 100644
index 0000000000..7634cdebd3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-axiom/src/test/resources/order.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/order.wsdl" xmlns:tns="http://example.com/order.wsdl"
+ xmlns:xsd1="http://example.com/order.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/order.xsd" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd"/>
+ <element name="checkOrderStatus">
+ <complexType>
+ <sequence>
+ <element name="customerId" type="string" />
+ <element name="order" type="ipo:PurchaseOrderType" />
+ <element name="flag" type="int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="checkOrderStatusResponse">
+ <complexType>
+ <sequence>
+ <element name="status" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="note" type="string" />
+ </schema>
+ </types>
+
+ <message name="CheckOrderStatusInput1">
+ <part name="body" element="xsd1:checkOrderStatus" />
+ </message>
+
+ <message name="CheckOrderStatusOutput1">
+ <part name="body" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <message name="CheckOrderStatusInput2">
+ <part name="p1" element="xsd1:checkOrderStatus" />
+ <part name="p2" element="xsd1:note" />
+ </message>
+
+ <message name="CheckOrderStatusOutput2">
+ <part name="p1" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <portType name="OrderPortType">
+ <operation name="checkOrderStatus">
+ <input message="tns:CheckOrderStatusInput1" />
+ <output message="tns:CheckOrderStatusOutput1" />
+ </operation>
+ <operation name="checkOrderStatus2">
+ <input message="tns:CheckOrderStatusInput2" />
+ <output message="tns:CheckOrderStatusOutput2" />
+ </operation>
+ </portType>
+
+</definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/pom.xml
new file mode 100755
index 0000000000..9557263ea7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/pom.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>databinding-castor</artifactId>
+ <name>Apache Tuscany Data Binding for Castor</name>
+ <description>Tuscany Castor Data Binding</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>castor</groupId>
+ <artifactId>castor</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Adding Apache xerces to workaround the castor references for SAX parser -->
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/castor-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-castor</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <tasks>
+ <taskdef name="castor-srcgen"
+ classname="org.exolab.castor.tools.ant.taskdefs.CastorSourceGenTask"
+ classpathref="maven.test.classpath" />
+ <mkdir dir="${project.build.directory}/castor-source"></mkdir>
+ <castor-srcgen file="${basedir}/src/test/resources/ipo.xsd"
+ todir="${project.build.directory}/castor-source" package="com.example.ipo.castor"
+ types="j2" warnings="false" bindingfile="${basedir}/src/test/resources/binding.xml" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java
new file mode 100755
index 0000000000..9ae0335ada
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.exolab.castor.xml.Marshaller;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class Castor2Node<T> extends TransformerExtension<T, Node> implements PullTransformer<T, Node> {
+ private Class<T> type;
+
+ public Castor2Node(Class<T> type) {
+ super();
+ this.type = type;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public Class getSourceType() {
+ return type;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public Node transform(Object source, TransformationContext context) {
+ try {
+ Document document = DOMHelper.newDocument();
+ Marshaller.marshal(source, document);
+ return document;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java
new file mode 100644
index 0000000000..643d6fb4ad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import java.io.Writer;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.exolab.castor.xml.Marshaller;
+
+public class Castor2SAX<T> extends TransformerExtension<T, Writer> implements PushTransformer<T, Writer> {
+ private Class<T> type;
+
+ /**
+ * @param type
+ */
+ public Castor2SAX(Class<T> type) {
+ super();
+ this.type = type;
+ }
+
+ public Class getSourceType() {
+ return type;
+ }
+
+ public Class getTargetType() {
+ return Writer.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public void transform(T source, Writer writer, TransformationContext context) {
+ try {
+ Marshaller.marshal(source, writer);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java
new file mode 100644
index 0000000000..f477273387
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import org.apache.tuscany.spi.databinding.PushTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.exolab.castor.xml.Marshaller;
+import org.xml.sax.ContentHandler;
+
+public class Castor2Writer<T> extends TransformerExtension<T, ContentHandler> implements PushTransformer<T, ContentHandler> {
+ private Class<T> type;
+
+ /**
+ * @param type
+ */
+ public Castor2Writer(Class<T> type) {
+ super();
+ this.type = type;
+ }
+
+ public Class getSourceType() {
+ return type;
+ }
+
+ public Class getTargetType() {
+ return ContentHandler.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public void transform(T source, ContentHandler contentHandler, TransformationContext context) {
+ try {
+ Marshaller.marshal(source, contentHandler);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java
new file mode 100644
index 0000000000..61bac7d20f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.exolab.castor.xml.Unmarshaller;
+import org.xml.sax.InputSource;
+
+public class InputSource2Castor<T> extends TransformerExtension<InputSource, T> implements PullTransformer<InputSource, T> {
+ private Class<T> type;
+
+ /**
+ * @param type
+ */
+ public InputSource2Castor(Class<T> type) {
+ super();
+ this.type = type;
+ }
+
+ public Class getTargetType() {
+ return type;
+ }
+
+ public Class getSourceType() {
+ return InputSource.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public T transform(InputSource source, TransformationContext context) {
+ try {
+ Object object = Unmarshaller.unmarshal(type, source);
+ return type.cast(object);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java
new file mode 100644
index 0000000000..fa5a15b3ba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.exolab.castor.xml.Unmarshaller;
+import org.w3c.dom.Node;
+
+public class Node2Castor<T> extends TransformerExtension<Node, T> implements PullTransformer<Node, T> {
+ private Class<T> type;
+
+ /**
+ * @param type
+ */
+ public Node2Castor(Class<T> type) {
+ super();
+ this.type = type;
+ }
+
+ public Class getTargetType() {
+ return type;
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public T transform(Node source, TransformationContext context) {
+ try {
+ Object object = Unmarshaller.unmarshal(type, source);
+ return type.cast(object);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java
new file mode 100644
index 0000000000..a8ade1bda5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import java.io.Reader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.exolab.castor.xml.Unmarshaller;
+
+public class Reader2Castor<T> extends TransformerExtension<Reader, T> implements PullTransformer<Reader, T> {
+ private Class<T> type;
+
+ /**
+ * @param type
+ */
+ public Reader2Castor(Class<T> type) {
+ super();
+ this.type = type;
+ }
+
+ public Class getTargetType() {
+ return type;
+ }
+
+ public Class getSourceType() {
+ return Reader.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext)
+ */
+ public T transform(Reader source, TransformationContext context) {
+ try {
+ Object object = Unmarshaller.unmarshal(type, source);
+ return type.cast(object);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/java/org/apache/tuscany/databinding/castor/Castor2NodeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/java/org/apache/tuscany/databinding/castor/Castor2NodeTestCase.java
new file mode 100644
index 0000000000..378e89866a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/java/org/apache/tuscany/databinding/castor/Castor2NodeTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.castor;
+
+import junit.framework.TestCase;
+
+public class Castor2NodeTestCase extends TestCase {
+ private static final String IPO_XML = "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\"" + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">" + " <name>Helen Zoe</name>" + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>" + " <postcode>CB1 1JR</postcode>" + " </shipTo>" + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>" + " <street>8 Oak Avenue</street>" + " <city>Old Town</city>" + " <state>PA</state>"
+ + " <zip>95819</zip>" + " </billTo>" + " <items>" + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>" + " <quantity>1</quantity>" + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>" + " <shipDate>1999-12-05</shipDate>" + " </item>" + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ public void testTransform() throws Exception {
+ // FIXME: There's a bug in the castor-generated code which cannot handle subutype correctly
+ // http://jira.codehaus.org/browse/CASTOR-1475
+ // shipTo should be able to accept UKAddress
+// Reader2Castor<PurchaseOrder> t1 = new Reader2Castor<PurchaseOrder>(PurchaseOrder.class);
+// PurchaseOrder po = t1.transform(new StringReader(IPO_XML), null);
+ /*
+ * Castor2Node t2 = new Castor2Node(); Node node = t2.transform(po, null); Assert.assertNotNull(node);
+ */
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/binding.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/binding.xml
new file mode 100755
index 0000000000..3517e71692
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/binding.xml
@@ -0,0 +1,27 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<binding xmlns="http://www.castor.org/SourceGenerator/Binding"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ defaultBinding="type">
+
+ <elementBinding name="complexType:PurchaseOrderType/items">
+ <java-class name="ItemsElement"/>
+ </elementBinding>
+
+</binding>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/org/exolab/castor/builder/castorbuilder.properties b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/org/exolab/castor/builder/castorbuilder.properties
new file mode 100644
index 0000000000..3f9f2eabb7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-castor/src/test/resources/org/exolab/castor/builder/castorbuilder.properties
@@ -0,0 +1,81 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# Property file for SourceCodeGenerator
+#
+# $Id: castorbuilder.properties,v 1.3 2004/05/06 08:20:51 kvisco Exp $
+
+# To enable bound properties uncomment the following line. Please
+# note that currently *all* fields will be treated as bound properties
+# when enabled. This will change in the future when we introduce
+# fine grained control over each class and it's properties.
+#
+#org.exolab.castor.builder.boundproperties=true
+
+# Java class mapping of <xsd:element>'s and <xsd:complexType>'s
+#
+org.exolab.castor.builder.javaclassmapping=type
+
+# This property allows one to specify the super class of *all*
+# generated classes
+#
+#org.exolab.castor.builder.superclass=com.xyz.BaseObject
+
+# XML namespace mapping to Java packages
+#
+#org.exolab.castor.builder.nspackages=\
+ http://www.xyz.com/schemas/project=com.xyz.schemas.project,\
+ http://www.xyz.com/schemas/person=com.xyz.schemas.person
+
+# Set to true if you want to generate the equals method
+# for each generated class
+# false by default
+#
+#org.exolab.castor.builder.equalsmethod=true
+
+# Set to true if you want to use Object Wrappers instead
+# of primitives (e.g Float instead of float).
+# false by default.
+#
+#org.exolab.castor.builder.primitivetowrapper=false
+
+# Set to true if you want the generated class descriptors to
+# expose the element and attribute names they contain.
+# false by default.
+#
+#org.exolab.castor.builder.classdescfieldnames=false
+
+# Set to true if you want the generated source code to contain
+# Extra methods for the collection fields, such as get/set using
+# the collection type in addition to the type-safe array.
+# Set this to true if you want your code to be more compatible
+# with Castor JDO. This is false by default.
+#
+#org.exolab.castor.builder.extraCollectionMethods=true
+
+# Use old-style (Castor 0.9.3.9) of naming that uppercases
+# names after an underscore
+#
+#org.exolab.castor.xml.JavaNaming.upperCaseAfterUnderscore=true
+
+# This property specifies whether generated enumerated type
+# classes implement the EnumeratedTypeAccess interface.
+# false by default
+#org.exolab.castor.builder.enumTypeAccessInterface=true
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/pom.xml
new file mode 100755
index 0000000000..8a76364cca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>databinding-jaxb</artifactId>
+ <name>Apache Tuscany Data Binding for JAXB</name>
+ <description>Tuscany JAXB Data Binding</description>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>https://maven-repository.dev.java.net/nonav/repository</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>https://maven-repository.dev.java.net/repository</url>
+ <layout>legacy</layout>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxb-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>com.sun.tools.xjc.maven2</groupId>
+ <artifactId>maven-jaxb-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>generate-jaxb</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generatePackage>com.example.ipo.jaxb</generatePackage>
+ <generateDirectory>${project.build.directory}/jaxb-source</generateDirectory>
+ <schemaDirectory>${basedir}/src/test/resources</schemaDirectory>
+ <includeSchemas>
+ <includeSchema>ipo.xsd</includeSchema>
+ </includeSchemas>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXB2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXB2Node.java
new file mode 100755
index 0000000000..90855b41b1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXB2Node.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+@Service(Transformer.class)
+public class JAXB2Node extends TransformerExtension<Object, Node> implements PullTransformer<Object, Node> {
+
+ public JAXB2Node() {
+ super();
+ }
+
+ public Node transform(Object source, TransformationContext tContext) {
+ if (source == null)
+ return null;
+ try {
+ JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
+ Marshaller marshaller = context.createMarshaller();
+ // FIXME: The default Marshaller doesn't support
+ // marshaller.getNode()
+ Document document = DOMHelper.newDocument();
+ marshaller.marshal(source, document);
+ return document;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Object.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getSourceDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java
new file mode 100644
index 0000000000..6f606dd757
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBContextHelper.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.model.DataType;
+
+public class JAXBContextHelper {
+ // TODO: Do we need to set them for source and target?
+ public static final String JAXB_CLASSES = "jaxb.classes";
+
+ public static final String JAXB_CONTEXT_PATH = "jaxb.contextPath";
+
+ private JAXBContextHelper() {
+ }
+
+ public static JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
+ if (tContext == null)
+ throw new TransformationException("JAXB context is not set for the transformation.");
+
+ // FIXME: We should check the context path or classes
+ // FIXME: What should we do if JAXB is an intermediate node?
+ DataType<?> bindingContext = source ? tContext.getSourceDataType() : tContext.getTargetDataType();
+ String contextPath = (String) bindingContext.getMetadata(JAXB_CONTEXT_PATH);
+ JAXBContext context = null;
+ if (contextPath != null)
+ context = JAXBContext.newInstance(contextPath);
+ else {
+ Class[] classes = (Class[]) bindingContext.getMetadata(JAXB_CLASSES);
+ context = JAXBContext.newInstance(classes);
+ }
+ if (context == null)
+ throw new TransformationException("JAXB context is not set for the transformation.");
+ return context;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java
new file mode 100644
index 0000000000..c43e9bcd42
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBDataBinding.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.jaxb;
+
+import java.beans.Introspector;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchema;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * JAXB DataBinding
+ */
+public class JAXBDataBinding extends DataBindingExtension {
+
+ public static final String NAME = JAXBElement.class.getName();
+
+ @Override
+ public DataType introspect(Class<?> javaType) {
+ if (JAXBElement.class.isAssignableFrom(javaType)) {
+ Type type = javaType.getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = ((ParameterizedType) type);
+ Type rawType = parameterizedType.getRawType();
+ if (rawType == JAXBElement.class) {
+ Type actualType = parameterizedType.getActualTypeArguments()[0];
+ if (actualType instanceof Class) {
+ return introspect((Class<?>) actualType);
+ }
+ }
+ }
+ return new DataType<QName>(getName(), javaType, null);
+ }
+
+ String namespace = null;
+ String name = null;
+ Package pkg = javaType.getPackage();
+ if (pkg != null) {
+ XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
+ namespace = schema.namespace();
+ }
+ XmlType type = javaType.getAnnotation(XmlType.class);
+ if (type != null) {
+ String typeNamespace = type.namespace();
+ String typeName = type.name();
+
+ if (typeNamespace.equals("##default") && typeName.equals("")) {
+ XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
+ if (rootElement != null) {
+ namespace = rootElement.namespace();
+ } else {
+ // FIXME: The namespace should be from the referencing property
+ namespace = null;
+ }
+ } else if (typeNamespace.equals("##default")) {
+ // namespace is from the package
+ } else {
+ namespace = typeNamespace;
+ }
+
+ if (typeName.equals("##default")) {
+ name = Introspector.decapitalize(javaType.getSimpleName());
+ } else {
+ name = typeName;
+ }
+ } else {
+ XmlEnum xmlEnum = javaType.getAnnotation(XmlEnum.class);
+ if (xmlEnum != null) {
+ name = Introspector.decapitalize(javaType.getSimpleName());
+ }
+ }
+ if (namespace == null && name == null) {
+ return null;
+ }
+ QName xmlType = new QName(namespace, name);
+ DataType<QName> dataType = new DataType<QName>(getName(), javaType, xmlType);
+ return dataType;
+ }
+
+ public JAXBDataBinding() {
+ super(NAME, JAXBElement.class);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandler.java
new file mode 100644
index 0000000000..507f36eb19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandler.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.jaxb;
+
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.idl.ElementInfo;
+
+/**
+ * JAXB WrapperHandler implementation
+ */
+public class JAXBWrapperHandler implements WrapperHandler<JAXBElement<?>> {
+
+ public JAXBElement<?> create(ElementInfo element, TransformationContext context) {
+ try {
+ String packageName = null;
+ String factoryClassName = packageName + ".ObjectFactory";
+ Class<?> factoryClass = Class.forName(factoryClassName, true, context.getClassLoader());
+ assert factoryClass.isAnnotationPresent(XmlRegistry.class);
+ Object factory = factoryClass.newInstance();
+ QName elementName = element.getQName();
+ Method method = null;
+ for (Method m : factoryClass.getMethods()) {
+ XmlElementDecl xmlElement = m.getAnnotation(XmlElementDecl.class);
+ QName name = new QName(xmlElement.namespace(), xmlElement.name());
+ if (xmlElement != null && name.equals(elementName)) {
+ method = m;
+ break;
+ }
+ }
+ if (method != null) {
+ Class typeClass = method.getParameterTypes()[0];
+ Object value = typeClass.newInstance();
+ return (JAXBElement<?>) method.invoke(factory, new Object[] { value });
+ } else {
+ throw new TransformationException("ObjectFactory cannot be resolved.");
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Object getChild(JAXBElement<?> wrapper, int i, ElementInfo element) {
+ try {
+ Object value = wrapper.getValue();
+ PropertyDescriptor descriptors[] =
+ Introspector.getBeanInfo(wrapper.getDeclaredType()).getPropertyDescriptors();
+ for (PropertyDescriptor d : descriptors) {
+ if (d.getName().equals(element.getQName().getLocalPart())) {
+ return d.getReadMethod().invoke(value, new Object[] {});
+ }
+ }
+ return null;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public void setChild(JAXBElement<?> wrapper, int i, ElementInfo childElement, Object value) {
+ try {
+ Object wrapperValue = wrapper.getValue();
+ PropertyDescriptor descriptors[] =
+ Introspector.getBeanInfo(wrapper.getDeclaredType()).getPropertyDescriptors();
+ for (PropertyDescriptor d : descriptors) {
+ if (d.getName().equals(childElement.getQName().getLocalPart())) {
+ d.getWriteMethod().invoke(wrapperValue, new Object[] { value });
+ break;
+ }
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Node2JAXB.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Node2JAXB.java
new file mode 100755
index 0000000000..ddb81c2eae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Node2JAXB.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+@Service(Transformer.class)
+public class Node2JAXB extends TransformerExtension<Node, Object> implements PullTransformer<Node, Object> {
+
+ public Node2JAXB() {
+ super();
+ }
+
+ public Object transform(Node source, TransformationContext context) {
+ if (source == null)
+ return null;
+ try {
+ JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ return unmarshaller.unmarshal(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public Class getTargetType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Reader2JAXB.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Reader2JAXB.java
new file mode 100644
index 0000000000..36e05dd953
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/Reader2JAXB.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.jaxb;
+
+import java.io.Reader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class Reader2JAXB extends TransformerExtension<Reader, Object> implements
+ PullTransformer<Reader, Object> {
+
+ public Reader2JAXB() {
+ super();
+ }
+
+ public Object transform(Reader source, TransformationContext context) {
+ if (source == null)
+ return null;
+ try {
+ JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ StreamSource streamSource = new StreamSource(source);
+ return unmarshaller.unmarshal(streamSource);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return Reader.class;
+ }
+
+ public Class getTargetType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ return 30;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/XMLStreamReader2JAXB.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/XMLStreamReader2JAXB.java
new file mode 100755
index 0000000000..23d2586613
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/XMLStreamReader2JAXB.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class XMLStreamReader2JAXB extends TransformerExtension<XMLStreamReader, Object> implements
+ PullTransformer<XMLStreamReader, Object> {
+
+ public XMLStreamReader2JAXB() {
+ super();
+ }
+
+ public Object transform(XMLStreamReader source, TransformationContext context) {
+ if (source == null)
+ return null;
+ try {
+ JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ return unmarshaller.unmarshal(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public Class getTargetType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return JAXBDataBinding.NAME;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..2b86e506eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.JAXB">
+
+ <component name="databinding.jaxb">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.JAXBDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2JAXB">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.XMLStreamReader2JAXB" />
+ </component>
+
+ <component name="transformer.Node2JAXB">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.Node2JAXB" />
+ </component>
+
+ <component name="transformer.JAXB2Node">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.JAXB2Node" />
+ </component>
+
+ <component name="transformer.Reader2JAXB">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.Reader2JAXB" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java
new file mode 100644
index 0000000000..1b80be724f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.jaxb;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+import com.example.ipo.jaxb.USAddress;
+import com.example.ipo.jaxb.USState;
+
+/**
+ *
+ */
+public class JAXBDataBindingTestCase extends TestCase {
+ private JAXBDataBinding binding;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ binding = new JAXBDataBinding();
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.databinding.jaxb.JAXBDataBinding#introspect(java.lang.Class)}.
+ */
+ public final void testIntrospect() {
+ DataType<?> dataType = binding.introspect(JAXBElement.class);
+ Assert.assertTrue(dataType.getDataBinding().equals(binding.getName()));
+ Assert.assertTrue(dataType.getPhysical() == JAXBElement.class && dataType.getLogical() == null);
+ dataType = binding.introspect(MockJAXBElement.class);
+ Assert.assertEquals(PurchaseOrderType.class, dataType.getPhysical());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), dataType.getLogical());
+ dataType = binding.introspect(USAddress.class);
+ Assert.assertEquals(USAddress.class, dataType.getPhysical());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "USAddress"), dataType.getLogical());
+ dataType = binding.introspect(USState.class);
+ Assert.assertTrue(dataType.getDataBinding().equals(binding.getName()));
+ Assert.assertEquals(USState.class, dataType.getPhysical());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "USState"), dataType.getLogical());
+
+ }
+
+ private static class MockJAXBElement extends JAXBElement<PurchaseOrderType> {
+
+ private static final long serialVersionUID = -2767569071002707973L;
+
+ /**
+ * @param elementName
+ * @param type
+ * @param value
+ */
+ public MockJAXBElement(QName elementName, Class<PurchaseOrderType> type, PurchaseOrderType value) {
+ super(elementName, type, value);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java
new file mode 100755
index 0000000000..ebc537805e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.jaxb;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.io.StringReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+import org.w3c.dom.Node;
+
+public class JAXBTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private String contextPath = "com.example.ipo.jaxb";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testTransform() throws Exception {
+ Reader2JAXB t0 = new Reader2JAXB();
+
+ DataType targetDataType = new DataType<Class>(Object.class, null);
+ targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext = createMock(TransformationContext.class);
+ expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
+ replay(tContext);
+
+ Object object1 = t0.transform(new StringReader(IPO_XML), tContext);
+
+ DataType sourceDataType = new DataType<Class>(Object.class, null);
+ sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext1 = createMock(TransformationContext.class);
+ expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
+ replay(tContext1);
+
+ JAXB2Node t1 = new JAXB2Node();
+ Node node = t1.transform(object1, tContext1);
+
+ Assert.assertNotNull(node);
+
+ Node2JAXB t2 = new Node2JAXB();
+ Object object2 = t2.transform(node, tContext);
+ Assert.assertNotNull(object2);
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/resources/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-jaxb/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/pom.xml
new file mode 100755
index 0000000000..a7091dcc90
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/pom.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>databinding-sdo</artifactId>
+ <name>Apache Tuscany Data Binding for SDO</name>
+ <description>Data Binding based on SDO.</description>
+
+ <!-- include incubator repo as a plugin repo -->
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/sdo-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.0-incubator-M2</version>
+ <executions>
+ <execution>
+ <id>generate-sdo</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/ipo.xsd</schemaFile>
+ <javaPackage>com.example.ipo.sdo</javaPackage>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2String.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2String.java
new file mode 100755
index 0000000000..bae01a69b2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2String.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+
+@Service(Transformer.class)
+public class DataObject2String extends TransformerExtension<DataObject, String> implements
+ PullTransformer<DataObject, String> {
+
+ private static final String TUSCANY_SDO = "http://incubator.apache.org/tuscany/xmlns/sdo/1.0-incubator-M2";
+
+ public String transform(DataObject source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ Object logicalType = context.getSourceDataType().getLogical();
+ if (logicalType instanceof QName) {
+ QName elementName = (QName) logicalType;
+ return xmlHelper.save(source, elementName.getNamespaceURI(), elementName.getLocalPart());
+ } else {
+ return xmlHelper.save(source, TUSCANY_SDO, "dataObject");
+ }
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return DataObject.class;
+ }
+
+ public Class getTargetType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReader.java
new file mode 100755
index 0000000000..8caba8458d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReader.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+@Service(Transformer.class)
+public class DataObject2XMLStreamReader extends TransformerExtension<DataObject, XMLStreamReader> implements
+ PullTransformer<DataObject, XMLStreamReader> {
+
+ public XMLStreamReader transform(DataObject source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(typeHelper);
+ Object logicalType = context.getSourceDataType().getLogical();
+ QName elementName =
+ (logicalType instanceof QName) ? (QName) logicalType : new QName("commonj.sdo", "dataObject");
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ XMLDocument document =
+ xmlHelper.createDocument(source, elementName.getNamespaceURI(), elementName.getLocalPart());
+ return streamHelper.createXMLStreamReader(document);
+ } catch (XMLStreamException e) {
+ // TODO: Add context to the exception
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return DataObject.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java
new file mode 100755
index 0000000000..cd45575004
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/DataObjectLoader.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.StAXElementLoader;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.annotation.Autowire;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * A SDO model-based Loader to load DataObject from the XML stream
+ *
+ */
+public class DataObjectLoader implements StAXElementLoader<ModelObject> {
+ protected LoaderRegistry registry;
+ private QName propertyQName;
+
+ public DataObjectLoader(Property property) {
+ super();
+ this.propertyQName = new QName(XSDHelper.INSTANCE.getNamespaceURI(property),
+ XSDHelper.INSTANCE.getLocalName(property));
+ }
+
+ public DataObjectLoader(QName propertyQName) {
+ super();
+ this.propertyQName = propertyQName;
+ }
+
+ public ModelObject load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ assert propertyQName.equals(reader.getName());
+ // TODO: We need a way to get TypeHelper from deploymentContext
+ TypeHelper typeHelper = TypeHelper.INSTANCE;
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(typeHelper);
+ DataObject dataObject = streamHelper.loadObject(reader);
+ // TODO: Is it required that the object always extends from ModelObject?
+ return new ModelDataObject(dataObject);
+ }
+
+ @Autowire
+ public void setRegistry(LoaderRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void start() {
+ registry.registerLoader(propertyQName, this);
+ }
+
+ @Destroy
+ public void stop() {
+ registry.unregisterLoader(propertyQName, this);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java
new file mode 100755
index 0000000000..ac8ca776c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ImportSDOLoader.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.osoa.sca.annotations.Constructor;
+
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * Loader that handles &lt;import.sdo&gt; elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImportSDOLoader extends LoaderExtension {
+ public static final QName IMPORT_SDO =
+ new QName("http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2", "import.sdo");
+
+ @Constructor( { "registry" })
+ public ImportSDOLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPORT_SDO;
+ }
+
+ public ModelObject load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ assert IMPORT_SDO.equals(reader.getName());
+
+ // FIXME: [rfeng] How to associate the TypeHelper with deployment context?
+ TypeHelper typeHelper = TypeHelper.INSTANCE;
+ if (deploymentContext != null && deploymentContext.getParent() != null) {
+ typeHelper = (TypeHelper) deploymentContext.getParent().getExtension(TypeHelper.class.getName());
+ if (typeHelper == null) {
+ typeHelper = SDOUtil.createTypeHelper();
+ deploymentContext.getParent().putExtension(TypeHelper.class.getName(), typeHelper);
+ }
+ }
+
+ importFactory(reader, deploymentContext);
+ importWSDL(reader, deploymentContext, typeHelper);
+ LoaderUtil.skipToEndElement(reader);
+ return new SDOType(typeHelper);
+ }
+
+ private void importFactory(XMLStreamReader reader, DeploymentContext deploymentContext) throws LoaderException {
+ String factoryName = reader.getAttributeValue(null, "factory");
+ if (factoryName != null) {
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try {
+ // set TCCL as SDO needs it
+ ClassLoader cl = deploymentContext.getClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ Class<?> factoryClass = cl.loadClass(factoryName);
+ // FIXME: We require the SDO to provide an API to register static types in a given TypeHelper
+ SDOUtil.registerStaticTypes(factoryClass);
+ } catch (ClassNotFoundException e) {
+ throw new LoaderException(e.getMessage(), e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+ }
+ }
+
+ private void importWSDL(XMLStreamReader reader, DeploymentContext deploymentContext, TypeHelper typeHelper)
+ throws LoaderException {
+ String location = reader.getAttributeValue(null, "location");
+ if (location == null)
+ location = reader.getAttributeValue(null, "wsdlLocation");
+ if (location != null) {
+ try {
+ URL wsdlURL = null;
+ URI uri = URI.create(location);
+ if (uri.isAbsolute()) {
+ wsdlURL = uri.toURL();
+ }
+ wsdlURL = deploymentContext.getClassLoader().getResource(location);
+ if (null == wsdlURL) {
+ LoaderException loaderException = new LoaderException("WSDL location error");
+ loaderException.setResourceURI(location);
+ throw loaderException;
+ }
+ InputStream xsdInputStream = wsdlURL.openStream();
+ try {
+ XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+ xsdHelper.define(xsdInputStream, wsdlURL.toExternalForm());
+ } finally {
+ xsdInputStream.close();
+ }
+ } catch (IOException e) {
+ LoaderException sfe = new LoaderException(e.getMessage());
+ sfe.setResourceURI(location);
+ throw sfe;
+ }
+ }
+ }
+
+ public static class SDOType extends ModelObject {
+ private TypeHelper typeHelper;
+
+ public SDOType(TypeHelper typeHelper) {
+ super();
+ this.typeHelper = typeHelper;
+ }
+
+ public TypeHelper getTypeHelper() {
+ return typeHelper;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ModelDataObject.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ModelDataObject.java
new file mode 100755
index 0000000000..a3870b5e9a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/ModelDataObject.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import org.apache.tuscany.spi.model.ModelObject;
+
+import commonj.sdo.DataObject;
+
+public class ModelDataObject extends ModelObject {
+ private DataObject dataObject;
+
+ public ModelDataObject(DataObject dataObject) {
+ super();
+ this.dataObject = dataObject;
+ }
+
+ public DataObject getDataObject() {
+ return dataObject;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java
new file mode 100644
index 0000000000..213dfd9280
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataBinding.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.tuscany.spi.model.DataType;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ *
+ */
+public class SDODataBinding extends DataBindingExtension {
+ private WrapperHandler<Object> wrapperHandler;
+
+ @Override
+ public DataType introspect(Class<?> javaType) {
+ if (javaType == DataObject.class) {
+ return new DataType<QName>(getName(), javaType, null);
+ }
+ Type type = TypeHelper.INSTANCE.getType(javaType);
+ if (type == null || type.isDataType()) {
+ return null;
+ }
+ String namespace = type.getURI();
+ String name = XSDHelper.INSTANCE.getLocalName(type);
+ QName xmlType = new QName(namespace, name);
+ DataType<QName> dataType = new DataType<QName>(getName(), javaType, xmlType);
+ return dataType;
+ }
+
+ public SDODataBinding() {
+ super(DataObject.class);
+ wrapperHandler = new SDOWrapperHandler();
+ }
+
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return wrapperHandler;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataTypeHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataTypeHelper.java
new file mode 100644
index 0000000000..9d88c9fa58
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDODataTypeHelper.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import org.apache.tuscany.databinding.sdo.ImportSDOLoader.SDOType;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Helper class to get TypeHelper from the transformation context
+ */
+public class SDODataTypeHelper {
+ private SDODataTypeHelper() {
+ }
+
+ public static TypeHelper getTypeHelper(TransformationContext context) {
+ TypeHelper typeHelper = null;
+ if (context == null || context.getMetadata() == null) {
+ return TypeHelper.INSTANCE;
+ }
+ CompositeComponent composite = (CompositeComponent) context.getMetadata().get(CompositeComponent.class);
+ if (composite != null) {
+ SDOType sdoType = (SDOType) composite.getExtensions().get(SDOType.class);
+ if (sdoType != null) {
+ typeHelper = sdoType.getTypeHelper();
+ }
+ }
+ if (typeHelper == null) {
+ return TypeHelper.INSTANCE;
+ }
+ return typeHelper;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java
new file mode 100755
index 0000000000..0c3e74cdc7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOObjectFactory.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.CopyHelper;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.ObjectCreationException;
+
+/**
+ * Creates new instances of an SDO
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOObjectFactory implements ObjectFactory<DataObject> {
+
+ private DataObject dataObject;
+
+ public SDOObjectFactory(DataObject dataObject) {
+ this.dataObject = dataObject;
+ }
+
+ public DataObject getInstance() throws ObjectCreationException {
+ return CopyHelper.INSTANCE.copy(dataObject);
+ }
+
+ public void releaseInstance(DataObject instance) {
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOSimpleTypeMapper.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOSimpleTypeMapper.java
new file mode 100644
index 0000000000..78e2c4e0c2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOSimpleTypeMapper.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.TypeInfo;
+
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * SDO Java/XML mapping for simple XSD types
+ */
+public class SDOSimpleTypeMapper implements SimpleTypeMapper {
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+
+ public SDOSimpleTypeMapper() {
+ super();
+ }
+
+ public Object toJavaObject(TypeInfo simpleType, String value, TransformationContext context) {
+ QName typeName = simpleType.getQName();
+ Type type = null;
+ if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
+ type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
+ } else {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
+ }
+ return SDOUtil.createFromString(type, value);
+ }
+
+ public String toXMLLiteral(TypeInfo simpleType, Object obj, TransformationContext context) {
+ QName typeName = simpleType.getQName();
+ Type type = null;
+ if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
+ type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
+ } else {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ if (typeHelper == null) {
+ typeHelper = TypeHelper.INSTANCE;
+ }
+ type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
+ }
+ return SDOUtil.convertToString(type, obj);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java
new file mode 100644
index 0000000000..d34b389458
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.model.DataType;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+/**
+ * SDO Wrapper Handler
+ */
+public class SDOWrapperHandler implements WrapperHandler<Object> {
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.WrapperHandler#create(ElementInfo,
+ * TransformationContext)
+ */
+ public Object create(ElementInfo element, TransformationContext context) {
+ TypeHelper typeHelper = TypeHelper.INSTANCE;
+ if (context != null) {
+ DataType targetType = context.getTargetDataType();
+ if (targetType != null) {
+ typeHelper = (TypeHelper) targetType.getMetadata(TypeHelper.class.getName());
+ if (typeHelper == null) {
+ typeHelper = TypeHelper.INSTANCE;
+ }
+ }
+ }
+ QName typeName = element.getType().getQName();
+ DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper);
+ DataObject root = dataFactory.create(typeName.getNamespaceURI(), typeName.getLocalPart());
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ return xmlHelper.createDocument(root, element.getQName().getNamespaceURI(), element.getQName().getLocalPart());
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.WrapperHandler#getChild(java.lang.Object, int,
+ * ElementInfo)
+ */
+ public Object getChild(Object wrapper, int i, ElementInfo element) {
+ DataObject wrapperDO =
+ (wrapper instanceof XMLDocument) ? ((XMLDocument) wrapper).getRootObject() : (DataObject) wrapper;
+ return wrapperDO.get(element.getQName().getLocalPart());
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.WrapperHandler#setChild(java.lang.Object, int,
+ * ElementInfo, java.lang.Object)
+ */
+ public void setChild(Object wrapper, int i, ElementInfo childElement, Object value) {
+ DataObject wrapperDO =
+ (wrapper instanceof XMLDocument) ? ((XMLDocument) wrapper).getRootObject() : (DataObject) wrapper;
+ wrapperDO.set(childElement.getQName().getLocalPart(), value);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/String2DataObject.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/String2DataObject.java
new file mode 100755
index 0000000000..81b0b7dbcc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/String2DataObject.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+
+@Service(Transformer.class)
+public class String2DataObject extends TransformerExtension<String, DataObject> implements PullTransformer<String, DataObject> {
+
+ public DataObject transform(String source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ return xmlHelper.load(source).getRootObject();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return String.class;
+ }
+
+ public Class getTargetType() {
+ return DataObject.class;
+ }
+
+ public int getWeight() {
+ return 50;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2String.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2String.java
new file mode 100644
index 0000000000..8870000838
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2String.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import java.io.StringWriter;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+@Service(Transformer.class)
+public class XMLDocument2String extends TransformerExtension<XMLDocument, String> implements
+ PullTransformer<XMLDocument, String> {
+
+ public String transform(XMLDocument source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ StringWriter writer = new StringWriter();
+ xmlHelper.save(source, writer, null);
+ return writer.toString();
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return XMLDocument.class;
+ }
+
+ public Class getTargetType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReader.java
new file mode 100755
index 0000000000..92563f37d2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReader.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+
+@Service(Transformer.class)
+public class XMLDocument2XMLStreamReader extends TransformerExtension<XMLDocument, XMLStreamReader> implements PullTransformer<XMLDocument, XMLStreamReader> {
+ /**
+ * @param source
+ * @param context
+ * @return
+ */
+ public XMLStreamReader transform(XMLDocument source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(typeHelper);
+ return streamHelper.createXMLStreamReader(source);
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return XMLDocument.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2DataObject.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2DataObject.java
new file mode 100755
index 0000000000..e00396820a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2DataObject.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+
+@Service(Transformer.class)
+public class XMLStreamReader2DataObject extends TransformerExtension<XMLStreamReader, DataObject> implements
+ PullTransformer<XMLStreamReader, DataObject> {
+
+ public DataObject transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(typeHelper);
+ // The XMLStreamHelper requires that the reader is posistioned at START_ELEMENT
+ while (source.getEventType() != XMLStreamConstants.START_ELEMENT && source.hasNext()) {
+ source.next();
+ }
+ return streamHelper.loadObject(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getTargetType() {
+ return DataObject.class;
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 15;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2XMLDocument.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2XMLDocument.java
new file mode 100755
index 0000000000..063fbca812
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/XMLStreamReader2XMLDocument.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sdo.helper.XMLStreamHelper;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+
+@Service(Transformer.class)
+public class XMLStreamReader2XMLDocument extends TransformerExtension<XMLStreamReader, XMLDocument> implements
+ PullTransformer<XMLStreamReader, XMLDocument> {
+
+ public XMLDocument transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ TypeHelper typeHelper = SDODataTypeHelper.getTypeHelper(context);
+ XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(typeHelper);
+ return streamHelper.load(source);
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getTargetType() {
+ return XMLDocument.class;
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 15;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/databinding.sdo.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/databinding.sdo.scdl
new file mode 100644
index 0000000000..245f06e1cd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/databinding.sdo.scdl
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ SDO databinding extension
+
+ This is the copy to be included by other extensions
+
+ $Rev: 431086 $ $Date: 2006-08-12 13:58:17 -0700 (Sat, 12 Aug 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.sdo.include">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-sdo</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <!-- import.sdo element loader implementations -->
+ <component name="elementLoader.import.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
+ </component>
+
+ <component name="databinding.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.SDODataBinding" />
+ </component>
+
+ <component name="transformer.DataObject2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2String"/>
+ </component>
+ <component name="transformer.DataObject2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLDocument2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2String"/>
+ </component>
+ <component name="transformer.String2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.String2DataObject"/>
+ </component>
+ <component name="transformer.XMLDocument2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLStreamReader2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2DataObject"/>
+ </component>
+ <component name="transformer.XMLStreamReader2XMLDocument">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..e554690be9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ SDO databinding extension
+
+ $Rev: 431086 $ $Date: 2006-08-12 13:58:17 -0700 (Sat, 12 Aug 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.sdo">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-sdo</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <!-- import.sdo element loader implementations -->
+ <component name="elementLoader.import.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
+ </component>
+
+ <component name="databinding.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.SDODataBinding" />
+ </component>
+
+ <component name="transformer.DataObject2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2String"/>
+ </component>
+ <component name="transformer.DataObject2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLDocument2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2String"/>
+ </component>
+ <component name="transformer.String2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.String2DataObject"/>
+ </component>
+ <component name="transformer.XMLDocument2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLStreamReader2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2DataObject"/>
+ </component>
+ <component name="transformer.XMLStreamReader2XMLDocument">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2StringTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2StringTestCase.java
new file mode 100644
index 0000000000..28a885cd16
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2StringTestCase.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import commonj.sdo.DataObject;
+
+/**
+ *
+ */
+public class DataObject2StringTestCase extends SDOTransformerTestCaseBase {
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataType<QName>(binding, PurchaseOrderType.class, orderQName);
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataType<Class<String>>(String.class, String.class);
+ }
+
+ public final void testTransform() {
+ String xml = new DataObject2String().transform(dataObject, context);
+ Assert.assertTrue(xml.indexOf("<city>San Jose</city>") != -1);
+ DataObject po = new String2DataObject().transform(xml, reversedContext);
+ Assert.assertTrue(po instanceof PurchaseOrderType);
+ PurchaseOrderType orderType = (PurchaseOrderType) po;
+ Assert.assertEquals("San Jose", orderType.getBillTo().getCity());
+ }
+
+ public final void testXML() {
+ String xml =
+ "<foo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ipo=\"http://www.example.com/IPO\" xsi:type=\"ipo:USAddress\"/>";
+ DataObject dataObject = new String2DataObject().transform(xml, reversedContext);
+ context.setSourceDataType(new DataType<QName>(DataObject.class.getName(), DataObject.class, null));
+ xml = new DataObject2String().transform(dataObject, context);
+ Assert.assertTrue(xml.contains("xsi:type=\"ipo:USAddress\""));
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..5ab23c6df1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObject2XMLStreamReaderTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+
+/**
+ *
+ */
+public class DataObject2XMLStreamReaderTestCase extends SDOTransformerTestCaseBase {
+
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataType<QName>(binding, PurchaseOrderType.class, orderQName);
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataType<Class<XMLStreamReader>>(XMLStreamReader.class, XMLStreamReader.class);
+ }
+
+ public final void testTransform() throws XMLStreamException {
+ XMLStreamReader reader = new DataObject2XMLStreamReader().transform(dataObject, context);
+ while (reader.hasNext()) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT)
+ break;
+ }
+ new XMLStreamReader2DataObject().transform(reader, reversedContext);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObjectLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObjectLoaderTestCase.java
new file mode 100755
index 0000000000..8cdbf0a295
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/DataObjectLoaderTestCase.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+import commonj.sdo.helper.XSDHelper;
+
+public class DataObjectLoaderTestCase extends TestCase {
+
+ private XSDHelper xsdHelper = XSDHelper.INSTANCE;
+
+ private QName name = new QName("http://www.osoa.org/xmlns/mock/0.9", "implementation.mock");
+
+ private String xml = "<module name=\"m\" xmlns=\"http://www.osoa.org/xmlns/sca/0.9\" xmlns:mock=\"http://www.osoa.org/xmlns/mock/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.osoa.org/xmlns/mock/0.9 sca-implementation-mock.xsd http://www.osoa.org/xmlns/sca/0.9 sca-core.xsd \"><component name=\"c\"><mock:implementation.mock myAttr=\"helloworld.HelloWorldImpl\" /></component></module>";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ URL url = getClass().getClassLoader().getResource("model/sca-implementation-mock.xsd");
+ // URL url = getClass().getClassLoader().getResource("model/sca-core.xsd");
+ xsdHelper.define(url.openStream(), url.toExternalForm());
+ }
+
+ public void testLoader() throws Exception {
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ int event = reader.getEventType();
+ while (!(event == XMLStreamConstants.START_ELEMENT && reader.getName().equals(name)) && reader.hasNext()) {
+ event = reader.nextTag();
+ }
+ DataObjectLoader loader = new DataObjectLoader(name);
+ DeploymentContext context = new RootDeploymentContext(getClass().getClassLoader(), inputFactory, new ModuleScopeContainer(), null);
+ ModelDataObject modelObject = (ModelDataObject) loader.load(null, reader, context);
+ Assert.assertNotNull(modelObject.getDataObject());
+ Assert.assertTrue(modelObject.getDataObject().getString("myAttr").equals("helloworld.HelloWorldImpl"));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
new file mode 100755
index 0000000000..b2acb139f9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/ImportSDOLoaderTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sdo;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.databinding.sdo.ImportSDOLoader.SDOType;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImportSDOLoaderTestCase extends TestCase {
+ private static boolean inited;
+
+ private ImportSDOLoader loader;
+ private XMLInputFactory xmlFactory;
+ private DeploymentContext deploymentContext;
+
+ public void testMinimal() throws XMLStreamException, LoaderException {
+ String xml = "<import.sdo xmlns='http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2'/>";
+ XMLStreamReader reader = getReader(xml);
+ assertTrue(loader.load(null, reader, deploymentContext) instanceof SDOType);
+ }
+
+ public void testLocation() throws XMLStreamException, LoaderException {
+ String xml = "<import.sdo xmlns='http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2' location='ipo.xsd'/>";
+ XMLStreamReader reader = getReader(xml);
+ assertTrue(loader.load(null, reader, deploymentContext) instanceof SDOType);
+ }
+
+ public void testFactory() throws XMLStreamException, LoaderException {
+ String xml = "<import.sdo xmlns='http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2' "
+ + "factory='org.apache.tuscany.databinding.sdo.ImportSDOLoaderTestCase$MockFactory'/>";
+ XMLStreamReader reader = getReader(xml);
+ assertFalse(inited);
+ assertTrue(loader.load(null, reader, deploymentContext) instanceof SDOType);
+ assertTrue(inited);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ loader = new ImportSDOLoader(null);
+ xmlFactory = XMLInputFactory.newInstance();
+ deploymentContext = new RootDeploymentContext(getClass().getClassLoader(), xmlFactory, null, null);
+ }
+
+ protected XMLStreamReader getReader(String xml) throws XMLStreamException {
+ XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(xml));
+ reader.next();
+ return reader;
+ }
+
+ public static class MockFactory {
+ public static final Object INSTANCE = null;
+
+ static {
+ ImportSDOLoaderTestCase.inited = true;
+ }
+ }
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDODataBindingTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDODataBindingTestCase.java
new file mode 100644
index 0000000000..438de93c76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDODataBindingTestCase.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import com.example.ipo.sdo.SdoFactory;
+import com.example.ipo.sdo.USAddress;
+import commonj.sdo.DataObject;
+
+/**
+ *
+ */
+public class SDODataBindingTestCase extends TestCase {
+ private SDODataBinding binding;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ binding = new SDODataBinding();
+ SDOUtil.registerStaticTypes(SdoFactory.class);
+ }
+
+ public final void testIntrospect() {
+ DataType<?> dataType = binding.introspect(DataObject.class);
+ Assert.assertTrue(dataType.getDataBinding().equals(binding.getName()));
+ Assert.assertTrue(dataType.getPhysical() == DataObject.class && dataType.getLogical() == null);
+ dataType = binding.introspect(PurchaseOrderType.class);
+ Assert.assertEquals(PurchaseOrderType.class, dataType.getPhysical());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), dataType.getLogical());
+ dataType = binding.introspect(USAddress.class);
+ Assert.assertEquals(USAddress.class, dataType.getPhysical());
+ Assert.assertEquals(new QName("http://www.example.com/IPO", "USAddress"), dataType.getLogical());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOTransformerTestCaseBase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOTransformerTestCaseBase.java
new file mode 100644
index 0000000000..848dde6e13
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/SDOTransformerTestCaseBase.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.core.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+import com.example.ipo.sdo.SdoFactory;
+import com.example.ipo.sdo.USAddress;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * The base class for SDO-related test cases
+ */
+public abstract class SDOTransformerTestCaseBase extends TestCase {
+ protected String binding = DataObject.class.getName();
+
+ protected static final QName orderQName = new QName("http://www.example.com/IPO", "purchaseOrder");
+
+ protected TransformationContext context;
+ protected TransformationContext reversedContext;
+ protected DataObject dataObject;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ SDOUtil.registerStaticTypes(SdoFactory.class);
+ context = new TransformationContextImpl();
+ context.setSourceDataType(getSourceDataType());
+ context.setTargetDataType(getTargetDataType());
+
+ reversedContext = new TransformationContextImpl();
+ reversedContext.setSourceDataType(getTargetDataType());
+ reversedContext.setTargetDataType(getSourceDataType());
+
+ PurchaseOrderType po = SdoFactory.INSTANCE.createPurchaseOrderType();
+ USAddress address = SdoFactory.INSTANCE.createUSAddress();
+ address.setCity("San Jose");
+ address.setStreet("123 ABC St");
+ address.setState("CA");
+ address.setStreet("95131");
+ po.setBillTo(address);
+ dataObject = (DataObject) po;
+ }
+
+ protected abstract DataType<?> getSourceDataType();
+
+ protected abstract DataType<?> getTargetDataType();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..a7f391216b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/java/org/apache/tuscany/databinding/sdo/XMLDocument2XMLStreamReaderTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.sdo;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.spi.model.DataType;
+
+import com.example.ipo.sdo.PurchaseOrderType;
+
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+/**
+ *
+ */
+public class XMLDocument2XMLStreamReaderTestCase extends SDOTransformerTestCaseBase {
+
+ @Override
+ protected DataType<?> getSourceDataType() {
+ return new DataType<QName>(XMLDocument.class.getName(), XMLDocument.class, orderQName);
+ }
+
+ @Override
+ protected DataType<?> getTargetDataType() {
+ return new DataType<Class<XMLStreamReader>>(XMLStreamReader.class, XMLStreamReader.class);
+ }
+
+ public final void testTransform() throws XMLStreamException {
+ XMLDocument document =
+ XMLHelper.INSTANCE.createDocument(dataObject, orderQName.getNamespaceURI(), orderQName.getLocalPart());
+ XMLStreamReader reader = new XMLDocument2XMLStreamReader().transform(document, context);
+ XMLDocument document2 = new XMLStreamReader2XMLDocument().transform(reader, reversedContext);
+ Assert.assertEquals(orderQName.getNamespaceURI(), document2.getRootElementURI());
+ Assert.assertEquals(orderQName.getLocalPart(), document2.getRootElementName());
+ Assert.assertTrue(document2.getRootObject() instanceof PurchaseOrderType);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/META-INF/tuscany/databinding.sdo.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/META-INF/tuscany/databinding.sdo.scdl
new file mode 100644
index 0000000000..70b4028e8a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/META-INF/tuscany/databinding.sdo.scdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ import.sdo configuration
+
+ $Rev: 431086 $ $Date: 2006-08-12 13:58:17 -0700 (Sat, 12 Aug 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.sdo">
+
+ <!-- import.sdo element loader implementations -->
+ <component name="elementLoader.import.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-core.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-core.xsd
new file mode 100755
index 0000000000..56c6977254
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-core.xsd
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified">
+
+ <element name="componentType" type="sca:ComponentType"/>
+ <complexType name="ComponentType">
+ <sequence>
+ <element minOccurs="0" maxOccurs="unbounded" name="service" type="sca:Service"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="reference" type="sca:Reference"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="property" type="sca:Property"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Service">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:interface"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="interface" type="sca:Interface"/>
+ <complexType name="Interface"/>
+
+ <complexType name="Reference">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:interface"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="multiplicity" type="sca:Multiplicity" use="optional" default="1..1"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Property">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="type" type="QName" use="required"/>
+ <attribute name="many" type="boolean" default="false" use="optional"/>
+ <attribute name="required" type="boolean" default="false" use="optional"/>
+ <attribute name="default" type="string" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <element name="moduleFragment" type="sca:ModuleFragment"/>
+ <complexType name="ModuleFragment">
+ <sequence>
+ <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="sca:EntryPoint"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="component" type="sca:Component"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="sca:ExternalService"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="wire" type="sca:ModuleWire"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="module" type="sca:Module"/>
+ <complexType name="Module">
+ <complexContent>
+ <extension base="sca:ModuleFragment"/>
+ </complexContent>
+ </complexType>
+
+ <complexType name="EntryPoint">
+ <sequence>
+ <element minOccurs="0" maxOccurs="1" ref="sca:interface"/>
+ <element minOccurs="1" maxOccurs="unbounded" ref="sca:binding"/>
+ <element minOccurs="1" maxOccurs="unbounded" name="reference" type="anyURI"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="multiplicity" type="sca:Multiplicity" use="optional" default="1..1"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+ <!-- a multiplicity 1..1 or 0..n sample
+ <reference>StockQuoteComponent</reference> - type must be URI
+ a multiplicity 1..n or 0..n sample
+ <reference>StockQuoteComponent1</reference> - type must be URI
+ <reference>StockQuoteComponent2</reference>
+ -->
+
+ <element name="binding" type="sca:Binding"/>
+ <complexType name="Binding">
+ <attribute name="uri" type="anyURI" use="optional"/>
+ </complexType>
+
+ <complexType name="Component">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:implementation"/>
+ <element minOccurs="0" maxOccurs="1" name="properties" type="sca:PropertyValues"/>
+ <element minOccurs="0" maxOccurs="1" name="references" type="sca:ReferenceValues"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+ <!-- a multiplicity 1..1 or 0..1 sample
+ <references>
+ <v:stockQuote>StockQuoteComponent</v:stockquote> - type must be URI
+ </references>
+ a multiplicity 1..n or 0..n sample
+ <references>
+ <v:stockQuote>StockQuoteComponent1</v:stockQuote> - type must be URI
+ <v:stockQuote>StockQuoteComponent2</v:stockQuote>
+ </references>
+ -->
+
+ <element name="implementation" type="sca:Implementation"/>
+ <complexType name="Implementation"/>
+
+ <complexType name="PropertyValues">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="ReferenceValues">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <complexType name="ExternalService">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:interface"/>
+ <element minOccurs="0" maxOccurs="unbounded" ref="sca:binding"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="overridable" type="sca:OverrideOptions" default="may" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <complexType name="ModuleWire">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:source.uri"/>
+ <element minOccurs="1" maxOccurs="1" ref="sca:target.uri"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="source" type="anyType"/>
+ <element name="target" type="anyType"/>
+
+ <element name="source.uri" type="anyURI" substitutionGroup="sca:source"/>
+ <element name="target.uri" type="anyURI" substitutionGroup="sca:target"/>
+
+ <element name="subsystem" type="sca:Subsystem"/>
+ <complexType name="Subsystem">
+ <sequence>
+ <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="sca:EntryPoint"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="moduleComponent" type="sca:ModuleComponent"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="sca:ExternalService"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="wire" type="sca:SystemWire"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="ModuleComponent">
+ <sequence>
+ <element minOccurs="0" maxOccurs="1" name="properties" type="sca:PropertyValues"/>
+ <element minOccurs="0" maxOccurs="1" name="references" type="sca:ReferenceValues"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="module" type="NCName" use="required"/>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="SystemWire">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:source"/>
+ <element minOccurs="1" maxOccurs="1" ref="sca:target"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="source.epr" type="anyType" substitutionGroup="sca:source"/>
+ <element name="target.epr" type="anyType" substitutionGroup="sca:target"/>
+
+ <simpleType name="Multiplicity">
+ <restriction base="string">
+ <enumeration value="0..1"/>
+ <enumeration value="1..1"/>
+ <enumeration value="0..n"/>
+ <enumeration value="1..n"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="OverrideOptions">
+ <restriction base="string">
+ <enumeration value="no"/>
+ <enumeration value="may"/>
+ <enumeration value="must"/>
+ </restriction>
+ </simpleType>
+
+</schema>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-implementation-mock.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-implementation-mock.xsd
new file mode 100755
index 0000000000..bbaf58f00c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/test/resources/model/sca-implementation-mock.xsd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/mock/0.9"
+ elementFormDefault="qualified"
+ xmlns:mock="http://www.osoa.org/xmlns/mock/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/0.9"
+ schemaLocation="sca-core.xsd" />
+
+ <element name="implementation.mock" type="mock:MockImplementation"
+ substitutionGroup="sca:implementation" />
+ <complexType name="MockImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="myAttr" type="NCName" use="required" />
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/pom.xml
new file mode 100755
index 0000000000..6a91a4007f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/pom.xml
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>databinding-test</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Data Binding Integration Test</name>
+ <description>Apache Tuscany Data Binding Integration Test</description>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>java.net</id>
+ <name>java.net Maven 1.x Repository</name>
+ <url>https://maven-repository.dev.java.net/nonav/repository</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-jaxb</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-xmlbeans</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-axiom</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.0.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxb-source</source>
+ <source>target/sdo-source</source>
+ <source>target/xmlbeans-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-sdo</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <schemaFile>${basedir}/src/test/resources/ipo.xsd</schemaFile>
+ <javaPackage>com.example.ipo.sdo</javaPackage>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>com.sun.tools.xjc.maven2</groupId>
+ <artifactId>maven-jaxb-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>generate-jaxb</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generatePackage>com.example.ipo.jaxb</generatePackage>
+ <generateDirectory>${project.build.directory}/jaxb-source</generateDirectory>
+ <schemaDirectory>${basedir}/src/test/resources</schemaDirectory>
+ <includeSchemas>
+ <includeSchema>ipo.xsd</includeSchema>
+ </includeSchemas>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>generate-xmlbeans</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean"
+ classpathref="maven.compile.classpath" />
+ <xmlbean schema="${basedir}/src/test/resources" classpathref="maven.compile.classpath"
+ destfile="${project.build.directory}/ipo-xmlbeans.jar"
+ srcgendir="${project.build.directory}/xmlbeans-source" javasource="1.5"
+ classgendir="${project.build.directory}/test-classes" />
+ </tasks>
+ <!--
+ <sourceRoot>${project.build.directory}/xmlbeans-source</sourceRoot>
+ <testSourceRoot>${project.build.directory}/xmlbeans-source</testSourceRoot>
+ -->
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/JAXBTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/JAXBTestCase.java
new file mode 100755
index 0000000000..894bee16e4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/JAXBTestCase.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.databinding.jaxb.JAXB2Node;
+import org.apache.tuscany.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.databinding.jaxb.XMLStreamReader2JAXB;
+import org.apache.tuscany.databinding.xmlbeans.Node2XmlObject;
+import org.apache.tuscany.databinding.xmlbeans.XmlObject2XMLStreamReader;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Node;
+
+public class JAXBTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private String contextPath = "com.example.ipo.jaxb";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testTransform() throws Exception {
+ // URL/Stream/Reader to XmlObject
+ XmlObject object = XmlObject.Factory.parse(new StringReader(IPO_XML));
+
+ // XmlObject to XMLStreamReader
+ XmlObject2XMLStreamReader t1 = new XmlObject2XMLStreamReader();
+ XMLStreamReader reader = t1.transform(object, null);
+
+ DataType targetDataType = new DataType<Class>(Object.class, null);
+ targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext = createMock(TransformationContext.class);
+ expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
+ replay(tContext);
+
+ // XMLStreamReader to JAXB
+ XMLStreamReader2JAXB t2 = new XMLStreamReader2JAXB();
+ Object object2 = t2.transform(reader, tContext);
+
+ DataType sourceDataType = new DataType<Class>(Object.class, null);
+ sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext1 = createMock(TransformationContext.class);
+ expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
+ replay(tContext1);
+
+ JAXB2Node t3 = new JAXB2Node();
+ Node node = t3.transform(object2, tContext1);
+
+ Node2XmlObject t4 = new Node2XmlObject();
+ XmlObject object3 = t4.transform(node, null);
+
+ Assert.assertNotNull(object3);
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/TransformationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/TransformationTestCase.java
new file mode 100755
index 0000000000..a181c80b87
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/TransformationTestCase.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.impl.TransformerRegistryImpl;
+import org.apache.tuscany.core.databinding.xml.Node2String;
+import org.apache.tuscany.core.databinding.xml.String2Node;
+import org.apache.tuscany.core.databinding.xml.String2XMLStreamReader;
+import org.apache.tuscany.core.databinding.xml.XMLStreamReader2String;
+import org.apache.tuscany.databinding.axiom.OMElement2String;
+import org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader;
+import org.apache.tuscany.databinding.axiom.String2OMElement;
+import org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement;
+import org.apache.tuscany.databinding.jaxb.JAXB2Node;
+import org.apache.tuscany.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.databinding.jaxb.Node2JAXB;
+import org.apache.tuscany.databinding.jaxb.XMLStreamReader2JAXB;
+import org.apache.tuscany.databinding.sdo.DataObject2XMLStreamReader;
+import org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader;
+import org.apache.tuscany.databinding.sdo.XMLStreamReader2DataObject;
+import org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument;
+import org.apache.tuscany.databinding.sdo.ImportSDOLoader.SDOType;
+import org.apache.tuscany.databinding.xmlbeans.Node2XmlObject;
+import org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject;
+import org.apache.tuscany.databinding.xmlbeans.XmlObject2Node;
+import org.apache.tuscany.databinding.xmlbeans.XmlObject2XMLStreamReader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Node;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class TransformationTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private TransformerRegistry registry;
+
+ private String contextPath = "com.example.ipo.jaxb";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new TransformerRegistryImpl();
+
+ List<Transformer> transformers = new ArrayList<Transformer>();
+
+ // Adding JAXB transformers
+ transformers.add(new JAXB2Node());
+ transformers.add(new Node2JAXB());
+ transformers.add(new XMLStreamReader2JAXB());
+
+ // Adding XMLBeans transformers
+ transformers.add(new XmlObject2Node());
+ transformers.add(new XmlObject2XMLStreamReader());
+ transformers.add(new Node2XmlObject());
+ transformers.add(new XMLStreamReader2XmlObject());
+
+ transformers.add(new DataObject2XMLStreamReader());
+ transformers.add(new XMLStreamReader2DataObject());
+
+ transformers.add(new XMLDocument2XMLStreamReader());
+ transformers.add(new XMLStreamReader2XMLDocument());
+
+ transformers.add(new String2XMLStreamReader());
+ transformers.add(new XMLStreamReader2String());
+
+ transformers.add(new String2Node());
+ transformers.add(new Node2String());
+
+ transformers.add(new OMElement2String());
+ transformers.add(new String2OMElement());
+
+ transformers.add(new XMLStreamReader2OMElement());
+ transformers.add(new OMElement2XMLStreamReader());
+
+ for (Transformer transformer : transformers) {
+ registry.registerTransformer(transformer);
+ }
+
+ // System.out.println(registry);
+
+ URL xsdFile = getClass().getClassLoader().getResource("ipo.xsd");
+ XSDHelper.INSTANCE.define(xsdFile.openStream(), null);
+ }
+
+ @SuppressWarnings("unchecked")
+ // XMLBeans --> SDO
+ public void testTransformation1() throws Exception {
+ URL xsdFile = getClass().getClassLoader().getResource("ipo.xsd");
+ TypeHelper typeHelper = SDOUtil.createTypeHelper();
+ XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+ xsdHelper.define(xsdFile.openStream(), xsdFile.toExternalForm());
+
+ // URL/Stream/Reader to XmlObject
+ XmlObject object = XmlObject.Factory.parse(new StringReader(IPO_XML));
+
+ List<Transformer> path =
+ registry.getTransformerChain(XmlObject.class.getName(), DataObject.class.getName());
+ System.out.println("Path: " + path);
+
+ TransformationContext tContext = createTransformationContext();
+ tContext.getMetadata().put(SDOType.class, new SDOType(typeHelper));
+
+ Object result = object;
+ for (Transformer transformer : path) {
+ result = ((PullTransformer)transformer).transform(result, tContext);
+ }
+ System.out.println("Result: " + result);
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result instanceof DataObject);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ // SDO --> DOM
+ public void testTransformation2() throws Exception {
+ // System.out.println(registry);
+
+ URL xmlFile = getClass().getClassLoader().getResource("ipo.xml");
+ // URL/Stream/Reader to XmlObject
+ XMLDocument object = XMLHelper.INSTANCE.load(xmlFile.openStream());
+
+ List<Transformer> path =
+ registry.getTransformerChain(XMLDocument.class.getName(), Node.class.getName());
+ System.out.println("Path: " + path);
+
+ TransformationContext tContext = createTransformationContext();
+
+ Object result = object;
+ for (Transformer transformer : path) {
+ result = ((PullTransformer)transformer).transform(result, tContext);
+ }
+ System.out.println("Result: " + result);
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result instanceof Node);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ // SDO --> JAXB
+ public void testTransformation3() throws Exception {
+ // System.out.println(registry);
+
+ URL xmlFile = getClass().getClassLoader().getResource("ipo.xml");
+ // URL/Stream/Reader to XmlObject
+ XMLDocument object = XMLHelper.INSTANCE.load(xmlFile.openStream());
+
+ List<Transformer> path =
+ registry.getTransformerChain(XMLDocument.class.getName(), JAXBElement.class.getName());
+ System.out.println("Path: " + path);
+
+ TransformationContext tContext = createTransformationContext();
+
+ Object result = object;
+ for (Transformer transformer : path) {
+ result = ((PullTransformer)transformer).transform(result, tContext);
+ }
+ System.out.println("Result: " + result);
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result instanceof Object);
+
+ }
+
+ private TransformationContext createTransformationContext() {
+ DataType dataType = new DataType<Class>(Object.class, null);
+ dataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+
+ TransformationContext tContext = createMock(TransformationContext.class);
+ expect(tContext.getTargetDataType()).andReturn(dataType).anyTimes();
+
+ expect(tContext.getSourceDataType()).andReturn(dataType).anyTimes();
+ Map<Class<?>, Object> metadata = new HashMap<Class<?>, Object>();
+ expect(tContext.getMetadata()).andReturn(metadata).anyTimes();
+ replay(tContext);
+ return tContext;
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/XmlObjectTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/XmlObjectTestCase.java
new file mode 100755
index 0000000000..78d51352cb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/XmlObjectTestCase.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.databinding.xmlbeans.Node2XmlObject;
+import org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject;
+import org.apache.tuscany.databinding.xmlbeans.XmlObject2Node;
+import org.apache.tuscany.databinding.xmlbeans.XmlObject2XMLStreamReader;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Node;
+
+public class XmlObjectTestCase extends TestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testTransform() throws Exception {
+ XmlObject object = XmlObject.Factory.parse(new StringReader(IPO_XML));
+
+ // XmlObject to XMLStreamReader
+ XmlObject2XMLStreamReader t1 = new XmlObject2XMLStreamReader();
+ XMLStreamReader reader = t1.transform(object, null);
+
+ // XMLStreamReader to XmlObject
+ XMLStreamReader2XmlObject t2 = new XMLStreamReader2XmlObject();
+ XmlObject object2 = t2.transform(reader, null);
+
+ // XmlObject to Node
+ XmlObject2Node t3 = new XmlObject2Node();
+ Node node = t3.transform(object2, null);
+
+ // Node to XmlObject
+ Node2XmlObject t4 = new Node2XmlObject();
+ XmlObject object3 = t4.transform(node, null);
+ Assert.assertNotNull(object3);
+ }
+
+ /*
+ * public void testGeneratedXmlObject() throws Exception { URL xmlFile =
+ * getClass().getClassLoader().getResource("ipo.xml"); // URL/Stream/Reader
+ * to XmlObject PurchaseOrderDocument object =
+ * PurchaseOrderDocument.Factory.parse(xmlFile); // XmlObject to
+ * XMLStreamReader XmlObject2XMLStreamReader t1 = new
+ * XmlObject2XMLStreamReader(); XMLStreamReader reader =
+ * t1.transform(object, null); // XMLStreamReader to XmlObject
+ * XMLStreamReader2XmlObject t2 = new XMLStreamReader2XmlObject(); XmlObject
+ * object2 = t2.transform(reader, null); // XmlObject to Node XmlObject2Node
+ * t3 = new XmlObject2Node(); Node node = t3.transform(object2, null); //
+ * Node to XmlObject Node2XmlObject t4 = new Node2XmlObject(); XmlObject
+ * object3 = t4.transform(node, null); Assert.assertNotNull(object3); }
+ */
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Client.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Client.java
new file mode 100644
index 0000000000..8ddc625d66
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Client.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sample;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Client {
+ void call(Object po);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/ClientImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/ClientImpl.java
new file mode 100644
index 0000000000..2d33a8666b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/ClientImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sample;
+
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Reference;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ClientImpl implements Client {
+
+ private Echo echoReference;
+
+ @Constructor
+ public ClientImpl(@Reference(name = "echoReference", required = true)
+ Echo echoReference) {
+ this.echoReference = echoReference;
+ }
+
+ public void call(Object po) {
+ Object ret = null;
+ if (po instanceof PurchaseOrderType) {
+ ret = echoReference.echoJAXB((PurchaseOrderType)po);
+ } else if (po instanceof com.example.ipo.sdo.PurchaseOrderType) {
+ ret = echoReference.echoSDO((com.example.ipo.sdo.PurchaseOrderType)po);
+ } else if (po instanceof com.example.ipo.xmlbeans.PurchaseOrderType) {
+ ret = echoReference.echoXMLBeans((com.example.ipo.xmlbeans.PurchaseOrderType)po);
+ }
+ System.out.println("Returned message: " + ret);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/DataBindingBootStrapTest.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/DataBindingBootStrapTest.java
new file mode 100644
index 0000000000..ff44dfb68d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/DataBindingBootStrapTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sample;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.databinding.jaxb.Reader2JAXB;
+import org.apache.tuscany.databinding.sdo.String2DataObject;
+import org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+import com.example.ipo.xmlbeans.PurchaseOrderDocument;
+import commonj.sdo.DataObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DataBindingBootStrapTest extends SCATestCase {
+ private static final String IPO_XML =
+ "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
+ + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
+ + " <name>Helen Zoe</name>"
+ + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>"
+ + " <postcode>CB1 1JR</postcode>"
+ + " </shipTo>"
+ + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>"
+ + " <street>8 Oak Avenue</street>"
+ + " <city>Old Town</city>"
+ + " <state>PA</state>"
+ + " <zip>95819</zip>"
+ + " </billTo>"
+ + " <items>"
+ + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>"
+ + " <quantity>1</quantity>"
+ + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>"
+ + " <shipDate>1999-12-05</shipDate>"
+ + " </item>"
+ + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ private Client client;
+ private String contextPath = "com.example.ipo.jaxb";
+
+ @SuppressWarnings("unchecked")
+ public void testDataBindingBootstrap() throws Exception {
+ DataType targetDataType = new DataType<Class>(Object.class, null);
+ targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
+ TransformationContext tContext = createMock(TransformationContext.class);
+ expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
+ replay(tContext);
+
+ String2DataObject t1 = new String2DataObject();
+ DataObject po1 = t1.transform(IPO_XML, null);
+ client.call(po1);
+
+ XMLStreamReader reader =
+ XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(IPO_XML));
+ XMLStreamReader2XmlObject t2 = new XMLStreamReader2XmlObject();
+ PurchaseOrderDocument po2 = (PurchaseOrderDocument)t2.transform(reader, null);
+ client.call(po2.getPurchaseOrder());
+
+ Reader2JAXB t3 = new Reader2JAXB();
+ JAXBElement<PurchaseOrderType> po3 =
+ (JAXBElement<PurchaseOrderType>)t3.transform(new StringReader(IPO_XML), tContext);
+ client.call(po3.getValue());
+
+ }
+
+ protected void setUp() throws Exception {
+ setApplicationSCDL(getClass(), "META-INF/sca/default.scdl");
+ addExtension("test-extensions", getClass().getClassLoader()
+ .getResource("META-INF/tuscany/test-extensions.scdl"));
+ super.setUp();
+ CompositeContext context = CurrentCompositeContext.getContext();
+ client = context.locateService(Client.class, "Client");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Echo.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Echo.java
new file mode 100644
index 0000000000..c44e575e26
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/Echo.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sample;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Remotable
+@Service
+public interface Echo {
+ @DataType(name="javax.xml.bind.JAXBElement")
+ PurchaseOrderType echoJAXB(PurchaseOrderType po);
+
+ @DataType(name="commonj.sdo.DataObject")
+ com.example.ipo.sdo.PurchaseOrderType echoSDO(com.example.ipo.sdo.PurchaseOrderType po);
+
+ @DataType(name="org.apache.xmlbeans.XmlObject")
+ com.example.ipo.xmlbeans.PurchaseOrderType echoXMLBeans(com.example.ipo.xmlbeans.PurchaseOrderType po);
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/EchoImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/EchoImpl.java
new file mode 100644
index 0000000000..775c0317a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/java/org/apache/tuscany/databinding/sample/EchoImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.sample;
+
+import com.example.ipo.jaxb.PurchaseOrderType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EchoImpl implements Echo {
+
+ public PurchaseOrderType echoJAXB(PurchaseOrderType po) {
+ System.out.println("JAXB: " + po);
+ return po;
+ }
+
+ public com.example.ipo.sdo.PurchaseOrderType echoSDO(com.example.ipo.sdo.PurchaseOrderType po) {
+ System.out.println("SDO: " + po);
+ return po;
+ }
+
+ public com.example.ipo.xmlbeans.PurchaseOrderType echoXMLBeans(com.example.ipo.xmlbeans.PurchaseOrderType po) {
+ System.out.println("XMLBeans: " + po);
+ return po;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..611acdb919
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/sca/default.scdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:db="http://incubator.apache.org/tuscany/xmlns/databinding/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.sample">
+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2" factory="com.example.ipo.sdo.SdoFactory"/>
+
+ <component name="Client">
+ <implementation.java class="org.apache.tuscany.databinding.sample.ClientImpl" />
+ <reference name="echoReference">Echo</reference>
+ </component>
+
+ <component name="Echo">
+ <implementation.java class="org.apache.tuscany.databinding.sample.EchoImpl" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.axiom.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.axiom.scdl
new file mode 100644
index 0000000000..a21da8c6e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.axiom.scdl
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.Axiom">
+
+ <component name="databinding.axiom">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.AxiomDataBinding" />
+ </component>
+
+ <!-- Transformers -->
+ <component name="transformer.XMLStreamReader2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.String2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.String2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2String" />
+ </component>
+
+ <component name="transformer.Object2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.Object2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2Object">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2Object" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.jaxb.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.jaxb.scdl
new file mode 100644
index 0000000000..2b86e506eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.jaxb.scdl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.JAXB">
+
+ <component name="databinding.jaxb">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.JAXBDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2JAXB">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.XMLStreamReader2JAXB" />
+ </component>
+
+ <component name="transformer.Node2JAXB">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.Node2JAXB" />
+ </component>
+
+ <component name="transformer.JAXB2Node">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.JAXB2Node" />
+ </component>
+
+ <component name="transformer.Reader2JAXB">
+ <system:implementation.system class="org.apache.tuscany.databinding.jaxb.Reader2JAXB" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.sdo.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.sdo.scdl
new file mode 100644
index 0000000000..dabab7c687
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.sdo.scdl
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ import.sdo configuration
+
+ $Rev: 431086 $ $Date: 2006-08-12 13:58:17 -0700 (Sat, 12 Aug 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.sdo">
+
+ <!-- import.sdo element loader implementations -->
+ <component name="elementLoader.import.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.ImportSDOLoader"/>
+ </component>
+ <component name="databinding.sdo">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.SDODataBinding" />
+ </component>
+ <component name="transformer.DataObject2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2String"/>
+ </component>
+ <component name="transformer.DataObject2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.DataObject2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLDocument2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2String"/>
+ </component>
+ <component name="transformer.String2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.String2DataObject"/>
+ </component>
+ <component name="transformer.XMLDocument2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader"/>
+ </component>
+ <component name="transformer.XMLStreamReader2DataObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2DataObject"/>
+ </component>
+ <component name="transformer.XMLStreamReader2XMLDocument">
+ <system:implementation.system class="org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.xmlbeans.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.xmlbeans.scdl
new file mode 100644
index 0000000000..55c7363cba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/databinding.xmlbeans.scdl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.XMLBeans">
+
+ <component name="databinding.XMLBeans">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XMLBeansDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2XmlObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject" />
+ </component>
+
+ <component name="transformer.Node2XmlObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.Node2XmlObject" />
+ </component>
+
+ <component name="transformer.XmlObject2Node">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XmlObject2Node" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2XmlObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/interface.wsdl.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/interface.wsdl.scdl
new file mode 100644
index 0000000000..fe9a635747
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/interface.wsdl.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev: 440894 $ $Date: 2006-09-06 15:52:01 -0700 (Wed, 06 Sep 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.idl.WSDL">
+
+ <component name="interface.wsdl.Loader">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLLoader" />
+ </component>
+
+ <component name="wsdl.Registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl" initLevel="40" />
+ </component>
+
+ <component name="xmlSchema.registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl" initLevel="35" />
+ </component>
+
+ <component name="interface.wsdl.Introspector">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospectorImpl" initLevel="40" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/test-extensions.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/test-extensions.scdl
new file mode 100644
index 0000000000..193bd7a3f6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/META-INF/tuscany/test-extensions.scdl
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="test.extensions">
+
+ <include name="org.apache.tuscany.databinding.axiom" scdlLocation="databinding.axiom.scdl"/>
+ <include name="org.apache.tuscany.databinding.sdo" scdlLocation="databinding.sdo.scdl"/>
+ <include name="org.apache.tuscany.databinding.jaxb" scdlLocation="databinding.jaxb.scdl"/>
+ <include name="org.apache.tuscany.databinding.xmlbeans" scdlLocation="databinding.xmlbeans.scdl"/>
+ <include name="org.apache.tuscany.interface.wsdl" scdlLocation="interface.wsdl.scdl"/>
+
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xml
new file mode 100755
index 0000000000..df901d183d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ipo:purchaseOrder
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ipo="http://www.example.com/IPO"
+ xsi:schemaLocation="http://www.example.com/IPO ipo.xsd"
+ orderDate="1999-12-01">
+
+ <shipTo exportCode="1" xsi:type="ipo:UKAddress">
+ <name>Helen Zoe</name>
+ <street>47 Eden Street</street>
+ <city>Cambridge</city>
+ <postcode>CB1 1JR</postcode>
+ </shipTo>
+
+ <billTo xsi:type="ipo:USAddress">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+
+ <items>
+ <item partNum="833-AA">
+ <productName>Lapis necklace</productName>
+ <quantity>1</quantity>
+ <USPrice>99.95</USPrice>
+ <ipo:comment>Want this for the holidays</ipo:comment>
+ <shipDate>1999-12-05</shipDate>
+ </item>
+ </items>
+</ipo:purchaseOrder>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsdconfig b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsdconfig
new file mode 100755
index 0000000000..a397182672
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-test/src/test/resources/ipo.xsdconfig
@@ -0,0 +1,21 @@
+<!-- Copyright 2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. -->
+<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <xb:namespace uri="http://www.example.com/IPO">
+ <xb:package>com.example.ipo.xmlbeans</xb:package>
+ </xb:namespace>
+
+</xb:config>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/pom.xml
new file mode 100755
index 0000000000..84fcdef7c8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/pom.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>databinding-xmlbeans</artifactId>
+ <name>Apache Tuscany Data Binding for XmlBeans</name>
+ <description>Tuscany XmlBeans Data Binding</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ <version>2.1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/xmlbeans-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-xmlbeans</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <tasks>
+ <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean"
+ classpathref="maven.compile.classpath" />
+ <xmlbean schema="${basedir}/src/test/resources" classpathref="maven.compile.classpath"
+ destfile="${project.build.directory}/ipo-xmlbeans.jar"
+ srcgendir="${project.build.directory}/xmlbeans-source" javasource="1.5"
+ classgendir="${project.build.directory}/test-classes" />
+ </tasks>
+ <testSourceRoot>${project.build.directory}/xmlbeans-source</testSourceRoot>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/Node2XmlObject.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/Node2XmlObject.java
new file mode 100755
index 0000000000..0b4da53473
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/Node2XmlObject.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.xmlbeans;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+@Service(Transformer.class)
+public class Node2XmlObject extends TransformerExtension<Node, XmlObject> implements
+ PullTransformer<Node, XmlObject> {
+ // private XmlOptions options;
+
+ public XmlObject transform(Node source, TransformationContext context) {
+ try {
+ return XmlObject.Factory.parse(source);
+ } catch (XmlException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getTargetType() {
+ return XmlObject.class;
+ }
+
+ public Class getSourceType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 30;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLBeansDataBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLBeansDataBinding.java
new file mode 100644
index 0000000000..12057982e4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLBeansDataBinding.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.databinding.xmlbeans;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * XMLBeans DataBinding
+ */
+public class XMLBeansDataBinding extends DataBindingExtension {
+ public static final String NAME = XmlObject.class.getName();
+
+ public XMLBeansDataBinding() {
+ super(NAME, XmlObject.class);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLStreamReader2XmlObject.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLStreamReader2XmlObject.java
new file mode 100755
index 0000000000..0e61bd9571
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XMLStreamReader2XmlObject.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.xmlbeans;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class XMLStreamReader2XmlObject extends TransformerExtension<XMLStreamReader, XmlObject> implements PullTransformer<XMLStreamReader, XmlObject> {
+ // private XmlOptions options;
+
+ public XmlObject transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ return XmlObject.Factory.parse(source);
+ } catch (XmlException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getTargetType() {
+ return XmlObject.class;
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2Node.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2Node.java
new file mode 100755
index 0000000000..8fc1e58bd5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2Node.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.xmlbeans;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.xmlbeans.XmlObject;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Node;
+
+@Service(Transformer.class)
+public class XmlObject2Node extends TransformerExtension<XmlObject, Node> implements
+ PullTransformer<XmlObject, Node> {
+ // private XmlOptions options;
+
+ public Node transform(XmlObject source, TransformationContext context) {
+ if (source == null)
+ return null;
+ return source.newDomNode();
+ }
+
+ public Class getSourceType() {
+ return XmlObject.class;
+ }
+
+ public Class getTargetType() {
+ return Node.class;
+ }
+
+ public int getWeight() {
+ return 30;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2XMLStreamReader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2XMLStreamReader.java
new file mode 100755
index 0000000000..8a12cf34f0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/java/org/apache/tuscany/databinding/xmlbeans/XmlObject2XMLStreamReader.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.xmlbeans;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.xmlbeans.XmlObject;
+
+public class XmlObject2XMLStreamReader extends TransformerExtension<XmlObject, XMLStreamReader> implements PullTransformer<XmlObject, XMLStreamReader> {
+ // private XmlOptions options;
+
+ public XMLStreamReader transform(XmlObject source, TransformationContext context) {
+ return source.newXMLStreamReader();
+ }
+
+ public Class getSourceType() {
+ return XmlObject.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..55c7363cba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.databinding.XMLBeans">
+
+ <component name="databinding.XMLBeans">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XMLBeansDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2XmlObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject" />
+ </component>
+
+ <component name="transformer.Node2XmlObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.Node2XmlObject" />
+ </component>
+
+ <component name="transformer.XmlObject2Node">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XmlObject2Node" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2XmlObject">
+ <system:implementation.system class="org.apache.tuscany.databinding.xmlbeans.XMLStreamReader2XmlObject" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/java/org/apache/tuscany/databinding/xmlbeans/XmlObjectTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/java/org/apache/tuscany/databinding/xmlbeans/XmlObjectTestCase.java
new file mode 100755
index 0000000000..57fbae7e35
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/java/org/apache/tuscany/databinding/xmlbeans/XmlObjectTestCase.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.databinding.xmlbeans;
+
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Node;
+
+import com.example.ipo.xmlbeans.PurchaseOrderDocument;
+
+public class XmlObjectTestCase extends TestCase {
+ private static final String IPO_XML = "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xmlns:ipo=\"http://www.example.com/IPO\""
+ + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\"" + " orderDate=\"1999-12-01\">"
+ + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">" + " <name>Helen Zoe</name>" + " <street>47 Eden Street</street>"
+ + " <city>Cambridge</city>" + " <postcode>CB1 1JR</postcode>" + " </shipTo>" + " <billTo xsi:type=\"ipo:USAddress\">"
+ + " <name>Robert Smith</name>" + " <street>8 Oak Avenue</street>" + " <city>Old Town</city>" + " <state>PA</state>"
+ + " <zip>95819</zip>" + " </billTo>" + " <items>" + " <item partNum=\"833-AA\">"
+ + " <productName>Lapis necklace</productName>" + " <quantity>1</quantity>" + " <USPrice>99.95</USPrice>"
+ + " <ipo:comment>Want this for the holidays</ipo:comment>" + " <shipDate>1999-12-05</shipDate>" + " </item>" + " </items>"
+ + "</ipo:purchaseOrder>";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testXmlObject() throws Exception {
+ // URL/Stream/Reader to XmlObject
+ XmlObject object = XmlObject.Factory.parse(new StringReader(IPO_XML));
+
+ // XmlObject to XMLStreamReader
+ XmlObject2XMLStreamReader t1 = new XmlObject2XMLStreamReader();
+ XMLStreamReader reader = t1.transform(object, null);
+
+ // XMLStreamReader to XmlObject
+ XMLStreamReader2XmlObject t2 = new XMLStreamReader2XmlObject();
+ XmlObject object2 = t2.transform(reader, null);
+
+ // XmlObject to Node
+ XmlObject2Node t3 = new XmlObject2Node();
+ Node node = t3.transform(object2, null);
+
+ // Node to XmlObject
+ Node2XmlObject t4 = new Node2XmlObject();
+ XmlObject object3 = t4.transform(node, null);
+ Assert.assertNotNull(object3);
+ }
+
+ public void testGeneratedXmlObject() throws Exception {
+ // URL xmlFile = getClass().getClassLoader().getResource("ipo.xml");
+ // URL/Stream/Reader to XmlObject
+ PurchaseOrderDocument object = PurchaseOrderDocument.Factory.parse(new StringReader(IPO_XML));
+
+ // XmlObject to XMLStreamReader
+ XmlObject2XMLStreamReader t1 = new XmlObject2XMLStreamReader();
+ XMLStreamReader reader = t1.transform(object, null);
+
+ // XMLStreamReader to XmlObject
+ XMLStreamReader2XmlObject t2 = new XMLStreamReader2XmlObject();
+ PurchaseOrderDocument object2 = (PurchaseOrderDocument) t2.transform(reader, null);
+
+ // XmlObject to Node
+ XmlObject2Node t3 = new XmlObject2Node();
+ Node node = t3.transform(object2, null);
+
+ // Node to XmlObject
+ Node2XmlObject t4 = new Node2XmlObject();
+ PurchaseOrderDocument object3 = (PurchaseOrderDocument) t4.transform(node, null);
+ Assert.assertNotNull(object3);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsdconfig b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsdconfig
new file mode 100755
index 0000000000..a397182672
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/databinding-xmlbeans/src/test/resources/ipo.xsdconfig
@@ -0,0 +1,21 @@
+<!-- Copyright 2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. -->
+<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <xb:namespace uri="http://www.example.com/IPO">
+ <xb:package>com.example.ipo.xmlbeans</xb:package>
+ </xb:namespace>
+
+</xb:config>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/pom.xml
new file mode 100644
index 0000000000..5c311e470c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/databinding/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Data Bindings</name>
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>databinding-axiom</module>
+ <module>databinding-castor</module>
+ <module>databinding-jaxb</module>
+ <module>databinding-sdo</module>
+ <module>databinding-xmlbeans</module>
+ <module>databinding-test</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>release</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>databinding-axiom</module>
+ <module>databinding-sdo</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/pom.xml
new file mode 100644
index 0000000000..10035bfbd3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Interface Definition Languages</name>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>wsdl</module>
+ </modules>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/pom.xml
new file mode 100644
index 0000000000..6fb9ea427d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>wsdl</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany WSDL</name>
+ <description>Tuscany WSDL Support.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java
new file mode 100644
index 0000000000..1b9326acab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * Introspector for creating WSDLServiceContract definitions from WSDL PortTypes.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InterfaceWSDLIntrospector {
+
+ /**
+ * Introspect a WSDL portType and return a service contract definition.
+ *
+ * @param type the portType to inspect
+ * @return a WSDLServiceContract corresponding to the WSDL portType
+ */
+ WSDLServiceContract introspect(PortType portType) throws InvalidServiceContractException;
+
+ /**
+ * Introspect a WSDL portType and return a service contract definition.
+ *
+ * @param type the portType to inspect
+ * @param callback the callback portType to inspec
+ * @return a WSDLServiceContract corresponding to the WSDL portType
+ */
+ WSDLServiceContract introspect(PortType type, PortType callback) throws InvalidServiceContractException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java
new file mode 100644
index 0000000000..bbfb3b3d01
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Introspector for creating WSDLServiceContract definitions from WSDL PortTypes.
+ */
+public class InterfaceWSDLIntrospectorImpl implements InterfaceWSDLIntrospector {
+ public static final String INPUT_PARTS = "idl:input";
+
+ private WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ /**
+ * @param wsdlDefinitionRegistry
+ */
+ @Constructor("wsdlDefinitionRegistry")
+ public InterfaceWSDLIntrospectorImpl(@Autowire WSDLDefinitionRegistry wsdlDefinitionRegistry) {
+ super();
+ this.wsdlDefinitionRegistry = wsdlDefinitionRegistry;
+ }
+
+ // FIXME: Do we want to deal with document-literal wrapped style based on the JAX-WS spec?
+ protected Map<String, org.apache.tuscany.spi.model.Operation<QName>> introspectOperations(PortType portType)
+ throws InvalidServiceContractException {
+ Map<String, org.apache.tuscany.spi.model.Operation<QName>> operations =
+ new HashMap<String, org.apache.tuscany.spi.model.Operation<QName>>();
+ for (Object op : portType.getOperations()) {
+ Operation wsdlOp = (Operation) op;
+ operations.put(wsdlOp.getName(), introspectOperation(wsdlOp));
+ }
+ return operations;
+ }
+
+ protected org.apache.tuscany.spi.model.Operation<QName> introspectOperation(Operation wsdlOp)
+ throws InvalidServiceContractException {
+
+ WSDLOperation op = new WSDLOperation(wsdlOp, null, wsdlDefinitionRegistry.getSchemaRegistry());
+ return op.getOperation();
+ }
+
+ /**
+ * @see org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospector#introspect(javax.wsdl.PortType)
+ */
+ public WSDLServiceContract introspect(PortType portType) throws InvalidServiceContractException {
+ WSDLServiceContract contract = new WSDLServiceContract();
+ contract.setPortType(portType);
+ contract.setInterfaceName(portType.getQName().getLocalPart());
+ contract.setOperations(introspectOperations(portType));
+ // FIXME: set to Non-conversational for now
+ contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
+ return contract;
+ }
+
+ /**
+ * @see org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospector#introspect(javax.wsdl.PortType, javax.wsdl.PortType)
+ */
+ public WSDLServiceContract introspect(PortType portType, PortType callbackPortType)
+ throws InvalidServiceContractException {
+ assert portType != null : "PortType cannot be null";
+ WSDLServiceContract contract = new WSDLServiceContract();
+ // FIXME: set to Non-conversational for now
+ contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
+ contract.setPortType(portType);
+ contract.setInterfaceName(portType.getQName().getLocalPart());
+ contract.setOperations(introspectOperations(portType));
+ if (callbackPortType != null) {
+ contract.setCallbackPortType(callbackPortType);
+ contract.setCallbackName(callbackPortType.getQName().getLocalPart());
+ contract.setCallbackOperations(introspectOperations(callbackPortType));
+ }
+ return contract;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java
new file mode 100644
index 0000000000..cdb74becfd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Loads a WSDL interface definition from an XML-based assembly file
+ *
+ * @version $Rev$ $Date$
+ */
+public class InterfaceWSDLLoader extends LoaderExtension {
+ public static final QName INTERFACE_WSDL = new QName(XML_NAMESPACE_1_0, "interface.wsdl");
+
+ private static final String WSDLI = "http://www.w3.org/2006/01/wsdl-instance";
+
+ private static final String WSDLI_LOCATION = "wsdlLocation";
+
+ private WSDLDefinitionRegistry wsdlRegistry;
+
+ private InterfaceWSDLIntrospector introspector;
+
+ @Constructor ({ "registry", "wsdlRegistry", "introspector" })
+ public InterfaceWSDLLoader(@Autowire LoaderRegistry registry,
+ @Autowire WSDLDefinitionRegistry wsdlRegistry,
+ @Autowire InterfaceWSDLIntrospector introspector) {
+ super(registry);
+ this.wsdlRegistry = wsdlRegistry;
+ this.introspector = introspector;
+ }
+
+ public QName getXMLType() {
+ return INTERFACE_WSDL;
+ }
+
+ public WSDLServiceContract load(
+ CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ assert INTERFACE_WSDL.equals(reader.getName());
+
+ String interfaceURI = reader.getAttributeValue(null, "interface");
+ if (interfaceURI == null) {
+ throw new InvalidValueException("interface");
+ }
+
+ String callbackURI = reader.getAttributeValue(null, "callbackInterface");
+ String wsdlLocation = reader.getAttributeValue(WSDLI, WSDLI_LOCATION);
+
+ Map<Class<?>, ModelObject> extensions = new HashMap<Class<?>, ModelObject>();
+ while (true) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ ModelObject mo = registry.load(parent, reader, deploymentContext);
+ if (mo != null) {
+ extensions.put(mo.getClass(), mo);
+ }
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
+ if (reader.getName().equals(INTERFACE_WSDL)) {
+ break;
+ }
+ }
+ }
+ // FIXME set the interaction scope
+ // serviceContract.setInteractionScope(StAXUtil.interactionScope(reader.getAttributeValue(null, "scope")));
+
+ if (wsdlLocation != null) {
+ try {
+ wsdlRegistry.loadDefinition(wsdlLocation, deploymentContext.getClassLoader());
+ } catch (IOException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(wsdlLocation);
+ throw le;
+ } catch (WSDLException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(wsdlLocation);
+ throw le;
+ }
+ }
+
+ PortType portType = getPortType(interfaceURI);
+ if (portType == null) {
+ throw new MissingResourceException(interfaceURI);
+ }
+ PortType callback = null;
+ if (callbackURI != null) {
+ callback = getPortType(callbackURI);
+ }
+ try {
+ WSDLServiceContract contract = introspector.introspect(portType, callback);
+ DataType<?> dataType = (DataType<?>) extensions.get(DataType.class);
+ if (dataType != null) {
+ contract.setDataBinding(dataType.getDataBinding());
+ }
+ contract.getExtensions().putAll(extensions);
+ return contract;
+ } catch (InvalidServiceContractException e) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(wsdlLocation);
+ throw le;
+ }
+ }
+
+ protected PortType getPortType(String uri) {
+ // Syntax: <WSDL-namespace-URI>#wsdl.interface(<portTypeOrInterface-name>)
+ int index = uri.indexOf('#');
+ String namespace = uri.substring(0, index);
+ String name = uri.substring(index + 1);
+ name = name.substring("wsdl.interface(".length(), name.length() - 1);
+ QName qname = new QName(namespace, name);
+ return wsdlRegistry.getPortType(qname);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java
new file mode 100644
index 0000000000..55decc9313
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidFragmentException extends WSDLLoaderException {
+ public InvalidFragmentException() {
+ }
+
+ public InvalidFragmentException(String message) {
+ super(message);
+ }
+
+ public InvalidFragmentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidFragmentException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java
new file mode 100644
index 0000000000..17dde17b19
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * An exception to indicate the WSDL definition is invalid
+ */
+public class InvalidWSDLException extends InvalidServiceContractException {
+
+ /**
+ *
+ */
+ public InvalidWSDLException() {
+ }
+
+ /**
+ * @param message
+ */
+ public InvalidWSDLException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public InvalidWSDLException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public InvalidWSDLException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java
new file mode 100644
index 0000000000..7c5ab0bfc1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidWSDLLocationException extends WSDLLoaderException {
+ public InvalidWSDLLocationException() {
+ }
+
+ public InvalidWSDLLocationException(String message) {
+ super(message);
+ }
+
+ public InvalidWSDLLocationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidWSDLLocationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java
new file mode 100644
index 0000000000..92a2b2099e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MissingWSDLException extends WSDLLoaderException {
+ public MissingWSDLException() {
+ }
+
+ public MissingWSDLException(String message) {
+ super(message);
+ }
+
+ public MissingWSDLException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MissingWSDLException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java
new file mode 100644
index 0000000000..0d69d401f8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * An exception to indicate some WSDL styles that we don't support
+ */
+public class NotSupportedWSDLException extends InvalidServiceContractException {
+
+ /**
+ *
+ */
+ public NotSupportedWSDLException() {
+ }
+
+ /**
+ * @param message
+ */
+ public NotSupportedWSDLException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public NotSupportedWSDLException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public NotSupportedWSDLException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java
new file mode 100644
index 0000000000..0454569e87
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UnresolveableResourceException extends WSDLLoaderException {
+ public UnresolveableResourceException() {
+ }
+
+ public UnresolveableResourceException(String message) {
+ super(message);
+ }
+
+ public UnresolveableResourceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnresolveableResourceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java
new file mode 100644
index 0000000000..0694811f0d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.xml.namespace.QName;
+
+/**
+ * A service for caching WSDLs
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public interface WSDLDefinitionRegistry {
+ /**
+ * Loads and registers a WSDL Definition.
+ *
+ * @param namespace the expected namespace, or null if any namespace should be allowed
+ * @param location the location to load the definition from
+ * @return the loaded Definition
+ * @throws IOException if there was a problem reading the document
+ * @throws WSDLException if there was a problem parsing the definition
+ */
+ Definition loadDefinition(String namespace, URL location) throws IOException, WSDLException;
+
+ /**
+ * Load and register a WSDL definition as specified in a WSDL2.0 wsdlLocation attribute.
+ *
+ * @param wsdlLocation the value of the wsdlLocation attribute
+ * @param classLoader application classloader used to support relative locations
+ * @return the loaded Definition
+ * @throws IOException if there was a problem reading the document
+ * @throws WSDLException if there was a problem parsing the definition
+ */
+ Definition loadDefinition(String wsdlLocation, ClassLoader classLoader) throws IOException, WSDLException;
+
+ /**
+ * Returns the PortType with the supplied qualified name, or null if no such port has been defined.
+ *
+ * @param name the qualified name of the WSDL portType
+ * @return the PortType for the supplied name, or null if none has been defined
+ */
+ PortType getPortType(QName name);
+
+ /**
+ * Returns the ServiceDefinition with the supplied qualified name, or null if no such service has been defined.
+ *
+ * @param name the qualified name of the WSDL service
+ * @return the ServiceDefinition for the supplied name, or null if none has been defined
+ */
+ Service getService(QName name);
+
+
+ /**
+ * Returns the ExtensionRegistry that is used when parsing WSDL documents during the loadDefinition call.
+ *
+ * @return the ExtensionRegistry that is used when parsing WSDL documents.
+ */
+ ExtensionRegistry getExtensionRegistry();
+
+ /**
+ * Get the XMLSchemaRegistry
+ *
+ * @return
+ */
+ XMLSchemaRegistry getSchemaRegistry();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java
new file mode 100644
index 0000000000..976a09caca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * The default implementation of the runtime WSDL registry
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLDefinitionRegistryImpl implements WSDLDefinitionRegistry {
+ private final WSDLFactory wsdlFactory;
+
+ private final ExtensionRegistry registry;
+
+ private final Map<URL, Definition> definitionsByLocation = new HashMap<URL, Definition>();
+
+ private final Map<String, List<Definition>> definitionsByNamespace = new HashMap<String, List<Definition>>();
+
+ private Monitor monitor;
+
+ private XMLSchemaRegistry schemaRegistry;
+
+ public WSDLDefinitionRegistryImpl() throws WSDLException {
+ wsdlFactory = WSDLFactory.newInstance();
+ registry = wsdlFactory.newPopulatedExtensionRegistry();
+ }
+
+ @Autowire
+ public void setSchemaRegistry(XMLSchemaRegistry schemaRegistry) {
+ this.schemaRegistry = schemaRegistry;
+ }
+
+ @org.apache.tuscany.api.annotation.Monitor
+ public void setMonitor(Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ public ExtensionRegistry getExtensionRegistry() {
+ return registry;
+ }
+
+ public Definition loadDefinition(String wsdlLocation, ClassLoader classLoader) throws IOException, WSDLException {
+ int index = wsdlLocation.indexOf(' ');
+ if (index == -1) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Invalid wsdlLocation: " + wsdlLocation);
+ }
+ String namespace = wsdlLocation.substring(0, index).trim();
+ URL url;
+ URI uri;
+ try {
+ uri = new URI(wsdlLocation.substring(index + 1).trim());
+ } catch (URISyntaxException e) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Invalid wsdlLocation: " + wsdlLocation);
+ }
+ if (uri.isAbsolute()) {
+ url = uri.toURL();
+ } else {
+ url = classLoader.getResource(uri.toString());
+ if (url == null) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Resource not found: " + uri);
+ }
+ }
+ return loadDefinition(namespace, url);
+ }
+
+ public Definition loadDefinition(String namespace, URL location) throws IOException, WSDLException {
+ Definition definition = definitionsByLocation.get(location);
+ if (definition != null) {
+ // return cached copy
+ return definition;
+ }
+
+ if (monitor != null) {
+ monitor.readingWSDL(namespace, location);
+ }
+ WSDLReader reader = wsdlFactory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ reader.setExtensionRegistry(registry);
+
+ definition = reader.readWSDL(location.toString());
+ String definitionNamespace = definition.getTargetNamespace();
+ if (namespace != null && !namespace.equals(definitionNamespace)) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, namespace + " != "
+ + definition.getTargetNamespace());
+ }
+
+ // Load inline schemas
+ getSchemaRegistry().loadSchemas(definition);
+ for (Object i : definition.getImports().values()) {
+ Import imp = (Import) i;
+ Definition imported = imp.getDefinition();
+ if (imported != null) {
+ getSchemaRegistry().loadSchemas(imported);
+ }
+ }
+
+ if (monitor != null) {
+ monitor.cachingDefinition(definitionNamespace, location);
+ }
+ definitionsByLocation.put(location, definition);
+ List<Definition> definitions = definitionsByNamespace.get(definitionNamespace);
+ if (definitions == null) {
+ definitions = new ArrayList<Definition>();
+ definitionsByNamespace.put(definitionNamespace, definitions);
+ }
+ definitions.add(definition);
+
+ return definition;
+ }
+
+ public PortType getPortType(QName name) {
+ String namespace = name.getNamespaceURI();
+ List<Definition> definitions = definitionsByNamespace.get(namespace);
+ if (definitions == null) {
+ return null;
+ }
+ for (Definition definition : definitions) {
+ PortType portType = definition.getPortType(name);
+ if (portType != null) {
+ return portType;
+ }
+ }
+ return null;
+ }
+
+ public Service getService(QName name) {
+ String namespace = name.getNamespaceURI();
+ List<Definition> definitions = definitionsByNamespace.get(namespace);
+ if (definitions == null) {
+ return null;
+ }
+ for (Definition definition : definitions) {
+ Service service = definition.getService(name);
+ if (service != null) {
+ return service;
+ }
+ }
+ return null;
+ }
+
+ public static interface Monitor {
+ /**
+ * Monitor event emitted immediately before an attempt is made to read WSDL for the supplied namespace from the
+ * supplied location.
+ *
+ * @param namespace the target namespace expected in the WSDL; may be null
+ * @param location the location where we will attempt to read the WSDL definition from
+ */
+ void readingWSDL(String namespace, URL location);
+
+ /**
+ * Monitor event emitted immediately before registering a WSDL definition in the cache.
+ *
+ * @param namespace the target namespace for the WSDL
+ * @param location the location where the WSDL definition was read from
+ */
+ void cachingDefinition(String namespace, URL location);
+ }
+
+ public XMLSchemaRegistry getSchemaRegistry() {
+ if (schemaRegistry == null) {
+ // Default
+ schemaRegistry = new XMLSchemaRegistryImpl();
+ }
+ return schemaRegistry;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java
new file mode 100644
index 0000000000..fb90e839f5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.URI;
+import java.util.Collection;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+/**
+ * Interface for implementations that allow WSDL definitions to be loaded. Currently we do not have a complete solution
+ * for handling both WSDL2.0 and WSDL1.1 definitions so the current implementation only deals with loading WSDL1.1. This
+ * will change in the near future (for example when Woden supports both forms) so all WSDL1.1 specific methods are
+ * deprecated.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WSDLLoader {
+ /**
+ * Load a WSDL 1.1 Definition for a namespace from one of specified locations.
+ *
+ * @param namespace the namespace whose definition should be loaded
+ * @param locations a set of possible locations to load from
+ * @return the loaded Definition
+ * @throws WSDLException if there was a problem loading the definition
+ */
+ @Deprecated
+ Definition loadDefinition(String namespace, Collection<WSDLLocation> locations)
+ throws WSDLException, UnresolveableResourceException;
+
+ /**
+ * Load a WSDL 1.1 Definition from the specified location
+ *
+ * @param location the location to load from
+ * @return the loaded Definition
+ * @throws WSDLException if there was a problem loading the definition
+ */
+ @Deprecated
+ Definition loadDefinition(WSDLLocation location) throws WSDLException;
+
+ /**
+ * Return the WSDL1.1 PortType for the specified interface IRI.
+ *
+ * @param interfaceIRI the WSDL2.0 interface IRI
+ * @param wsdlLocation the location of the WSDL instance
+ * @param base a Classloader from which to load
+ * @return the specified port type
+ */
+ @Deprecated
+ PortType loadPortType(URI interfaceIRI, String wsdlLocation, ClassLoader base)
+ throws WSDLLoaderException, WSDLException;
+
+ /**
+ * Parses a WSDL2.0 wsdlLocation attribute definition and returns a Collection of all locations it contains.
+ *
+ * @param wsdlLocation a list of namespace/location pairs as specified by WSDL2.0
+ * @param base a ClassLoader to use to resolve relative URLs
+ * @return a collection of locations parsed from the string
+ * @throws InvalidWSDLLocationException
+ */
+ Collection<WSDLLocation> getLocations(String wsdlLocation, ClassLoader base) throws InvalidWSDLLocationException;
+
+ /**
+ * Returns the fully qualified name of a WSDL interface parsed from a IRI as defined by WSDL2.0. The value of the
+ * IRI defines the namespace, the fragment specifies the interface component; for example
+ * <code>http://example.org/TicketAgent.wsdl20#wsdl.interface(TicketAgent)</code>
+ *
+ * @param interfaceIRI the IRI for the interface
+ * @return the qualified name of the interface
+ * @throws UnresolveableResourceException if the URI is relative
+ * @throws InvalidFragmentException if the fragment is incorrectly formed
+ */
+ QName getInterfaceName(URI interfaceIRI) throws UnresolveableResourceException, InvalidFragmentException;
+
+ /**
+ * Returns an interface parsed from a wsdl.interface fragment.
+ *
+ * @param fragment the fragment value
+ * @return the interface name
+ * @throws InvalidFragmentException if the fragment is incorrectly formed
+ */
+ String getInterfaceName(String fragment) throws InvalidFragmentException;
+
+ /**
+ * Returns a namespace parsed from an IRI. This is the URI with any fragment removed.
+ *
+ * @param iri the IRI
+ * @return a namespace created by stripping fragment information from the URI
+ * @throws UnresolveableResourceException if the URI is relative
+ */
+ String getNamespace(URI iri) throws UnresolveableResourceException;
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java
new file mode 100644
index 0000000000..47a4b8ef1f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class WSDLLoaderException extends TuscanyException {
+ protected WSDLLoaderException() {
+ }
+
+ protected WSDLLoaderException(String message) {
+ super(message);
+ }
+
+ protected WSDLLoaderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected WSDLLoaderException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java
new file mode 100644
index 0000000000..cdf69fa1e8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WSDLLoaderImpl implements WSDLLoader {
+ private final WSDLFactory wsdlFactory;
+
+ private final ExtensionRegistry registry;
+
+ public WSDLLoaderImpl() throws WSDLException {
+ wsdlFactory = WSDLFactory.newInstance();
+ registry = wsdlFactory.newPopulatedExtensionRegistry();
+ }
+
+ public PortType loadPortType(URI interfaceIRI, String wsdlLocation, ClassLoader base)
+ throws WSDLLoaderException, WSDLException {
+ Collection<WSDLLocation> locations = getLocations(wsdlLocation, base);
+ QName interfaceName = getInterfaceName(interfaceIRI);
+
+ Definition definition = loadDefinition(interfaceName.getNamespaceURI(), locations);
+ return definition.getPortType(interfaceName);
+ }
+
+ public Definition loadDefinition(String namespace, Collection<WSDLLocation> locations)
+ throws WSDLException, UnresolveableResourceException {
+ for (WSDLLocation location : locations) {
+ if (namespace.equals(location.getNamespace()) && location.getLocation() != null) {
+ return loadDefinition(location);
+ }
+ }
+ throw new UnresolveableResourceException(namespace);
+ }
+
+ public Definition loadDefinition(WSDLLocation location) throws WSDLException {
+ String namespace = location.getNamespace();
+
+ WSDLReader reader = wsdlFactory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ reader.setExtensionRegistry(registry);
+
+ Definition definition = reader.readWSDL(location.getLocation().toString());
+ String definitionNamespace = definition.getTargetNamespace();
+ if (namespace != null && !namespace.equals(definitionNamespace)) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, namespace + " != "
+ + definition.getTargetNamespace());
+ }
+ return definition;
+ }
+
+ public Collection<WSDLLocation> getLocations(String wsdlLocation, ClassLoader base)
+ throws InvalidWSDLLocationException {
+ String parts[] = wsdlLocation.split("\\s");
+ // check the number of parts is a multiple of two
+ if ((parts.length & 1) != 0) {
+ throw new InvalidWSDLLocationException(wsdlLocation);
+ }
+ List<WSDLLocation> locations = new ArrayList<WSDLLocation>(parts.length >>> 1);
+ for (int i = 0; i < parts.length; i += 2) {
+ URL url;
+ try {
+ URI uri = new URI(parts[i + 1]);
+ if (uri.isAbsolute()) {
+ url = uri.toURL();
+ } else {
+ url = base.getResource(uri.toString());
+ }
+ } catch (MalformedURLException e) {
+ throw new InvalidWSDLLocationException(e);
+ } catch (URISyntaxException e) {
+ throw new InvalidWSDLLocationException(e);
+ }
+ WSDLLocation location = new WSDLLocation(parts[i], url);
+ locations.add(location);
+ }
+ return locations;
+ }
+
+ public QName getInterfaceName(URI interfaceIRI) throws UnresolveableResourceException, InvalidFragmentException {
+ String namespace = getNamespace(interfaceIRI);
+ String interfaceName = getInterfaceName(interfaceIRI.getFragment());
+ return new QName(namespace, interfaceName);
+ }
+
+ public String getInterfaceName(String fragment) throws InvalidFragmentException {
+ if (fragment == null) {
+ throw new InvalidFragmentException("missing fragment");
+ }
+ String[] parts = fragment.split("\\s");
+ for (String part : parts) {
+ if (part.startsWith("wsdl.interface(") && part.charAt(part.length() - 1) == ')') {
+ return part.substring(15, part.length() - 1);
+ }
+ }
+ throw new InvalidFragmentException(fragment);
+ }
+
+ public String getNamespace(URI iri) throws UnresolveableResourceException {
+ if (!iri.isAbsolute()) {
+ UnresolveableResourceException ure = new UnresolveableResourceException("no namespace defined in " + iri);
+ ure.setIdentifier(iri.toString());
+ throw ure;
+ }
+ StringBuilder s = new StringBuilder();
+ s.append(iri.getScheme());
+ s.append(':');
+ s.append(iri.getSchemeSpecificPart());
+ return s.toString();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java
new file mode 100644
index 0000000000..a124294c3a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.URL;
+
+/**
+ * A location where the WSDL for a namespace can be found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLLocation {
+ private final String namespace;
+ private final URL location;
+
+ /**
+ * Constructor specifying a namespace and where its WSDL can be found.
+ *
+ * @param namespace the target namespace
+ * @param location the location of the WSDL
+ */
+ public WSDLLocation(String namespace, URL location) {
+ this.namespace = namespace;
+ this.location = location;
+ }
+
+ /**
+ * Returns the target namespace.
+ *
+ * @return the target namespace
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * Returns the location where the WSDL definition can be found.
+ *
+ * @return the location where the WSDL definition can be found
+ */
+ public URL getLocation() {
+ return location;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java
new file mode 100644
index 0000000000..75fe1b9964
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java
@@ -0,0 +1,500 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.idl.WrapperInfo;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * Metadata for a WSDL operation
+ */
+public class WSDLOperation {
+ private static final String OPERATION_KEY = org.apache.tuscany.spi.model.Operation.class.getName();
+
+ protected XMLSchemaRegistry schemaRegistry;
+
+ protected Operation operation;
+
+ private String dataBinding;
+
+ protected org.apache.tuscany.spi.model.Operation<QName> operationModel;
+
+ protected DataType<List<DataType<QName>>> inputType;
+
+ protected DataType<QName> outputType;
+
+ protected List<DataType<QName>> faultTypes;
+
+ /**
+ * @param operation The WSDL4J operation
+ * @param dataBinding The default databinding
+ * @param schemaRegistry The XML Schema registry
+ */
+ public WSDLOperation(Operation operation, String dataBinding, XMLSchemaRegistry schemaRegistry) {
+ super();
+ this.operation = operation;
+ this.dataBinding = dataBinding;
+ this.schemaRegistry = schemaRegistry;
+ this.wrapper = new Wrapper();
+ }
+
+ private Wrapper wrapper;
+
+ private Boolean wrapperStyle;
+
+ /**
+ * Test if the operation qualifies wrapper style as defined by the JAX-WS 2.0 spec
+ *
+ * @return true if the operation qualifies wrapper style, otherwise false
+ */
+ public boolean isWrapperStyle() {
+ if (wrapperStyle == null) {
+ wrapperStyle =
+ Boolean.valueOf(wrapper.getInputChildElements() != null
+ && (operation.getOutput() == null || wrapper.getOutputChildElements() != null));
+ }
+ return wrapperStyle.booleanValue();
+ }
+
+ public Wrapper getWrapper() {
+ if (!isWrapperStyle()) {
+ throw new IllegalStateException("The operation is not wrapper style.");
+ } else {
+ return wrapper;
+ }
+ }
+
+ /**
+ * @return
+ * @throws InvalidServiceContractException
+ */
+ public DataType<List<DataType<QName>>> getInputType() throws InvalidServiceContractException {
+ if (inputType == null) {
+ Input input = operation.getInput();
+ Message message = (input == null) ? null : input.getMessage();
+ inputType = getMessageType(message);
+ inputType.setDataBinding("idl:input");
+ }
+ return inputType;
+ }
+
+ /**
+ * @return
+ * @throws NotSupportedWSDLException
+ */
+ public DataType<QName> getOutputType() throws InvalidServiceContractException {
+ if (outputType == null) {
+ Output output = operation.getOutput();
+ Message outputMsg = (output == null) ? null : output.getMessage();
+
+ List outputParts = (outputMsg == null) ? null : outputMsg.getOrderedParts(null);
+ if (outputParts != null && outputParts.size() > 0) {
+ if (outputParts.size() > 1) {
+ // We don't support output with multiple parts
+ throw new NotSupportedWSDLException("Multi-part output is not supported");
+ }
+ Part part = (Part) outputParts.get(0);
+ outputType = new WSDLPart(part).getDataType();
+ // outputType.setMetadata(WSDLOperation.class.getName(), this);
+ }
+ }
+ return outputType;
+ }
+
+ /**
+ * @return
+ * @throws NotSupportedWSDLException
+ */
+ public List<DataType<QName>> getFaultTypes() throws InvalidServiceContractException {
+ if (faultTypes == null) {
+ Collection faults = operation.getFaults().values();
+ faultTypes = new ArrayList<DataType<QName>>();
+ for (Object f : faults) {
+ Fault fault = (Fault) f;
+ Message faultMsg = fault.getMessage();
+ List faultParts = faultMsg.getOrderedParts(null);
+ if (faultParts.size() != 1) {
+ throw new NotSupportedWSDLException("The fault message MUST have a single part");
+ }
+ Part part = (Part) faultParts.get(0);
+ WSDLPart wsdlPart = new WSDLPart(part);
+ faultTypes.add(wsdlPart.getDataType());
+ }
+ }
+ return faultTypes;
+ }
+
+ private DataType<List<DataType<QName>>> getMessageType(Message message) throws InvalidServiceContractException {
+ List<DataType<QName>> partTypes = new ArrayList<DataType<QName>>();
+ if (message != null) {
+ Collection parts = message.getOrderedParts(null);
+ for (Object p : parts) {
+ WSDLPart part = new WSDLPart((Part) p);
+ DataType<QName> partType = part.getDataType();
+ partTypes.add(partType);
+ }
+ }
+ return new DataType<List<DataType<QName>>>(dataBinding, Object[].class, partTypes);
+ }
+
+ /**
+ * @return
+ * @throws NotSupportedWSDLException
+ */
+ public org.apache.tuscany.spi.model.Operation<QName> getOperation() throws InvalidServiceContractException {
+ if (operationModel == null) {
+ boolean oneway = (operation.getOutput() == null);
+ operationModel =
+ new org.apache.tuscany.spi.model.Operation<QName>(operation.getName(), getInputType(),
+ getOutputType(), getFaultTypes(), oneway, dataBinding);
+ operationModel.setWrapperStyle(isWrapperStyle());
+ // operationModel.setMetaData(WSDLOperation.class.getName(), this);
+ if (isWrapperStyle()) {
+ operationModel.setWrapper(getWrapper().getWrapperInfo());
+ // Register the operation with the types
+ for (DataType<?> d : wrapper.getUnwrappedInputType().getLogical()) {
+ d.setMetadata(OPERATION_KEY, operationModel);
+ }
+ if (wrapper.getUnwrappedOutputType() != null) {
+ wrapper.getUnwrappedOutputType().setMetadata(OPERATION_KEY, operationModel);
+ }
+ }
+ }
+ inputType.setMetadata(OPERATION_KEY, operationModel);
+ if (outputType != null) {
+ outputType.setMetadata(OPERATION_KEY, operationModel);
+ }
+ return operationModel;
+ }
+
+ /**
+ * Metadata for a WSDL part
+ */
+ public class WSDLPart {
+ private Part part;
+
+ private XmlSchemaElement element;
+
+ private DataType<QName> dataType;
+
+ public WSDLPart(Part part) throws InvalidWSDLException {
+ this.part = part;
+ QName elementName = part.getElementName();
+ if (elementName != null) {
+ element = schemaRegistry.getElement(elementName);
+ if (element == null) {
+ throw new InvalidWSDLException("Element cannot be resolved: " + elementName);
+ }
+ } else {
+ // Create an faked XSD element to host the metadata
+ element = new XmlSchemaElement();
+ element.setName(part.getName());
+ element.setQName(new QName(null, part.getName()));
+ QName typeName = part.getTypeName();
+ if (typeName != null) {
+ XmlSchemaType type = schemaRegistry.getType(typeName);
+ if (type == null) {
+ throw new InvalidWSDLException("Type cannot be resolved: " + typeName);
+ }
+ element.setSchemaType(type);
+ element.setSchemaTypeName(type.getQName());
+ }
+ }
+ dataType = new DataType<QName>(dataBinding, Object.class, element.getQName());
+ // dataType.setMetadata(WSDLPart.class.getName(), this);
+ dataType.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
+ }
+
+ /**
+ * @return the element
+ */
+ public XmlSchemaElement getElement() {
+ return element;
+ }
+
+ /**
+ * @return the part
+ */
+ public Part getPart() {
+ return part;
+ }
+
+ /**
+ * @return the dataType
+ */
+ public DataType<QName> getDataType() {
+ return dataType;
+ }
+ }
+
+ /**
+ * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based Web Services (JAX-WS) 2.0
+ * specification, section 2.3.1.2 Wrapper Style.
+ * <p>
+ * A WSDL operation qualifies for wrapper style mapping only if the following criteria are met:
+ * <ul>
+ * <li>(i) The operation’s input and output messages (if present) each contain only a single part
+ * <li>(ii) The input message part refers to a global element declaration whose localname is equal to the operation
+ * name
+ * <li>(iii) The output message part refers to a global element declaration
+ * <li>(iv) The elements referred to by the input and output message parts (henceforth referred to as wrapper
+ * elements) are both complex types defined using the xsd:sequence compositor
+ * <li>(v) The wrapper elements only contain child elements, they must not contain other structures such as
+ * wildcards (element or attribute), xsd:choice, substitution groups (element references are not permitted) or
+ * attributes; furthermore, they must not be nillable.
+ * </ul>
+ */
+ public class Wrapper {
+ private XmlSchemaElement inputWrapperElement;
+
+ private XmlSchemaElement outputWrapperElement;
+
+ private List<XmlSchemaElement> inputElements;
+
+ private List<XmlSchemaElement> outputElements;
+
+ private DataType<List<DataType<QName>>> unwrappedInputType;
+
+ private DataType<QName> unwrappedOutputType;
+
+ private transient WrapperInfo wrapperInfo;
+
+ private List<XmlSchemaElement> getChildElements(XmlSchemaElement element) {
+ if (element == null) {
+ return null;
+ }
+ XmlSchemaType type = element.getSchemaType();
+ if (!(type instanceof XmlSchemaComplexType)) {
+ // Has to be a complexType
+ return null;
+ }
+ XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+ if (complexType.getAttributes().getCount() != 0 || complexType.getAnyAttribute() != null) {
+ // No attributes
+ return null;
+ }
+ XmlSchemaParticle particle = complexType.getParticle();
+ if (particle == null) {
+ // No particle
+ return Collections.emptyList();
+ }
+ if (!(particle instanceof XmlSchemaSequence)) {
+ return null;
+ }
+ XmlSchemaSequence sequence = (XmlSchemaSequence) complexType.getParticle();
+ XmlSchemaObjectCollection items = sequence.getItems();
+ List<XmlSchemaElement> childElements = new ArrayList<XmlSchemaElement>();
+ for (int i = 0; i < items.getCount(); i++) {
+ XmlSchemaObject schemaObject = items.getItem(i);
+ if (!(schemaObject instanceof XmlSchemaElement)) {
+ return null;
+ }
+ XmlSchemaElement childElement = (XmlSchemaElement) schemaObject;
+ if (childElement.getName() == null || childElement.getRefName() != null || childElement.isNillable()) {
+ return null;
+ }
+ // TODO: Do we support maxOccurs >1 ?
+ if (childElement.getMaxOccurs() > 1) {
+ return null;
+ }
+ childElements.add(childElement);
+ }
+ return childElements;
+ }
+
+ /**
+ * Return a list of child XSD elements under the wrapped request element
+ *
+ * @return a list of child XSD elements or null if if the request element is not wrapped
+ */
+ public List<XmlSchemaElement> getInputChildElements() {
+ if (inputElements != null) {
+ return inputElements;
+ }
+ Input input = operation.getInput();
+ if (input != null) {
+ Message inputMsg = input.getMessage();
+ Collection parts = inputMsg.getParts().values();
+ if (parts.size() != 1) {
+ return null;
+ }
+ Part part = (Part) parts.iterator().next();
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ return null;
+ }
+ if (!operation.getName().equals(elementName.getLocalPart())) {
+ return null;
+ }
+ inputWrapperElement = schemaRegistry.getElement(elementName);
+ if (inputWrapperElement == null) {
+ return null;
+ }
+ inputElements = getChildElements(inputWrapperElement);
+ return inputElements;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Return a list of child XSD elements under the wrapped response element
+ *
+ * @return a list of child XSD elements or null if if the response element is not wrapped
+ */
+ public List<XmlSchemaElement> getOutputChildElements() {
+ if (outputElements != null) {
+ return outputElements;
+ }
+ Output output = operation.getOutput();
+ if (output != null) {
+ Message outputMsg = output.getMessage();
+ Collection parts = outputMsg.getParts().values();
+ if (parts.size() != 1) {
+ return null;
+ }
+ Part part = (Part) parts.iterator().next();
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ return null;
+ }
+ outputWrapperElement = schemaRegistry.getElement(elementName);
+ if (outputWrapperElement == null) {
+ return null;
+ }
+ outputElements = getChildElements(outputWrapperElement);
+ // FIXME: Do we support multiple child elements for the response?
+ return outputElements;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the inputWrapperElement
+ */
+ public XmlSchemaElement getInputWrapperElement() {
+ return inputWrapperElement;
+ }
+
+ /**
+ * @return the outputWrapperElement
+ */
+ public XmlSchemaElement getOutputWrapperElement() {
+ return outputWrapperElement;
+ }
+
+ public DataType<List<DataType<QName>>> getUnwrappedInputType() {
+ if (unwrappedInputType == null) {
+ List<DataType<QName>> childTypes = new ArrayList<DataType<QName>>();
+ for (XmlSchemaElement element : getInputChildElements()) {
+ DataType<QName> type = new DataType<QName>(dataBinding, Object.class, element.getQName());
+ type.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
+ childTypes.add(type);
+ }
+ unwrappedInputType =
+ new DataType<List<DataType<QName>>>("idl:unwrapped.input", Object[].class, childTypes);
+ }
+ return unwrappedInputType;
+ }
+
+ public DataType<QName> getUnwrappedOutputType() throws InvalidServiceContractException {
+ if (unwrappedOutputType == null) {
+ List<XmlSchemaElement> elements = getOutputChildElements();
+ if (elements != null && elements.size() > 0) {
+ if (elements.size() > 1) {
+ // We don't support output with multiple parts
+ throw new NotSupportedWSDLException("Multi-part output is not supported");
+ }
+ XmlSchemaElement element = elements.get(0);
+ unwrappedOutputType = new DataType<QName>(dataBinding, Object.class, element.getQName());
+ unwrappedOutputType.setMetadata(ElementInfo.class.getName(), getElementInfo(element));
+ }
+ }
+ return unwrappedOutputType;
+ }
+
+ public WrapperInfo getWrapperInfo() throws InvalidServiceContractException {
+ if (wrapperInfo == null) {
+ ElementInfo in = getElementInfo(getInputWrapperElement());
+ ElementInfo out = getElementInfo(getOutputWrapperElement());
+ List<ElementInfo> inChildren = new ArrayList<ElementInfo>();
+ for (XmlSchemaElement e : getInputChildElements()) {
+ inChildren.add(getElementInfo(e));
+ }
+ List<ElementInfo> outChildren = new ArrayList<ElementInfo>();
+ if (out != null) {
+ for (XmlSchemaElement e : getOutputChildElements()) {
+ outChildren.add(getElementInfo(e));
+ }
+ }
+ wrapperInfo =
+ new WrapperInfo(in, out, inChildren, outChildren, getUnwrappedInputType(), getUnwrappedOutputType());
+ }
+ return wrapperInfo;
+ }
+ }
+
+ private static ElementInfo getElementInfo(XmlSchemaElement element) {
+ if (element == null) {
+ return null;
+ }
+ return new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType()));
+ }
+
+ private static TypeInfo getTypeInfo(XmlSchemaType type) {
+ if (type == null) {
+ return null;
+ }
+ XmlSchemaType baseType = (XmlSchemaType) type.getBaseSchemaType();
+ QName name = type.getQName();
+ boolean simple = (type instanceof XmlSchemaSimpleType);
+ if (baseType == null) {
+ return new TypeInfo(name, simple, null);
+ } else {
+ return new TypeInfo(name, simple, getTypeInfo(baseType));
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java
new file mode 100644
index 0000000000..868ad0f3b4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Represents a service contract specified by a WSDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLServiceContract extends ServiceContract<QName> {
+ private PortType portType;
+ private PortType callbackPortType;
+
+ /**
+ *
+ */
+ public WSDLServiceContract() {
+ super();
+ this.remotable = true; // WSDL interface is always remotable by the SCA spec
+ }
+
+
+ public PortType getPortType() {
+ return portType;
+ }
+
+ public void setPortType(PortType portType) {
+ this.portType = portType;
+ }
+
+ public PortType getCallbackPortType() {
+ return callbackPortType;
+ }
+
+ public void setCallbackPortType(PortType callbackPortType) {
+ this.callbackPortType = callbackPortType;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java
new file mode 100644
index 0000000000..681e08be4d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaException;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * A service for caching XML Schemas
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XMLSchemaRegistry {
+ /**
+ * Load all inline schemas from the WSDL definition
+ *
+ * @param definition The WSDL defintion whose types element contains a list of schemas
+ * @return A list of inline schemas
+ */
+ List<XmlSchema> loadSchemas(Definition definition);
+
+ /**
+ * Loads and registers a XML schema.
+ *
+ * @param namespace the expected namespace, or null if any namespace should be allowed
+ * @param location the location to load the schema from
+ * @return the loaded Definition
+ * @throws IOException if there was a problem reading the document
+ * @throws XmlSchemaException if there was a problem parsing the schema
+ */
+ XmlSchema loadSchema(String namespace, URL location) throws IOException, XmlSchemaException;
+
+ /**
+ * Load and register a XML schema as specified in a XSD schemaLocation attribute.
+ *
+ * @param schemaLocation the value of the schemaLocation attribute
+ * @param classLoader application classloader used to support relative locations
+ * @return the loaded schema
+ * @throws IOException if there was a problem reading the document
+ * @throws XmlSchemaException if there was a problem parsing the schema
+ */
+ XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException;
+
+ /**
+ * Returns the XSD Element with the supplied qualified name, or null if no such element has been defined.
+ *
+ * @param name the qualified name of the XSD element
+ * @return the XSD element for the supplied name, or null if none has been defined
+ */
+ XmlSchemaElement getElement(QName name);
+
+ /**
+ * Returns the XmlSchemaType with the supplied qualified name, or null if no such type has been defined.
+ *
+ * @param name the qualified name of the XSD type
+ * @return the XSD type for the supplied name, or null if none has been defined
+ */
+ XmlSchemaType getType(QName name);
+
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java
new file mode 100644
index 0000000000..08600e4b7e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.schema.Schema;
+import javax.xml.namespace.QName;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaException;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.osoa.sca.annotations.Service;
+import org.w3c.dom.Element;
+
+/**
+ * Default implementation of XMLSchemaRegistry
+ */
+@Service(XMLSchemaRegistry.class)
+public class XMLSchemaRegistryImpl implements XMLSchemaRegistry {
+ private final XmlSchemaCollection collection;
+
+ /**
+ * @param collection
+ */
+ public XMLSchemaRegistryImpl(XmlSchemaCollection collection) {
+ super();
+ this.collection = collection;
+ }
+
+ public XMLSchemaRegistryImpl() {
+ super();
+ this.collection = new XmlSchemaCollection();
+ }
+
+ public XmlSchemaElement getElement(QName name) {
+ return collection.getElementByQName(name);
+ }
+
+ public XmlSchemaType getType(QName name) {
+ return collection.getTypeByQName(name);
+ }
+
+ public List<XmlSchema> loadSchemas(Definition definition) {
+ Types types = definition.getTypes();
+ if (types == null) {
+ return Collections.emptyList();
+ }
+ List<XmlSchema> schemas = new ArrayList<XmlSchema>();
+ for (Object ext : types.getExtensibilityElements()) {
+ if (ext instanceof Schema) {
+ Element element = ((Schema) ext).getElement();
+ XmlSchema s = collection.read(element, element.getBaseURI());
+ schemas.add(s);
+ }
+ }
+ return schemas;
+ }
+
+ public XmlSchema loadSchema(String namespace, URL location) throws IOException, XmlSchemaException {
+ XmlSchema schema;
+ XmlSchema[] schemaList = collection.getXmlSchema(location.toExternalForm());
+ if (schemaList != null && schemaList.length > 0) {
+ schema = schemaList[0];
+ } else {
+ InputStream is = location.openStream();
+ schema = collection.read(new InputStreamReader(is), null);
+ is.close();
+ }
+ if (namespace != null && schema != null && !namespace.equals(schema.getTargetNamespace())) {
+ throw new XmlSchemaException(namespace + " != " + schema.getTargetNamespace());
+ }
+ return schema;
+ }
+
+ public XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException {
+ int index = schemaLocation.indexOf(' ');
+ if (index == -1) {
+ throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation);
+ }
+ String namespace = schemaLocation.substring(0, index).trim();
+ URL url;
+ URI uri;
+ try {
+ uri = new URI(schemaLocation.substring(index + 1).trim());
+ } catch (URISyntaxException e) {
+ throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation);
+ }
+ if (uri.isAbsolute()) {
+ url = uri.toURL();
+ } else {
+ url = classLoader.getResource(uri.toString());
+ if (url == null) {
+ throw new XmlSchemaException("Resource cannot be resolved: schemaLocation: " + schemaLocation);
+ }
+ }
+ return loadSchema(namespace, url);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..142df15171
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ IDL WSDL extension
+
+ $Rev: 440894 $ $Date: 2006-09-06 15:52:01 -0700 (Wed, 06 Sep 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.idl.wsdl">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.idl</group>
+ <name>wsdl</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="interface.wsdl.Loader">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLLoader" />
+ </component>
+
+ <component name="wsdl.Registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl" initLevel="40" />
+ </component>
+
+ <component name="xmlSchema.registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl" initLevel="35" />
+ </component>
+
+ <component name="interface.wsdl.Introspector">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospectorImpl" initLevel="40" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl
new file mode 100644
index 0000000000..28b3458bf1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ IDL WSDL extension
+
+ This is a copy to be included by other extensions
+
+ $Rev: 440894 $ $Date: 2006-09-06 15:52:01 -0700 (Wed, 06 Sep 2006) $
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.idl.wsdl.include">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.idl</group>
+ <name>wsdl</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="interface.wsdl.Loader">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLLoader" />
+ </component>
+
+ <component name="wsdl.Registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl" initLevel="40" />
+ </component>
+
+ <component name="xmlSchema.registry">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl" initLevel="35" />
+ </component>
+
+ <component name="interface.wsdl.Introspector">
+ <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospectorImpl" initLevel="40" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java
new file mode 100644
index 0000000000..8f263607e0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * Test case for InterfaceWSDLIntrospectorImpl
+ */
+public class InterfaceWSDLIntrospectorImplTestCase extends TestCase {
+ private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+ private WSDLDefinitionRegistryImpl registry;
+ private PortType portType;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new WSDLDefinitionRegistryImpl();
+ registry.setSchemaRegistry(new XMLSchemaRegistryImpl());
+ URL url = getClass().getResource("stockquote.wsdl");
+ Definition definition = registry.loadDefinition(null, url);
+ portType = definition.getPortType(PORTTYPE_NAME);
+ }
+
+ public final void testIntrospectPortType() throws InvalidServiceContractException {
+ InterfaceWSDLIntrospector introspector = new InterfaceWSDLIntrospectorImpl(registry);
+ WSDLServiceContract contract = introspector.introspect(portType);
+ Assert.assertEquals(contract.getInterfaceName(), "StockQuotePortType");
+ Map<String, Operation<QName>> operations = contract.getOperations();
+ Assert.assertEquals(1, operations.size());
+ Operation<QName> operation = operations.get("getLastTradePrice");
+ Assert.assertNotNull(operation);
+ DataType<List<DataType<QName>>> inputType = operation.getInputType();
+ Assert.assertEquals(1, inputType.getLogical().size());
+ DataType<QName> returnType = operation.getOutputType();
+ Assert.assertNotNull(returnType);
+ Assert.assertEquals(0, operation.getFaultTypes().size());
+ Assert.assertEquals(1, operation.getWrapper().getInputChildElements().size());
+ Assert.assertEquals(1, operation.getWrapper().getOutputChildElements().size());
+ }
+
+ public final void testIntrospectPortTypePortType() throws InvalidServiceContractException {
+ InterfaceWSDLIntrospector introspector = new InterfaceWSDLIntrospectorImpl(registry);
+ WSDLServiceContract contract = introspector.introspect(portType, portType);
+ Assert.assertEquals("StockQuotePortType", contract.getInterfaceName());
+ Assert.assertEquals("StockQuotePortType", contract.getCallbackName());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java
new file mode 100644
index 0000000000..a7d7457f76
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+/**
+ * Verifies the default WSDL registry implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLDefinitionRegistryTestCase extends TestCase {
+ private static final String NS = "http://www.example.org";
+ private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() {
+ public void readingWSDL(String namespace, URL location) {
+ }
+
+ public void cachingDefinition(String namespace, URL location) {
+ }
+ };
+ private WSDLDefinitionRegistryImpl wsdlRegistry;
+ private ClassLoader cl;
+ private URL exampleWsdl;
+
+
+ public void testLoadFromAbsoluteWSDLLocation() {
+ try {
+ Definition def = wsdlRegistry.loadDefinition(NS + ' ' + exampleWsdl, cl);
+ Assert.assertNotNull(def.getPortType(new QName(NS, "HelloWorld")));
+ } catch (IOException e) {
+ Assert.fail(e.getMessage());
+ } catch (WSDLException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ public void testLoadFromRelativeWSDLLocation() {
+ try {
+ Definition def = wsdlRegistry.loadDefinition(NS + " org/apache/tuscany/idl/wsdl/example.wsdl", cl);
+ Assert.assertNotNull(def.getPortType(new QName(NS, "HelloWorld")));
+ } catch (IOException e) {
+ Assert.fail(e.getMessage());
+ } catch (WSDLException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ wsdlRegistry = new WSDLDefinitionRegistryImpl();
+ wsdlRegistry.setSchemaRegistry(new XMLSchemaRegistryImpl());
+ wsdlRegistry.setMonitor(NULL_MONITOR);
+ exampleWsdl = getClass().getResource("example.wsdl");
+ cl = getClass().getClassLoader();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java
new file mode 100644
index 0000000000..c05cf9770f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WSDLLoaderImplTestCase extends TestCase {
+ private WSDLLoaderImpl loader;
+ private URI exampleURI;
+ private QName exampleName;
+
+ public void testGetNamespace() throws UnresolveableResourceException {
+ assertEquals("http://example.org/TicketAgent.wsdl20", loader.getNamespace(exampleURI));
+ }
+
+ public void testGetInterfaceNameFromFragment() throws UnresolveableResourceException, InvalidFragmentException {
+ assertEquals("TicketAgent", loader.getInterfaceName("wsdl.interface(TicketAgent)"));
+ }
+
+ public void testGetInterfaceNameFromURI() throws UnresolveableResourceException, InvalidFragmentException {
+ assertEquals(exampleName, loader.getInterfaceName(exampleURI));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ loader = new WSDLLoaderImpl();
+ exampleURI = URI.create("http://example.org/TicketAgent.wsdl20#wsdl.interface(TicketAgent)");
+ exampleName = new QName("http://example.org/TicketAgent.wsdl20", "TicketAgent");
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java
new file mode 100644
index 0000000000..b77e88d408
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * Test case for WSDLOperation
+ */
+public class WSDLOperationTestCase extends TestCase {
+ private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+ private WSDLDefinitionRegistryImpl registry;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new WSDLDefinitionRegistryImpl();
+ registry.setSchemaRegistry(new XMLSchemaRegistryImpl());
+ }
+
+ public final void testWrappedOperation() throws Exception {
+ URL url = getClass().getResource("stockquote.wsdl");
+ Definition definition = registry.loadDefinition(null, url);
+ PortType portType = definition.getPortType(PORTTYPE_NAME);
+ Operation operation = portType.getOperation("getLastTradePrice", null, null);
+
+ WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry());
+
+ DataType<List<DataType<QName>>> inputType = op.getInputType();
+ Assert.assertEquals(1, inputType.getLogical().size());
+ Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePrice"), inputType.getLogical()
+ .get(0).getLogical());
+
+ DataType<QName> outputType = op.getOutputType();
+ Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"), outputType
+ .getLogical());
+ Assert.assertTrue(op.isWrapperStyle());
+
+ DataType<List<DataType<QName>>> unwrappedInputType = op.getWrapper().getUnwrappedInputType();
+ List<DataType<QName>> childTypes = unwrappedInputType.getLogical();
+ Assert.assertEquals(1, childTypes.size());
+ DataType<QName> childType = childTypes.get(0);
+ Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical());
+ ElementInfo element = (ElementInfo) childType.getMetadata(ElementInfo.class.getName());
+ Assert.assertNotNull(element);
+
+ childType = op.getWrapper().getUnwrappedOutputType();
+ Assert.assertEquals(new QName(null, "price"), childType.getLogical());
+ element = (ElementInfo) childType.getMetadata(ElementInfo.class.getName());
+ Assert.assertNotNull(element);
+ }
+
+ public final void testUnwrappedOperation() throws Exception {
+ URL url = getClass().getResource("unwrapped-stockquote.wsdl");
+ Definition definition = registry.loadDefinition(null, url);
+ PortType portType = definition.getPortType(PORTTYPE_NAME);
+
+ Operation operation = portType.getOperation("getLastTradePrice1", null, null);
+ WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry());
+ Assert.assertFalse(op.isWrapperStyle());
+ Assert.assertEquals(1, op.getInputType().getLogical().size());
+
+ operation = portType.getOperation("getLastTradePrice2", null, null);
+ op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry());
+ Assert.assertFalse(op.isWrapperStyle());
+ Assert.assertEquals(2, op.getInputType().getLogical().size());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java
new file mode 100644
index 0000000000..748c790297
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.idl.wsdl;
+
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Test case for WSDLOperation
+ */
+public class WrapperStyleOperationTestCase extends TestCase {
+ private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
+
+ private WSDLDefinitionRegistryImpl registry;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = new WSDLDefinitionRegistryImpl();
+ registry.setSchemaRegistry(new XMLSchemaRegistryImpl());
+ }
+
+ public final void testWrappedOperation() throws Exception {
+ URL url = getClass().getResource("stockquote.wsdl");
+ Definition definition = registry.loadDefinition(null, url);
+ PortType portType = definition.getPortType(PORTTYPE_NAME);
+ Operation operation = portType.getOperation("getLastTradePrice", null, null);
+ WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry());
+ Assert.assertTrue(op.isWrapperStyle());
+ Assert.assertEquals(1, op.getWrapper().getInputChildElements().size());
+ Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size());
+ }
+
+ public final void testUnwrappedOperation() throws Exception {
+ URL url = getClass().getResource("unwrapped-stockquote.wsdl");
+ Definition definition = registry.loadDefinition(null, url);
+ PortType portType = definition.getPortType(PORTTYPE_NAME);
+ Operation operation = portType.getOperation("getLastTradePrice1", null, null);
+ WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry());
+ Assert.assertFalse(op.isWrapperStyle());
+ operation = portType.getOperation("getLastTradePrice2", null, null);
+ op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry());
+ Assert.assertFalse(op.isWrapperStyle());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java
new file mode 100644
index 0000000000..60433d3bc1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.idl.wsdl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaException;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * Verifies the default XSD registry implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLSchemaRegistryImplTestCase extends TestCase {
+ private static final QName PO_ELEMENT_NAME = new QName("http://www.example.com/IPO", "purchaseOrder");
+ private static final QName PO_TYPE_NAME = new QName("http://www.example.com/IPO", "PurchaseOrderType");
+
+ private static final String NS = "http://example.com/stockquote.xsd";
+ private static final QName GET_LAST_TRADE_PRICE_ELEMENT_NAME = new QName(NS, "getLastTradePrice");
+
+ private XMLSchemaRegistryImpl xsdRegistry;
+
+ private WSDLDefinitionRegistryImpl wsdlRegistry;
+
+ private ClassLoader cl;
+
+ private URL wsdl;
+
+ public void testLoadFromAbsoluteWSDLLocation() {
+ try {
+ Definition definition = wsdlRegistry.loadDefinition(null, wsdl);
+ List<XmlSchema> schemas = xsdRegistry.loadSchemas(definition);
+ Assert.assertTrue(schemas.size() == 1);
+ XmlSchema schema = schemas.get(0);
+ XmlSchemaElement element = schema.getElementByName(GET_LAST_TRADE_PRICE_ELEMENT_NAME);
+ Assert.assertNotNull(element);
+ XmlSchemaType type = element.getSchemaType();
+ XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+ XmlSchemaSequence sequence = (XmlSchemaSequence) complexType.getParticle();
+ XmlSchemaObjectCollection items = sequence.getItems();
+ Assert.assertTrue(items.getItem(0) instanceof XmlSchemaElement);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ public void testSchemaLocation() throws IOException {
+ String schemaLocation = "http://www.example.com/IPO org/apache/tuscany/idl/wsdl/ipo.xsd";
+ XmlSchema schema = xsdRegistry.loadSchema(schemaLocation, cl);
+ Assert.assertNotNull(schema);
+ Assert.assertNotNull(schema.getElementByName(PO_ELEMENT_NAME));
+ Assert.assertNotNull(xsdRegistry.getElement(PO_ELEMENT_NAME));
+ Assert.assertNotNull(schema.getTypeByName(PO_TYPE_NAME));
+ Assert.assertNotNull(xsdRegistry.getType(PO_TYPE_NAME));
+
+
+ schemaLocation = "http://www.example.com/IPO1 org/apache/tuscany/idl/wsdl/ipo.xsd";
+ try {
+ schema = xsdRegistry.loadSchema(schemaLocation, cl);
+ Assert.fail("");
+ } catch (XmlSchemaException e) {
+ Assert.assertTrue(e.getMessage().contains("http://www.example.com/IPO1 !="));
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ xsdRegistry = new XMLSchemaRegistryImpl();
+ wsdlRegistry = new WSDLDefinitionRegistryImpl();
+ wsdlRegistry.setSchemaRegistry(xsdRegistry);
+ wsdl = getClass().getResource("stockquote.wsdl");
+ cl = getClass().getClassLoader();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl
new file mode 100644
index 0000000000..5e8e5dad0d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://www.example.org"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="example">
+
+ <wsdl:portType name="HelloWorld">
+ </wsdl:portType>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd
new file mode 100644
index 0000000000..241ec15d36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd
@@ -0,0 +1,136 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl
new file mode 100644
index 0000000000..78e6bfe785
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput" />
+ <output message="tns:GetLastTradePriceOutput" />
+ </operation>
+ </portType>
+
+</definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl
new file mode 100644
index 0000000000..c74c0c9b64
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
+ xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getLastTradePrice">
+ <complexType>
+ <sequence>
+ <element name="tickerSymbol" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getLastTradePriceResponse">
+ <complexType>
+ <sequence>
+ <element name="price" type="float" />
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="GetLastTradePriceInput1">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ </message>
+
+ <message name="GetLastTradePriceOutput1">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <message name="GetLastTradePriceInput2">
+ <part name="body" element="xsd1:getLastTradePrice" />
+ <part name="other" type="xsd:string"/>
+ </message>
+
+ <message name="GetLastTradePriceOutput2">
+ <part name="body" element="xsd1:getLastTradePriceResponse" />
+ </message>
+
+ <portType name="StockQuotePortType">
+ <operation name="getLastTradePrice">
+ <input message="tns:GetLastTradePriceInput1" />
+ <output message="tns:GetLastTradePriceOutput1" />
+ </operation>
+ <operation name="getLastTradePrice1">
+ <input message="tns:GetLastTradePriceInput1" />
+ <output message="tns:GetLastTradePriceOutput1" />
+ </operation>
+ <operation name="getLastTradePrice2">
+ <input message="tns:GetLastTradePriceInput2" />
+ <output message="tns:GetLastTradePriceOutput2" />
+ </operation>
+ </portType>
+
+</definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/LICENSE.txt
new file mode 100644
index 0000000000..75b52484ea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/NOTICE.txt
new file mode 100644
index 0000000000..ecc68a9614
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/pom.xml
new file mode 100644
index 0000000000..685d1a0af0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>maven</artifactId>
+ <name>Apache Tuscany Maven Service</name>
+ <description>Tuscany Maven Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-embedder</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenArtifactRepository.java b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenArtifactRepository.java
new file mode 100644
index 0000000000..b2c608da63
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenArtifactRepository.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.services.maven;
+
+import java.util.Collection;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Artifact repository used for resolving artifacts.
+ *
+ * This is used by the composite loader for resolving artifacts transitively. The repository uses the Maven API for resolving dependencies and hence
+ * expects the artifacts to be stored in a structure similar to the Maven repository layout. The repository first looks within the deployed unit (WAR
+ * for example), before resorting to a local and set of remote Maven repositories.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MavenArtifactRepository implements ArtifactRepository {
+
+ /** Maven helper */
+ private MavenHelper mavenHelper;
+
+ /** WAR repository helper */
+ private WarRepositoryHelper warRepositoryHelper;
+
+ /**
+ * Conctructs a new artifact repository.
+ */
+ public MavenArtifactRepository(@Property(name = "remoteRepoUrl")
+ String remoteRepoUrl, @Autowire
+ RuntimeInfo runtimeInfo) {
+ mavenHelper = new MavenHelper(remoteRepoUrl, runtimeInfo.isOnline());
+ warRepositoryHelper = new WarRepositoryHelper(runtimeInfo.getBaseURL());
+ mavenHelper.start();
+ }
+
+ /**
+ * Resolve an artifact. This ensures that the information associated with an artifact is fully populated; Specifically, after this operation the
+ * URL should contain a location where the artifact can be obtained.
+ *
+ * @param artifact
+ * the artifact to be resolved
+ */
+ public void resolve(Artifact rootArtifact) {
+ if(warRepositoryHelper.resolveTransitively(rootArtifact)) {
+ return;
+ }
+ if(mavenHelper.resolveTransitively(rootArtifact)) {
+ return;
+ }
+ TuscanyDependencyException tde = new TuscanyDependencyException("Unable to resolve artifact: " + rootArtifact);
+ tde.setIdentifier(rootArtifact.toString());
+ throw tde;
+ }
+
+ /**
+ * Resolve a collection of Artifacts.
+ *
+ * @param artifacts
+ * a collection of artifacts to be resolved
+ * @see #resolve(Artifact)
+ */
+ public void resolve(Collection<? extends Artifact> artifacts) {
+ for (Artifact artifact : artifacts) {
+ resolve(artifact);
+ }
+ }
+
+ /**
+ * Destroy method.
+ *
+ */
+ @Destroy
+ public void destroy() {
+ mavenHelper.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java
new file mode 100644
index 0000000000..f68ad562f7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.services.maven;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.metadata.ResolutionGroup;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.codehaus.classworlds.ClassWorld;
+import org.codehaus.classworlds.DefaultClassRealm;
+import org.codehaus.classworlds.DuplicateRealmException;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.embed.Embedder;
+
+/**
+ * Utility class for embedding Maven.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MavenHelper {
+
+ /** Local repository */
+ private static final File LOCAL_REPO = new File(System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository");
+
+ /** Remote repository URLs */
+ private final String[] remoteRepositoryUrls;
+
+ /** Maven metadata source */
+ private ArtifactMetadataSource metadataSource;
+
+ /** Artifact factory */
+ private ArtifactFactory artifactFactory;
+
+ /** Local artifact repository */
+ private ArtifactRepository localRepository;
+
+ /** Remote artifact repositories */
+ private List<ArtifactRepository> remoteRepositories = new LinkedList<ArtifactRepository>();
+
+ /** Artifact resolver */
+ private ArtifactResolver artifactResolver;
+
+ /** Online */
+ private boolean online;
+
+ /**
+ * Initialize the remote repository URLs.
+ *
+ * @param remoteRepositoryUrls
+ * Remote repository URLS.
+ * @param runtimeInfo
+ * Runtime information.
+ */
+ public MavenHelper(String remoteRepositoryUrl, boolean online) {
+ this.remoteRepositoryUrls = remoteRepositoryUrl.split(",");
+ this.online = online;
+ }
+
+ /**
+ * Starts the embedder.
+ *
+ * @throws TuscanyDependencyException
+ * If unable to start the embedder.
+ */
+ public void start() throws TuscanyDependencyException {
+
+ try {
+
+ Embedder embedder = new Embedder();
+ ClassWorld classWorld = new ClassWorld();
+
+ classWorld.newRealm("plexus.core", getClass().getClassLoader());
+
+ // Evil hack for Tomcat classloader issue - starts
+ Field realmsField = ClassWorld.class.getDeclaredField("realms");
+ realmsField.setAccessible(true);
+ Map realms = (Map) realmsField.get(classWorld);
+ DefaultClassRealm realm = (DefaultClassRealm) realms.get("plexus.core");
+
+ Class clazz = Class.forName("org.codehaus.classworlds.RealmClassLoader");
+ Constructor ctr = clazz.getDeclaredConstructor(new Class[] { DefaultClassRealm.class, ClassLoader.class });
+ ctr.setAccessible(true);
+ Object realmClassLoader = ctr.newInstance(realm, getClass().getClassLoader());
+
+ Field realmClassLoaderField = DefaultClassRealm.class.getDeclaredField("classLoader");
+ realmClassLoaderField.setAccessible(true);
+ realmClassLoaderField.set(realm, realmClassLoader);
+ // Evil hack for Tomcat classloader issue - ends
+
+ embedder.start(classWorld);
+
+ metadataSource = (ArtifactMetadataSource) embedder.lookup(ArtifactMetadataSource.ROLE);
+ artifactFactory = (ArtifactFactory) embedder.lookup(ArtifactFactory.ROLE);
+ artifactResolver = (ArtifactResolver) embedder.lookup(ArtifactResolver.ROLE);
+
+ setUpRepositories(embedder);
+
+ embedder.stop();
+
+ } catch (DuplicateRealmException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (PlexusContainerException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (ComponentLookupException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (NoSuchFieldException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (ClassNotFoundException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (NoSuchMethodException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (InstantiationException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new TuscanyDependencyException(ex);
+ }
+
+ }
+
+ /**
+ * Stops the embedder.
+ *
+ * @throws TuscanyDependencyException
+ * If unable to stop the embedder.
+ */
+ public void stop() throws TuscanyDependencyException {
+ }
+
+ /**
+ * Resolves the dependencies transitively.
+ *
+ * @param artifact
+ * Artifact whose dependencies need to be resolved.
+ * @throws TuscanyDependencyException
+ * If unable to resolve the dependencies.
+ */
+ public boolean resolveTransitively(Artifact rootArtifact) throws TuscanyDependencyException {
+
+ org.apache.maven.artifact.Artifact mavenRootArtifact = artifactFactory.createArtifact(rootArtifact.getGroup(), rootArtifact.getName(),
+ rootArtifact.getVersion(), org.apache.maven.artifact.Artifact.SCOPE_RUNTIME, rootArtifact.getType());
+
+ try {
+
+ if (resolve(mavenRootArtifact)) {
+ rootArtifact.setUrl(mavenRootArtifact.getFile().toURL());
+ if (resolveDependencies(rootArtifact, mavenRootArtifact)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } catch (MalformedURLException ex) {
+ throw new TuscanyDependencyException(ex);
+ }
+
+ }
+
+ /*
+ * Resolves the artifact.
+ */
+ private boolean resolve(org.apache.maven.artifact.Artifact mavenRootArtifact) {
+
+ try {
+ artifactResolver.resolve(mavenRootArtifact, remoteRepositories, localRepository);
+ return true;
+ } catch (ArtifactResolutionException ex) {
+ return false;
+ } catch (ArtifactNotFoundException ex) {
+ return false;
+ }
+
+ }
+
+ /*
+ * Sets up local and remote repositories.
+ */
+ private void setUpRepositories(Embedder embedder) {
+
+ try {
+
+ ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup(ArtifactRepositoryFactory.ROLE);
+
+ ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) embedder.lookup(ArtifactRepositoryLayout.ROLE, "default");
+
+ String updatePolicy = online ? ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS : ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER;
+ ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(true, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
+ ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(true, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
+
+ localRepository = artifactRepositoryFactory.createArtifactRepository("local", LOCAL_REPO.toURL().toExternalForm(), layout,
+ snapshotsPolicy, releasesPolicy);
+
+ if (!online) {
+ return;
+ }
+
+ for (String remoteRepositoryUrl : remoteRepositoryUrls) {
+ String repoid = remoteRepositoryUrl.replace(':', '_');
+ repoid = repoid.replace('/', '_');
+ repoid = repoid.replace('\\', '_');
+ remoteRepositories.add(artifactRepositoryFactory.createArtifactRepository(repoid, remoteRepositoryUrl, layout, snapshotsPolicy,
+ releasesPolicy));
+ }
+
+ } catch (MalformedURLException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (ComponentLookupException ex) {
+ throw new TuscanyDependencyException(ex);
+ }
+
+ }
+
+ /*
+ * Resolves transitive dependencies.
+ */
+ private boolean resolveDependencies(Artifact rootArtifact, org.apache.maven.artifact.Artifact mavenRootArtifact) {
+
+ try {
+
+ ResolutionGroup resolutionGroup = null;
+ ArtifactResolutionResult result = null;
+
+ resolutionGroup = metadataSource.retrieve(mavenRootArtifact, localRepository, remoteRepositories);
+ result = artifactResolver.resolveTransitively(resolutionGroup.getArtifacts(), mavenRootArtifact, remoteRepositories, localRepository,
+ metadataSource);
+
+ // Add the artifacts to the deployment unit
+ for (Object obj : result.getArtifacts()) {
+ org.apache.maven.artifact.Artifact depArtifact = (org.apache.maven.artifact.Artifact) obj;
+ Artifact artifact = new Artifact();
+ artifact.setName(mavenRootArtifact.getArtifactId());
+ artifact.setGroup(mavenRootArtifact.getGroupId());
+ artifact.setType(mavenRootArtifact.getType());
+ artifact.setClassifier(mavenRootArtifact.getClassifier());
+ artifact.setUrl(depArtifact.getFile().toURL());
+ rootArtifact.addDependency(artifact);
+ }
+
+ } catch (ArtifactMetadataRetrievalException ex) {
+ return false;
+ } catch (MalformedURLException ex) {
+ throw new TuscanyDependencyException(ex);
+ } catch (ArtifactResolutionException ex) {
+ return false;
+ } catch (ArtifactNotFoundException ex) {
+ return false;
+ }
+
+ return true;
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyDependencyException.java b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyDependencyException.java
new file mode 100644
index 0000000000..6e89443711
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyDependencyException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.services.maven;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Exception thrown in case of an artifact error.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyDependencyException extends TuscanyRuntimeException {
+
+ /**
+ * Initializes the cause.
+ * @param cause Cause of the exception.
+ */
+ public TuscanyDependencyException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Initializes the message.
+ * @param message Message of the exception.
+ */
+ public TuscanyDependencyException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/WarRepositoryHelper.java b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/WarRepositoryHelper.java
new file mode 100644
index 0000000000..be4ee68bfa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/WarRepositoryHelper.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.services.maven;
+
+import java.beans.XMLDecoder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.spi.services.artifact.Artifact;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Helper class for resolving dependencies from WAR files.
+ *
+ * @author Administrator
+ *
+ */
+public class WarRepositoryHelper {
+
+ /** WAR Repository URL */
+ private URL reporsitoryUrl;
+
+ /** Dependency metadata */
+ private Map<String, Set<String>> transDependencyMap = new HashMap<String, Set<String>>();
+
+ /**
+ * Initializes the repository URL.
+ * @param baseUrl Base URL.
+ */
+ @SuppressWarnings("unchecked")
+ public WarRepositoryHelper(URL baseUrl) {
+
+
+ InputStream transDepMapInputStream = null;
+ try {
+
+ reporsitoryUrl = new URL(baseUrl, "repository/");
+ URL transDependencyMapUrl = new URL(baseUrl, "repository/dependency.metadata");
+ transDepMapInputStream = transDependencyMapUrl.openStream();
+
+ XMLDecoder decoder = new XMLDecoder(transDepMapInputStream);
+ transDependencyMap = (Map<String, Set<String>>)decoder.readObject();
+ decoder.close();
+
+ } catch (MalformedURLException ex) {
+ // throw new TuscanyDependencyException(ex);
+ } catch (IOException ex) {
+ // throw new TuscanyDependencyException(ex);
+ } finally {
+ IOUtil.close(transDepMapInputStream);
+ }
+
+ }
+
+ /**
+ * Resolves the dependencies transitively.
+ *
+ * @param artifact
+ * Artifact whose dependencies need to be resolved.
+ * @throws TuscanyDependencyException
+ * If unable to resolve the dependencies.
+ */
+ public boolean resolveTransitively(Artifact rootArtifact) throws TuscanyDependencyException {
+
+ String artKey = rootArtifact.getGroup() + "/" + rootArtifact.getName() + "/" + rootArtifact.getVersion() + "/";
+ if(!transDependencyMap.containsKey(artKey)) {
+ return false;
+ }
+
+
+ for(String dep : transDependencyMap.get(artKey)) {
+
+ String[] tokens = dep.split("/");
+ String artName = tokens[1];
+
+ try {
+ if(artName.equals(rootArtifact.getName())) {
+ rootArtifact.setUrl(new URL(reporsitoryUrl, dep));
+ } else {
+ Artifact depArtifact = new Artifact();
+ depArtifact.setGroup(tokens[0]);
+ depArtifact.setName(tokens[1]);
+ depArtifact.setVersion(tokens[2]);
+ depArtifact.setUrl(new URL(reporsitoryUrl, dep));
+ rootArtifact.addDependency(depArtifact);
+
+ }
+ } catch (MalformedURLException ex) {
+ throw new TuscanyDependencyException(ex);
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTestCase.java
new file mode 100644
index 0000000000..2eeb4e2e66
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTestCase.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.services.maven;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.spi.services.artifact.Artifact;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MavenArtifactRepositoryTestCase extends TestCase {
+
+ public MavenArtifactRepositoryTestCase(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'org.apache.tuscany.services.maven.MavenArtifactRepository.resolve(Artifact)'
+ */
+ public void testResolveArtifact() throws Exception {
+
+ final URL BASE_URL = new File(System.getProperty("user.home") + File.separator + ".m2").toURL();
+ String remoteRepoUrl = "http://repo1.maven.org/maven2/";
+ MavenArtifactRepository repository = new MavenArtifactRepository(remoteRepoUrl, new RuntimeInfo() {
+ public File getApplicationRootDirectory() {
+ return null;
+ }
+
+ public URL getBaseURL() {
+ return BASE_URL;
+ }
+
+ public File getInstallDirectory() {
+ return null;
+ }
+
+ public boolean isOnline() {
+ return false;
+ }
+ });
+ Artifact artifact = new Artifact();
+ artifact.setGroup("junit");
+ artifact.setName("junit");
+ artifact.setVersion("3.8.1");
+ artifact.setType("jar");
+
+ repository.resolve(artifact);
+
+ Set<URL> urls = artifact.getUrls();
+
+ System.err.println(urls);
+
+ assertEquals(1, urls.size());
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/WarRepositoryHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/WarRepositoryHelperTestCase.java
new file mode 100644
index 0000000000..3a79599fa7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/WarRepositoryHelperTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.services.maven;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.apache.tuscany.spi.services.artifact.Artifact;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Administrator
+ *
+ */
+public class WarRepositoryHelperTestCase extends TestCase {
+
+ /**
+ * @param arg0
+ */
+ public WarRepositoryHelperTestCase(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.services.maven.WarRepositoryHelper#WarRepositoryHelper(java.net.URL)}.
+ */
+ public void testWarRepositoryHelper() {
+
+ URL warUrl = getClass().getClassLoader().getResource("webapp.war");
+ URLClassLoader urlc = new URLClassLoader(new URL[] {warUrl});
+
+ URL repoUrl = urlc.getResource("WEB-INF/tuscany/");
+ System.err.println(repoUrl);
+
+ WarRepositoryHelper warRepositoryHelper = new WarRepositoryHelper(repoUrl);
+ assertNotNull(warRepositoryHelper);
+
+ }
+
+ /**
+ * Test method for {@link org.apache.tuscany.services.maven.WarRepositoryHelper#WarRepositoryHelper(java.net.URL)}.
+ */
+ public void testResolveTransitively() {
+
+ URL warUrl = getClass().getClassLoader().getResource("webapp.war");
+ URLClassLoader urlc = new URLClassLoader(new URL[] {warUrl});
+
+ URL repoUrl = urlc.getResource("WEB-INF/tuscany/");
+ WarRepositoryHelper warRepositoryHelper = new WarRepositoryHelper(repoUrl);
+
+ Artifact artifact = new Artifact();
+ artifact.setGroup("commons-httpclient");
+ artifact.setName("commons-httpclient");
+ artifact.setVersion("3.0");
+
+ warRepositoryHelper.resolveTransitively(artifact);
+ assertEquals(4, artifact.getUrls().size());
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/resources/webapp.war b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/resources/webapp.war
new file mode 100644
index 0000000000..4448aca8ff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/maven/src/test/resources/webapp.war
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/pom.xml
new file mode 100644
index 0000000000..df90006ade
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>persistence-common</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany JPA</name>
+ <description>Tuscany JPA Integration.</description>
+
+
+ <repositories>
+ <repository>
+ <id>java.net</id>
+ <url>https://maven-repository.dev.java.net/nonav/repository</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-api</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/src/main/java/org/apache/tuscany/service/persistence/common/PersistenceUnitProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/src/main/java/org/apache/tuscany/service/persistence/common/PersistenceUnitProcessor.java
new file mode 100644
index 0000000000..77ac0ef018
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/common/src/main/java/org/apache/tuscany/service/persistence/common/PersistenceUnitProcessor.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.persistence.common;
+
+import javax.persistence.PersistenceUnit;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.AbstractPropertyProcessor;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+
+/**
+ * Annotation processor for injecting <code>PersistenceUnit</code>
+ * annotations on properties.
+ *
+ */
+public class PersistenceUnitProcessor extends AbstractPropertyProcessor<PersistenceUnit> {
+
+ /**
+ * Injects the implementation processor service.
+ * @param service Implementation processor service.
+ */
+ public PersistenceUnitProcessor(@Autowire ImplementationProcessorService service) {
+ super(PersistenceUnit.class, service);
+ }
+
+ /**
+ * Defaults to the field name.
+ */
+ @Override
+ protected String getName(PersistenceUnit persistenceUnit) {
+ return null;
+ }
+
+ /**
+ * Initializes the property.
+ */
+ @SuppressWarnings("unchecked")
+ protected <EntityManagerFactory> void initProperty(JavaMappedProperty<EntityManagerFactory> property,
+ PersistenceUnit annotation,
+ CompositeComponent parent,
+ DeploymentContext context) {
+ String unitName = annotation.unitName();
+ final EntityManagerFactory emf = (EntityManagerFactory)parent.getSystemChild(unitName);
+ if(emf == null) {
+ // TODO Create an EMF, also clarify from jmarino what the second argument is.
+ parent.registerJavaObject(unitName, null, emf);
+ }
+ property.setDefaultValueFactory(new ObjectFactory<EntityManagerFactory>() {
+ public EntityManagerFactory getInstance() throws ObjectCreationException {
+ return emf;
+ }
+ });
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/pom.xml
new file mode 100644
index 0000000000..38aaecdd5a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>openjpa</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany OpenJPA</name>
+ <description>TuscanyOpenJPA Integration.</description>
+
+
+ <repositories>
+ <repository>
+ <id>apache-snapshots</id>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ </repository>
+ </repositories>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-persistence-jdbc</artifactId>
+ <version>0.9.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/Constants.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/Constants.java
new file mode 100644
index 0000000000..820f57bcad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/Constants.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+/**
+ * Constants used by the JPA extension
+ *
+ * @version $Rev$ $Date$
+ */
+public final class Constants {
+
+ public static final String PERSISTENCE_UNIT = "persistenceUnit";
+ public static final String CONFIG_PROPERTIES = "configProperties";
+
+ private Constants() {
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerFactoryImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerFactoryImplementation.java
new file mode 100644
index 0000000000..d818f145bd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerFactoryImplementation.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+import org.apache.tuscany.spi.model.ComponentType;
+
+/**
+ * Represents the implementation type of a system service that manages JPA
+ * <code>EntityManagerFactoryImplementation</code> implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public class EntityManagerFactoryImplementation extends AtomicImplementation<ComponentType> {
+
+ public EntityManagerFactoryImplementation() {
+ }
+
+ public EntityManagerFactoryImplementation(ComponentType componentType) {
+ super(componentType);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerObjectFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerObjectFactory.java
new file mode 100644
index 0000000000..45d4e1a077
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerObjectFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import java.util.Map;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Creates a JPA <code>EntityManager</code> to be injected on a component implementation instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EntityManagerObjectFactory implements ObjectFactory<EntityManager> {
+
+ private EntityManagerFactory emf;
+ private Map props;
+
+ public EntityManagerObjectFactory(EntityManagerFactory emf) {
+ this.emf = emf;
+ }
+
+ public EntityManagerObjectFactory(EntityManagerFactory emf, Map props) {
+ this.emf = emf;
+ this.props = props;
+ }
+
+ public EntityManager getInstance() throws ObjectCreationException {
+ if (props == null) {
+ return emf.createEntityManager();
+ } else {
+ return emf.createEntityManager(props);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerProcessor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerProcessor.java
new file mode 100644
index 0000000000..9574f60b8c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/EntityManagerProcessor.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import java.lang.reflect.Member;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.AbstractPropertyProcessor;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+
+/**
+ * Evaluates constructors, methods, and fields annotated with {@link PersistenceContext }, creating a mapped property
+ * that will inject an {@link EntityManager} on an implementation instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EntityManagerProcessor extends AbstractPropertyProcessor<PersistenceContext> {
+
+ public EntityManagerProcessor(@Autowire ImplementationProcessorService service) {
+ super(PersistenceContext.class, service);
+ }
+
+ protected String getName(PersistenceContext annotation) {
+ String name = annotation.unitName();
+ if (name == null) {
+ return "_defaultJPAPersistenceUnit";
+ }
+ return name;
+ }
+
+ protected <T>JavaMappedProperty<T> createProperty(String name,
+ Class<T> javaType,
+ Member member) throws ProcessingException {
+ if (!EntityManager.class.equals(javaType)) {
+ InvalidInjectionSite e =
+ new InvalidInjectionSite("Injection site must by of type " + EntityManager.class.getName());
+ e.setIdentifier(name);
+ throw e;
+ }
+ return super.createProperty(name, javaType, member);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> void initProperty(JavaMappedProperty<T> property,
+ PersistenceContext annotation,
+ CompositeComponent parent,
+ DeploymentContext context) {
+ EntityManagerFactory emf = parent.resolveSystemInstance(EntityManagerFactory.class);
+ ObjectFactory factory = new EntityManagerObjectFactory(emf);
+ property.setDefaultValueFactory(factory);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/InvalidInjectionSite.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/InvalidInjectionSite.java
new file mode 100644
index 0000000000..11c5e9dfc7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/InvalidInjectionSite.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidInjectionSite extends ProcessingException {
+ public InvalidInjectionSite() {
+ }
+
+ public InvalidInjectionSite(String message) {
+ super(message);
+ }
+
+ public InvalidInjectionSite(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidInjectionSite(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAAtomicComponent.java
new file mode 100644
index 0000000000..1e440bf0d3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAAtomicComponent.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import java.util.ArrayList;
+import java.util.Map;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.extension.SystemAtomicComponentExtension;
+
+/**
+ * A system service that manages a JPA <code>EntityManagerFactory</code>. This service is used by {@link
+ * EntityManagerProcessor} to inject an <code>EntityManager<code> on a constructor parameter, field, or method of an
+ * implementation instance. Since a JPA persistence context is specific to an application, this system service is scoped
+ * to the application composite. That is, it is contained as a system child of the application composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JPAAtomicComponent extends SystemAtomicComponentExtension {
+ private EntityManagerFactory factory;
+ private String persistenceUnit;
+ private Map<Object, Object> configProps;
+
+ public JPAAtomicComponent(String name,
+ CompositeComponent parent,
+ ScopeContainer scopeContainer,
+ String persistenceUnit,
+ Map<Object, Object> configProps,
+ int initLevel) {
+ super(name, null, parent, scopeContainer, initLevel);
+ assert persistenceUnit != null;
+ this.persistenceUnit = persistenceUnit;
+ this.configProps = configProps;
+ interfazes = new ArrayList<Class<?>>();
+ interfazes.add(EntityManagerFactory.class);
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ if (configProps != null) {
+ factory = Persistence.createEntityManagerFactory(persistenceUnit, configProps);
+ } else {
+ factory = Persistence.createEntityManagerFactory(persistenceUnit);
+ }
+ return factory;
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ return factory;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAComponentBuilder.java
new file mode 100644
index 0000000000..65b3313515
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAComponentBuilder.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Property;
+
+import static org.apache.tuscany.service.openjpa.Constants.PERSISTENCE_UNIT;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JPAComponentBuilder extends ComponentBuilderExtension {
+ protected Class getImplementationType() {
+ return null;
+ }
+
+ public Component build(CompositeComponent parent, ComponentDefinition definition, DeploymentContext ctx)
+ throws BuilderConfigException {
+// String name = definition.getName();
+// ScopeContainer moduleScope = ctx.getModuleScope();
+// Integer initLevel = definition.getInitLevel();
+ ComponentType<?, ?, ?> type = definition.getImplementation().getComponentType();
+ Property<?> persistenceUnit = type.getProperties().get(PERSISTENCE_UNIT);
+ if (persistenceUnit == null) {
+ BuilderConfigException e =
+ new BuilderConfigException("Persistence Unit not specified in JPA import in composite");
+ e.setIdentifier(parent.getName());
+ throw e;
+ }
+// Property<?> configProps = type.getProperties().get(PERSISTENCE_UNIT);
+ return null;
+// return new JPAAtomicComponent(name, parent, moduleScope, initLevel);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAImportLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAImportLoader.java
new file mode 100644
index 0000000000..07969d095c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/main/java/org/apache/tuscany/service/openjpa/JPAImportLoader.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JPAImportLoader extends LoaderExtension {
+ private static final QName IMPORT = new QName(XML_NAMESPACE_1_0, "import.jpa");
+
+ public JPAImportLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPORT;
+ }
+
+ public ModelObject load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ //ComponentDefinition definition = new ComponentDefinition()
+ // TODO read in persisitence unit setting and properties, and set them as properties on the component
+ return null;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/test/java/org/apache/tuscany/service/openjpa/EntityManagerProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/test/java/org/apache/tuscany/service/openjpa/EntityManagerProcessorTestCase.java
new file mode 100644
index 0000000000..ec33c81d1e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/openjpa/src/test/java/org/apache/tuscany/service/openjpa/EntityManagerProcessorTestCase.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.openjpa;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessor;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EntityManagerProcessorTestCase extends TestCase {
+
+ private ImplementationProcessor processor;
+ private CompositeComponent parent;
+
+ public void testVisitMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", EntityManager.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitMethod(parent, method, type, null);
+ JavaMappedProperty<?> prop = type.getProperties().get("bar");
+ assertEquals(EntityManagerObjectFactory.class, prop.getDefaultValueFactory().getClass());
+ }
+
+ public void testVisitBadMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBadBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitMethod(parent, method, type, null);
+ fail();
+ } catch (InvalidInjectionSite e) {
+ // expected
+ }
+ }
+
+ public void testVisitField() throws Exception {
+ Field field = Foo.class.getDeclaredField("bar");
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitField(parent, field, type, null);
+ JavaMappedProperty<?> prop = type.getProperties().get("bar");
+ assertEquals(EntityManagerObjectFactory.class, prop.getDefaultValueFactory().getClass());
+ }
+
+ public void testBadVisitField() throws Exception {
+ Field field = Foo.class.getDeclaredField("badField");
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitField(null, field, type, null);
+ fail();
+ } catch (InvalidInjectionSite e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.replay(emf);
+ parent = EasyMock.createMock(CompositeComponent.class);
+ EasyMock.expect(parent.resolveSystemInstance(EntityManagerFactory.class)).andReturn(emf).atLeastOnce();
+ EasyMock.replay(parent);
+ ImplementationProcessorService service = EasyMock.createMock(ImplementationProcessorService.class);
+ service.addName(EasyMock.isA(List.class), EasyMock.eq(0), EasyMock.isA(String.class));
+ EasyMock.expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ ((List<Object>) EasyMock.getCurrentArguments()[0]).add(EasyMock.getCurrentArguments()[2]);
+ return null;
+ }
+ });
+ EasyMock.replay(service);
+ processor = new EntityManagerProcessor(service);
+ }
+
+ private static class Foo {
+
+
+ @PersistenceContext
+ protected EntityManager bar;
+
+ @PersistenceContext
+ protected String badField;
+
+ @PersistenceContext
+ public void setBar(EntityManager d) {
+ }
+
+ @PersistenceContext
+ public void setBadBar(String d) {
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/pom.xml
new file mode 100644
index 0000000000..6b3a7ed9d1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/persistence/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services.persistence</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Persistence Services</name>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>openjpa</module>
+ </modules>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/pom.xml
new file mode 100644
index 0000000000..81ccaf16fd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Services</name>
+
+ <!-- definition of repositories where the parent pom can be found -->
+ <repositories>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>apache.incubator</id>
+ <name>Apache Incubator Repository</name>
+ <url>http://people.apache.org/repo/m2-incubating-repository/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>idl</module>
+ <module>containers</module>
+ <module>databinding</module>
+ <module>bindings</module>
+ <module>maven</module>
+<!--
+ <module>transports/http.jetty</module>
+-->
+ </modules>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/pom.xml
new file mode 100644
index 0000000000..3fd0189fba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.services</groupId>
+ <artifactId>services</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>http-jetty</artifactId>
+ <name>Apache Tuscany Jetty HTTP Service</name>
+ <description>Tuscany Jetty HTTP Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.0.0beta17</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>6.0.0beta16</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyLogger.java b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyLogger.java
new file mode 100644
index 0000000000..d42b301fbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyLogger.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.jetty;
+
+import org.mortbay.log.Logger;
+
+/**
+ * Serves as a wrapper for a {@link TransportMonitor} to replace Jetty's logging mechanism
+ *
+ * @version $Rev$ $Date$
+ */
+public class JettyLogger implements Logger {
+
+ private TransportMonitor monitor;
+ private boolean debugEnabled;
+
+ public void setMonitor(TransportMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ public boolean isDebugEnabled() {
+ return debugEnabled;
+ }
+
+ public void setDebugEnabled(boolean debugEnabled) {
+ this.debugEnabled = debugEnabled;
+ }
+
+ public void info(String msg, Object arg0, Object arg1) {
+ if (monitor != null) {
+ monitor.debug(msg, arg0, arg1);
+ } else if (debugEnabled) {
+ System.err.println(":INFO: " + format(msg, arg0, arg1));
+ }
+ }
+
+ public void debug(String msg, Throwable th) {
+ if (debugEnabled) {
+ if (monitor != null) {
+ monitor.debug(msg, th);
+ } else {
+ System.err.println(":DEBUG: " + msg);
+ th.printStackTrace();
+ }
+ }
+ }
+
+ public void debug(String msg, Object arg0, Object arg1) {
+ if (debugEnabled) {
+ if (monitor != null) {
+ monitor.debug(msg, arg0, arg1);
+ } else {
+ System.err.println(":DEBUG: " + format(msg, arg0, arg1));
+ }
+ }
+ }
+
+ public void warn(String msg, Object arg0, Object arg1) {
+ if (monitor != null) {
+ monitor.warn(msg, arg0, arg1);
+ } else if (debugEnabled) {
+ System.err.println(":WARN: " + format(msg, arg0, arg1));
+ }
+ }
+
+ public void warn(String msg, Throwable th) {
+ if (monitor != null) {
+ monitor.warn(msg, th);
+ } else if (debugEnabled) {
+ System.err.println(":WARN: " + msg);
+ th.printStackTrace();
+ }
+ }
+
+ public Logger getLogger(String name) {
+ return this;
+ }
+
+ private String format(String msg, Object arg0, Object arg1) {
+ int i0 = msg.indexOf("{}");
+ int i1 = i0 < 0 ? -1 : msg.indexOf("{}", i0 + 2);
+ if (arg1 != null && i1 >= 0) {
+ msg = msg.substring(0, i1) + arg1 + msg.substring(i1 + 2);
+ }
+ if (arg0 != null && i0 >= 0) {
+ msg = msg.substring(0, i0) + arg0 + msg.substring(i0 + 2);
+ }
+ return msg;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyService.java b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyService.java
new file mode 100644
index 0000000000..6fd68813df
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.jetty;
+
+import org.apache.tuscany.spi.host.ServletHost;
+
+import org.mortbay.jetty.Server;
+
+/**
+ * Implementations provide a Jetty transport service to the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface JettyService extends ServletHost {
+
+ /**
+ * Returns the active Jetty server
+ */
+ Server getServer();
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java
new file mode 100644
index 0000000000..01ad06fbe9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java
@@ -0,0 +1,314 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.jetty;
+
+import java.io.File;
+import java.io.IOException;
+import javax.resource.spi.work.Work;
+import javax.servlet.Servlet;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.api.annotation.Monitor;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.ServletMapping;
+import org.mortbay.log.Log;
+import org.mortbay.log.Logger;
+import org.mortbay.thread.BoundedThreadPool;
+import org.mortbay.thread.ThreadPool;
+
+/**
+ * Implements an HTTP transport service using Jetty.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@Scope("MODULE")
+@Service(ServletHost.class)
+public class JettyServiceImpl implements JettyService {
+
+ private static final String ROOT = "/";
+ private static final int ERROR = 0;
+ private static final int UNINITIALIZED = 0;
+ private static final int STARTING = 1;
+ private static final int STARTED = 2;
+ private static final int STOPPING = 3;
+ private static final int STOPPED = 4;
+
+ private final Object joinLock = new Object();
+ private int state = UNINITIALIZED;
+ private int httpPort = 8080;
+ private int httpsPort = 8484;
+ private String keystore;
+ private String certPassword;
+ private String keyPassword;
+ private boolean sendServerVersion;
+ private boolean https;
+ private TransportMonitor monitor;
+ private WorkScheduler scheduler;
+ private boolean debug;
+ private Server server;
+ private Connector connector;
+ private ServletHandler servletHandler;
+
+ static {
+ // hack to replace the static Jetty logger
+ System.setProperty("org.mortbay.log.class", JettyLogger.class.getName());
+ }
+
+ public JettyServiceImpl(@Monitor TransportMonitor monitor,
+ @Autowire WorkScheduler scheduler) {
+ this.monitor = monitor;
+ this.scheduler = scheduler;
+ // Jetty uses a static logger, so jam in the monitor into a static reference
+ Logger logger = Log.getLogger(null);
+ if (logger instanceof JettyLogger) {
+ JettyLogger jettyLogger = (JettyLogger) logger;
+ jettyLogger.setMonitor(monitor);
+ if (debug) {
+ jettyLogger.setDebugEnabled(true);
+ }
+ }
+ }
+
+ public JettyServiceImpl(TransportMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ public JettyServiceImpl(TransportMonitor monitor,
+ WorkScheduler scheduler,
+ Connector connector) {
+ this(monitor, scheduler);
+ this.connector = connector;
+ }
+
+ @Property
+ public void setHttpPort(int httpPort) {
+ this.httpPort = httpPort;
+ }
+
+ @Property
+ public void setHttpsPort(int httpsPort) {
+ this.httpsPort = httpsPort;
+ }
+
+ @Property
+ public void setSendServerVersion(boolean sendServerVersion) {
+ this.sendServerVersion = sendServerVersion;
+ }
+
+ @Property
+ public void setHttps(boolean https) {
+ this.https = https;
+ }
+
+ @Property
+ public void setKeystore(String keystore) {
+ this.keystore = keystore;
+ }
+
+ @Property
+ public void setCertPassword(String certPassword) {
+ this.certPassword = certPassword;
+ }
+
+ @Property
+ public void setKeyPassword(String keyPassword) {
+ this.keyPassword = keyPassword;
+ }
+
+ @Property
+ public void setDebug(boolean val) {
+ debug = val;
+ }
+
+ @Init
+ public void init() throws Exception {
+ try {
+ state = STARTING;
+ server = new Server();
+ if (scheduler == null) {
+ BoundedThreadPool threadPool = new BoundedThreadPool();
+ threadPool.setMaxThreads(100);
+ server.setThreadPool(threadPool);
+ } else {
+ server.setThreadPool(new TuscanyThreadPool());
+ }
+ if (connector == null) {
+ if (https) {
+ Connector httpConnector = new SelectChannelConnector();
+ httpConnector.setPort(httpPort);
+ SslSocketConnector sslConnector = new SslSocketConnector();
+ sslConnector.setPort(httpsPort);
+ sslConnector.setKeystore(keystore);
+ sslConnector.setPassword(certPassword);
+ sslConnector.setKeyPassword(keyPassword);
+ server.setConnectors(new Connector[]{httpConnector, sslConnector});
+ } else {
+ SelectChannelConnector selectConnector = new SelectChannelConnector();
+ selectConnector.setPort(httpPort);
+ server.setConnectors(new Connector[]{selectConnector});
+ }
+ } else {
+ connector.setPort(httpPort);
+ server.setConnectors(new Connector[]{connector});
+ }
+ ContextHandler contextHandler = new ContextHandler();
+ contextHandler.setContextPath(ROOT);
+ server.setHandler(contextHandler);
+ servletHandler = new ServletHandler();
+ contextHandler.setHandler(servletHandler);
+ server.setStopAtShutdown(true);
+ server.setSendServerVersion(sendServerVersion);
+ monitor.started();
+ server.start();
+ state = STARTED;
+ } catch (Exception e) {
+ state = ERROR;
+ throw e;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws Exception {
+ state = STOPPING;
+ synchronized (joinLock) {
+ joinLock.notifyAll();
+ }
+ server.stop();
+ state = STOPPED;
+ monitor.shutdown();
+ }
+
+ public void registerMapping(String path, Servlet servlet) {
+ ServletHolder holder = new ServletHolder(servlet);
+ servletHandler.addServlet(holder);
+ ServletMapping mapping = new ServletMapping();
+ mapping.setServletName(holder.getClassName());
+ mapping.setPathSpec(path);
+ servletHandler.addServletMapping(mapping);
+ }
+
+ public void unregisterMapping(String string) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void registerComposite(File compositeLocation) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Server getServer() {
+ return server;
+ }
+
+ public int getHttpPort() {
+ return httpPort;
+ }
+
+ /**
+ * An integration wrapper to enable use of a {@link WorkScheduler} with Jetty
+ */
+ private class TuscanyThreadPool implements ThreadPool {
+
+ public boolean dispatch(Runnable job) {
+ scheduler.scheduleWork(new TuscanyWork(job));
+ return true;
+ }
+
+ public void join() throws InterruptedException {
+ synchronized (joinLock) {
+ joinLock.wait();
+ }
+ }
+
+ public int getThreads() {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getIdleThreads() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLowOnThreads() {
+ // TODO FIXME
+ return false;
+ }
+
+ public void start() throws Exception {
+
+ }
+
+ public void stop() throws Exception {
+
+ }
+
+ public boolean isRunning() {
+ return state == STARTING || state == STARTED;
+ }
+
+ public boolean isStarted() {
+ return state == STARTED;
+ }
+
+ public boolean isStarting() {
+ return state == STARTING;
+ }
+
+ public boolean isStopping() {
+ return state == STOPPING;
+ }
+
+ public boolean isFailed() {
+ return state == ERROR;
+ }
+ }
+
+ /**
+ * A unit of work dispatched to the runtime work scheduler
+ */
+ private class TuscanyWork implements Work {
+
+ Runnable job;
+
+ public TuscanyWork(Runnable job) {
+ this.job = job;
+ }
+
+ public void release() {
+ }
+
+ public void run() {
+ job.run();
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/TransportMonitor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/TransportMonitor.java
new file mode 100644
index 0000000000..c68eacd21c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/TransportMonitor.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.jetty;
+
+/**
+ * The monitoring interfaces used by the Jetty system service
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface TransportMonitor {
+
+ /**
+ * Called after the service is initialized
+ */
+ void started();
+
+ /**
+ * Called after the service is stopped
+ */
+ void shutdown();
+
+ void warn(String msg, Object...args);
+
+ void debug(String msg, Object...args);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java
new file mode 100644
index 0000000000..987d7d9a16
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.service.jetty;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JettyServiceImplTestCase extends TestCase {
+
+ private static final String REQUEST1_HEADER =
+ "GET / HTTP/1.0\n"
+ + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST1_CONTENT =
+ "";
+ private static final String REQUEST1 =
+ REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
+
+ private static final int HTTP_PORT = 8585;
+
+ private TransportMonitor monitor;
+ private WorkScheduler scheduler;
+ private ExecutorService executor = Executors.newCachedThreadPool();
+
+ /**
+ * Verifies requests are properly routed according to the servlet mapping
+ */
+ public void testRegisterServletMapping() throws Exception {
+ JettyServiceImpl service = new JettyServiceImpl(monitor);
+ service.setHttpPort(HTTP_PORT);
+ service.init();
+ TestServlet servlet = new TestServlet();
+ service.registerMapping("/", servlet);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.destroy();
+ assertTrue(servlet.invoked);
+ }
+
+ public void testUseWorkScheduler() throws Exception {
+ JettyServiceImpl service = new JettyServiceImpl(monitor, scheduler);
+ service.setDebug(true);
+ service.setHttpPort(HTTP_PORT);
+ service.init();
+ TestServlet servlet = new TestServlet();
+ service.registerMapping("/", servlet);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.destroy();
+ assertTrue(servlet.invoked);
+ }
+
+ public void testRestart() throws Exception {
+ JettyServiceImpl service = new JettyServiceImpl(monitor);
+ service.setHttpPort(HTTP_PORT);
+ service.init();
+ service.destroy();
+ service.init();
+ service.destroy();
+ }
+
+ public void testNoMappings() throws Exception {
+ JettyServiceImpl service = new JettyServiceImpl(monitor);
+ service.setHttpPort(HTTP_PORT);
+ service.init();
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.destroy();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ //executor.submit();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ monitor = createMock(TransportMonitor.class);
+ scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+
+ expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ executor.execute(runnable);
+ return null;
+ }
+ });
+ replay(scheduler);
+ }
+
+ private static String read(Socket socket) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+ private class TestServlet extends HttpServlet {
+ boolean invoked;
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ invoked = true;
+ OutputStream writer = resp.getOutputStream();
+ try {
+ writer.write("result".getBytes());
+ } finally {
+ writer.close();
+ }
+ }
+
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/test/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/test/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/test/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/test/pom.xml
new file mode 100644
index 0000000000..da609c9155
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>test</artifactId>
+ <name>Apache Tuscany Test Framework</name>
+ <description>Tuscany Testcase Framework</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java
new file mode 100644
index 0000000000..ff893d8c3a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/ArtifactFactory.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+
+/**
+ * A factory for creating runtime artifacts to facilitate testing without directly instantiating core implementation
+ * classes
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public final class ArtifactFactory {
+
+ private ArtifactFactory() {
+ }
+
+ public static Connector createConnector() {
+ return new ConnectorImpl(createWireService(), null, null, null);
+ }
+
+ public static WireService createWireService() {
+ return new JDKWireService(new WorkContextImpl(), null);
+ }
+
+ /**
+ * Creates an inbound wire. After a wire is returned, client code must call {@link
+ * #terminateWire(org.apache.tuscany.spi.wire.InboundWire)}. These two methods have been separated to allow wires
+ * to be decorated with interceptors or handlers prior to their completion
+ *
+ * @param serviceName the service name associated with the wire
+ * @param interfaze the interface associated with the wire
+ */
+ public static <T> InboundWire createInboundWire(String serviceName, Class<T> interfaze)
+ throws InvalidServiceContractException {
+ InboundWire wire = new InboundWireImpl();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ wire.setServiceContract(contract);
+ wire.setServiceName(serviceName);
+ wire.addInvocationChains(createInboundChains(interfaze));
+ return wire;
+ }
+
+ /**
+ * Creates an outbound wire. After a wire is returned, client code must call {@link
+ * #terminateWire(org.apache.tuscany.spi.wire.OutboundWire)}. These two methods have been separated to allow
+ * wires to be decorated with interceptors or handlers prior to their completion
+ *
+ * @param refName the reference name the wire is associated with on the client
+ * @param interfaze the interface associated with the wire
+ */
+ public static <T> OutboundWire createOutboundWire(String refName, Class<T> interfaze)
+ throws InvalidServiceContractException {
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setReferenceName(refName);
+ wire.addInvocationChains(createOutboundChains(interfaze));
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ wire.setServiceContract(contract);
+ return wire;
+ }
+
+
+ /**
+ * Finalizes the target wire
+ */
+ public static <T> void terminateWire(InboundWire wire) {
+ for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
+ // add tail interceptor
+ chain.addInterceptor(new InvokerInterceptor());
+ }
+ }
+
+ public static <T> void terminateWire(OutboundWire wire) {
+ for (OutboundInvocationChain chain : wire.getInvocationChains().values()) {
+ // add tail interceptor
+ chain.addInterceptor(new InvokerInterceptor());
+ }
+ }
+
+ private static Map<Operation<?>, OutboundInvocationChain> createOutboundChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
+ Map<Operation<?>, OutboundInvocationChain> invocations = new HashMap<Operation<?>, OutboundInvocationChain>();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ for (Operation operation : contract.getOperations().values()) {
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ invocations.put(operation, chain);
+ }
+ return invocations;
+ }
+
+ private static Map<Operation<?>, InboundInvocationChain> createInboundChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
+ Map<Operation<?>, InboundInvocationChain> invocations = new HashMap<Operation<?>, InboundInvocationChain>();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ for (Operation<?> operation : contract.getOperations().values()) {
+ InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+ // add tail interceptor
+ //chain.addInterceptor(new InvokerInterceptor());
+ invocations.put(operation, chain);
+ }
+ return invocations;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/Bootstrapper.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/Bootstrapper.java
new file mode 100644
index 0000000000..aed0fe2765
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/Bootstrapper.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.launcher.CompositeContextImpl;
+import org.apache.tuscany.core.launcher.LauncherImpl;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Bootstrapper extends TestCase {
+ protected CompositeComponent component;
+ private CompositeContextImpl context;
+ private Map<String, URL> extensions = new HashMap<String, URL>();
+ private String applicationSCDL = LauncherImpl.METAINF_APPLICATION_SCDL_PATH;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ClassLoader cl = getClass().getClassLoader();
+ TestLauncher launcher = new TestLauncher();
+ launcher.setApplicationLoader(cl);
+ CompositeComponent composite = launcher.bootRuntime(cl.getResource(LauncherImpl.METAINF_SYSTEM_SCDL_PATH),
+ new NullMonitorFactory());
+
+ for (String extensionName : extensions.keySet()) {
+ deployExtension(composite, extensionName, extensions.get(extensionName));
+ }
+
+ URL applicationScdlURL = cl.getResource(applicationSCDL);
+ if (applicationScdlURL == null) {
+ throw new RuntimeException("application SCDL not found: " + applicationSCDL);
+ }
+ component = launcher.bootApplication("application", applicationScdlURL);
+ component.start();
+ context = new CompositeContextImpl(component);
+ context.start();
+ }
+
+ /**
+ * A TestCase can use this to overide the default SCDL location of "META-INF/sca/default.scdl"
+ */
+ protected void setApplicationSCDL(String applicationSCDL) {
+ this.applicationSCDL = applicationSCDL;
+ }
+
+ /**
+ * A TestCase can use this to add the SCDL location of an extention to be deployed to the runtime
+ */
+ protected void addExtension(String extensionName, URL extentionSCDL) {
+ extensions.put(extensionName, extentionSCDL);
+ }
+
+ protected void deployExtension(CompositeComponent composite, String extensionName, URL scdlURL)
+ throws LoaderException {
+ SystemCompositeImplementation implementation = new SystemCompositeImplementation();
+ implementation.setScdlLocation(scdlURL);
+ URLClassLoader classLoader = new URLClassLoader(new URL[]{scdlURL}, getClass().getClassLoader());
+ implementation.setClassLoader(classLoader);
+
+ ComponentDefinition<SystemCompositeImplementation> definition =
+ new ComponentDefinition<SystemCompositeImplementation>(extensionName,
+ implementation);
+
+ Deployer deployer = (Deployer) composite.getSystemChild("deployer").getServiceInstance();
+ Component component = deployer.deploy(composite, definition);
+
+ component.start();
+ }
+
+ protected void tearDown() throws Exception {
+ context.stop();
+ component.stop();
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/SCATestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/SCATestCase.java
new file mode 100644
index 0000000000..ed3f23881f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/SCATestCase.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
+import org.apache.tuscany.core.launcher.CompositeContextImpl;
+import org.apache.tuscany.core.launcher.LauncherImpl;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+
+/**
+ * Base class for JUnit tests that want to run in an SCA client environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SCATestCase extends TestCase {
+ protected CompositeComponent component;
+ private CompositeContextImpl context;
+ private Map<String, URL> extensions = new HashMap<String, URL>();
+ private URL applicationSCDL;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ClassLoader cl = getClass().getClassLoader();
+ LauncherImpl launcher = new LauncherImpl();
+ launcher.setApplicationLoader(cl);
+ CompositeComponent composite = launcher.bootRuntime(cl.getResource(LauncherImpl.METAINF_SYSTEM_SCDL_PATH),
+ new NullMonitorFactory());
+
+ for (String extensionName : extensions.keySet()) {
+ deployExtension(composite, extensionName, extensions.get(extensionName));
+ }
+
+ if (applicationSCDL == null) {
+ throw new RuntimeException("application SCDL not found: " + applicationSCDL);
+ }
+ component = launcher.bootApplication("application", applicationSCDL);
+ component.start();
+ context = new CompositeContextImpl(component);
+ context.start();
+ }
+
+ /**
+ * A TestCase can use this to overide the default SCDL location of "META-INF/sca/default.scdl"
+ */
+ protected void setApplicationSCDL(URL applicationSCDL) {
+ this.applicationSCDL = applicationSCDL;
+ }
+
+ /**
+ * Set the application scdl based on the classpath entry for a class.
+ * Normally this will be a class in the production code associated with this test case.
+ *
+ * @param aClass a Class from which to determine the resource base url
+ * @param path location of the application SCDL relative to the base class
+ * @throws MalformedURLException if the path is malformed
+ */
+ protected void setApplicationSCDL(Class<?> aClass, String path) throws MalformedURLException {
+ URL root = getRoot(aClass);
+ setApplicationSCDL(new URL(root, path));
+ }
+
+ /**
+ * A TestCase can use this to add the SCDL location of an extention to be deployed to the runtime
+ */
+ protected void addExtension(String extensionName, URL extentionSCDL) {
+ extensions.put(extensionName, extentionSCDL);
+ }
+
+ protected void deployExtension(CompositeComponent composite, String extensionName, URL scdlURL)
+ throws LoaderException {
+ SystemCompositeImplementation implementation = new SystemCompositeImplementation();
+ implementation.setScdlLocation(scdlURL);
+ implementation.setClassLoader(new URLClassLoader(new URL[]{scdlURL}, getClass().getClassLoader()));
+
+ ComponentDefinition<SystemCompositeImplementation> definition =
+ new ComponentDefinition<SystemCompositeImplementation>(extensionName, implementation);
+
+ Deployer deployer = (Deployer) composite.getSystemChild("deployer").getServiceInstance();
+ Component component = deployer.deploy(composite, definition);
+
+ component.start();
+ }
+
+
+ protected static URL getRoot(Class<?> aClass) {
+ String name = aClass.getName();
+ String classPath = "/" + name.replace('.', '/') + ".class";
+ URL classURL = aClass.getResource(classPath);
+ assert classURL != null;
+ StringBuilder prefix = new StringBuilder();
+ for (int i = 0; i < name.length(); i++) {
+ if (name.charAt(i) == '.') {
+ prefix.append("../");
+ }
+ }
+ try {
+ return new URL(classURL, prefix.toString());
+ } catch (MalformedURLException e) {
+ throw new AssertionError();
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ context.stop();
+ component.stop();
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/TestLauncher.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/TestLauncher.java
new file mode 100644
index 0000000000..b66716bac0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/TestLauncher.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test;
+
+import java.io.File;
+
+import org.apache.tuscany.core.launcher.LauncherImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestLauncher extends LauncherImpl {
+
+ public File getInstallDirectory() {
+ return new File(".");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBinding.java
new file mode 100644
index 0000000000..36d204cedc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBinding.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.model.Binding;
+
+
+/**
+ * A simple binding for test purposes.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class TestBinding extends Binding {
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingBuilder.java
new file mode 100644
index 0000000000..7140320c08
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingBuilder.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestBindingBuilder extends BindingBuilderExtension<TestBinding> {
+
+ @SuppressWarnings("unchecked")
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<TestBinding> definition,
+ DeploymentContext context) {
+ Class<?> interfaze = definition.getServiceContract().getInterfaceClass();
+ return new TestBindingService(definition.getName(), interfaze, parent, wireService);
+ }
+
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<TestBinding> definition,
+ DeploymentContext context) {
+ Class<?> interfaze = definition.getServiceContract().getInterfaceClass();
+ String name = definition.getName();
+ return new TestBindingReference(name, interfaze, parent, wireService);
+ }
+
+ protected Class<TestBinding> getBindingType() {
+ return TestBinding.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingLoader.java
new file mode 100644
index 0000000000..db7ba3df6a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingLoader.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.Version;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestBindingLoader extends LoaderExtension<TestBinding> {
+
+ public static final QName BINDING_TEST = new QName(Version.XML_NAMESPACE_1_0, "binding.test");
+
+ @Constructor
+ public TestBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_TEST;
+ }
+
+ public TestBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext context) throws XMLStreamException, LoaderException {
+ return new TestBinding();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java
new file mode 100644
index 0000000000..a76362da08
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingReference.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestBindingReference extends ReferenceExtension {
+
+ public TestBindingReference(String name, Class<?> interfaze, CompositeComponent parent, WireService wireService) {
+ super(name, interfaze, parent, wireService);
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return new TestInvoker();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingRuntimeException.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingRuntimeException.java
new file mode 100644
index 0000000000..21f8bd1067
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingRuntimeException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestBindingRuntimeException extends TuscanyRuntimeException {
+
+ public TestBindingRuntimeException() {
+ }
+
+ public TestBindingRuntimeException(String message) {
+ super(message);
+ }
+
+ public TestBindingRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TestBindingRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingService.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingService.java
new file mode 100644
index 0000000000..66ef7ab879
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestBindingService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestBindingService extends ServiceExtension {
+ public TestBindingService(String name,
+ Class<?> interfaze,
+ CompositeComponent parent,
+ WireService wireService) throws CoreRuntimeException {
+ super(name, interfaze, parent, wireService);
+ // do nothing, but this could register with the host environment
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestInvoker.java
new file mode 100644
index 0000000000..4a6bed766e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestInvoker.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestInvoker implements TargetInvoker {
+
+ private boolean cacheable;
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable();
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ // echo back the result, a real binding would invoke some API for flowing the request
+ return ((Object[]) payload)[0];
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBinding.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBinding.java
new file mode 100644
index 0000000000..edb191501e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBinding.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * A simple socket-based binding. Service operations may onyl take one parameter that is <code>Serializable</code>
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class TestSocketBinding extends Binding {
+ private String host;
+ private int port;
+
+ public TestSocketBinding(String host, int port) {
+ this.host = host;
+ this.port = port;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingBuilder.java
new file mode 100644
index 0000000000..b674a518bb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingBuilder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestSocketBindingBuilder extends BindingBuilderExtension<TestSocketBinding> {
+
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<TestSocketBinding> definition,
+ DeploymentContext context) {
+ Class<?> interfaze = definition.getServiceContract().getInterfaceClass();
+ int port = definition.getBinding().getPort();
+ return new TestSocketBindingService(definition.getName(), port, interfaze, parent, wireService);
+ }
+
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<TestSocketBinding> definition,
+ DeploymentContext context) {
+ Class<?> interfaze = definition.getServiceContract().getInterfaceClass();
+ String name = definition.getName();
+ int port = definition.getBinding().getPort();
+ String host = definition.getBinding().getHost();
+ return new TestSocketBindingReference(name, host, port, interfaze, parent, wireService);
+ }
+
+ protected Class<TestSocketBinding> getBindingType() {
+ return TestSocketBinding.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingLoader.java
new file mode 100644
index 0000000000..98393e1baa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingLoader.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.Version;
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestSocketBindingLoader extends LoaderExtension<TestSocketBinding> {
+
+ public static final QName BINDING_TEST = new QName(Version.XML_NAMESPACE_1_0, "binding.socket");
+
+ @Constructor
+ public TestSocketBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return TestSocketBindingLoader.BINDING_TEST;
+ }
+
+ public TestSocketBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext context) throws XMLStreamException, LoaderException {
+ String host = reader.getAttributeValue(null, "host");
+ int port;
+ try {
+ port = Integer.parseInt(reader.getAttributeValue(null, "port"));
+ } catch (NumberFormatException e) {
+ throw new LoaderException("Invalid port specified", e);
+ }
+ return new TestSocketBinding(host, port);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingReference.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingReference.java
new file mode 100644
index 0000000000..211b173d63
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingReference.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestSocketBindingReference extends ReferenceExtension {
+
+ private String host;
+ private int port;
+
+ public TestSocketBindingReference(String name,
+ String host,
+ int port,
+ Class<?> interfaze,
+ CompositeComponent parent,
+ WireService wireService) {
+ super(name, interfaze, parent, wireService);
+ this.port = port;
+ this.host = host;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return new TestSocketInvoker(host, port, operation.getName());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingService.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingService.java
new file mode 100644
index 0000000000..6710094b4a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketBindingService.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * Implements a very simple remote, socket-based binding for test purposes. This binding exposes services using a socket
+ * on a given port. Service operations must take only one paramter that is <code>Serializable</code>.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSocketBindingService extends ServiceExtension {
+ private int port;
+ private ServerSocket socket;
+ private ExecutorService executor;
+ private TestSocketBindingService.ServerRunnable runnable;
+
+ public TestSocketBindingService(String name,
+ int port,
+ Class<?> interfaze,
+ CompositeComponent parent,
+ WireService wireService) throws CoreRuntimeException {
+ super(name, interfaze, parent, wireService);
+ this.port = port;
+ }
+
+ public void start() {
+ executor = Executors.newSingleThreadExecutor();
+ // create a listener, note that a work scheduler should normally be used to spawn work in different threads
+ runnable = new ServerRunnable();
+ executor.execute(runnable);
+ }
+
+ public void stop() {
+ try {
+ runnable.setEnd(true);
+ socket.close();
+ executor.shutdownNow();
+ } catch (IOException e) {
+ throw new TestBindingRuntimeException(e);
+ }
+ }
+
+ /**
+ * Creates a socket listener in another thread which handles one client at a time. For a real binding, a work
+ * scheduler should be used
+ */
+ private class ServerRunnable implements Runnable {
+
+ private boolean end;
+
+ public void setEnd(boolean end) {
+ this.end = end;
+ }
+
+ public void run() {
+ Socket clientSocket;
+ ObjectInputStream is = null;
+ ObjectOutputStream os = null;
+ try {
+ socket = new ServerSocket(port);
+ } catch (IOException e) {
+ throw new TestBindingRuntimeException(e);
+ }
+ while (!end) {
+ try {
+ clientSocket = socket.accept();
+ is = new ObjectInputStream(clientSocket.getInputStream());
+ String operation = is.readUTF();
+ int argn = is.readInt();
+ Object[] args = new Object[argn];
+ for (int i = 0; i<argn; i++) {
+ args[i] = is.readObject();
+ }
+ Map<Operation<?>, InboundInvocationChain> chains = getInboundWire().getInvocationChains();
+ for (InboundInvocationChain chain : chains.values()) {
+ if (chain.getOperation().getName().equals(operation)) {
+ Message message = new MessageImpl();
+ message.setTargetInvoker(chain.getTargetInvoker());
+ message.setBody(args);
+ message = chain.getHeadInterceptor().invoke(message);
+ os = new ObjectOutputStream(clientSocket.getOutputStream());
+ os.writeObject(message.getBody());
+ os.flush();
+ }
+ }
+ } catch (IOException e) {
+ throw new TestBindingRuntimeException(e);
+ } catch (ClassNotFoundException e) {
+ throw new TestBindingRuntimeException(e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ // ingore
+ }
+ }
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketInvoker.java
new file mode 100644
index 0000000000..154c1422a1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/java/org/apache/tuscany/test/binding/TestSocketInvoker.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test.binding;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Responsible for serializing an operation parameter flowing the invocation through the socket
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestSocketInvoker implements TargetInvoker {
+ private String host;
+ private int port;
+ private String operation;
+
+ private boolean cacheable;
+
+ public TestSocketInvoker(String host, int port, String operation) {
+ this.host = host;
+ this.port = port;
+ this.operation = operation;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable();
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ /**
+ * Sends the payload over a socket
+ */
+ public Object invokeTarget(final Object object) throws InvocationTargetException {
+ int argn;
+ if (object == null) {
+ argn = 0;
+ } else if (!object.getClass().isArray()) {
+ argn = 1;
+ } else {
+ argn = ((Object[])object).length;
+ }
+
+ Socket socket = null;
+ ObjectOutputStream os = null;
+ ObjectInputStream is = null;
+ try {
+ socket = new Socket(host, port);
+ os = new ObjectOutputStream(socket.getOutputStream());
+ os.writeUTF(operation);
+ os.writeInt(argn);
+ for (int i=0; i<argn; i++) {
+ if (!object.getClass().isArray()) {
+ os.writeObject(object);
+ }
+ else {
+ os.writeObject(((Object[])object)[i]);
+ }
+ }
+ os.flush();
+ is = new ObjectInputStream(socket.getInputStream());
+ return is.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new InvocationTargetException(e);
+ } catch (UnknownHostException e) {
+ throw new InvocationTargetException(e);
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ if (socket != null) {
+ try {
+ socket.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/system.scdl
new file mode 100644
index 0000000000..ab3a29364f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/system.scdl
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.launcher.System">
+
+ <!-- Component that provides the Deployer service -->
+ <component name="deployer">
+ <system:implementation.system class="org.apache.tuscany.core.deployer.DeployerImpl"/>
+ </component>
+
+ <!-- Work management -->
+ <component name="workContext">
+ <system:implementation.system class="org.apache.tuscany.core.component.WorkContextImpl"/>
+ </component>
+
+ <!-- Wire service -->
+ <component name="wireService">
+ <system:implementation.system class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+ </component>
+
+ <!-- Scope infrastructure -->
+ <component name="scopeRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ScopeRegistryImpl"/>
+ </component>
+
+ <!-- Builder and BuilderRegistry -->
+ <component name="builder">
+ <system:implementation.system class="org.apache.tuscany.core.builder.BuilderRegistryImpl"/>
+ </component>
+
+ <!-- Loader and LoaderRegistry -->
+ <component name="loader">
+ <system:implementation.system class="org.apache.tuscany.core.loader.LoaderRegistryImpl"/>
+ </component>
+
+ <!-- Introspector and IntrospectionRegistry -->
+ <component name="interfaceProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.implementation.IntrospectionRegistryImpl"/>
+ </component>
+
+ <!-- Connector infrastructure -->
+ <component name="connector">
+ <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
+ </component>
+
+ <component name="wirePostProcessorRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+ </component>
+
+ <!-- Default scopes -->
+ <component name="scope.module">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
+ </component>
+ <component name="scope.stateless">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
+ </component>
+
+ <!-- include loader configuration -->
+ <include name="org.apache.tuscany.launcher.Loader" scdlResource="org/apache/tuscany/core/loader.scdl"/>
+
+ <!-- include implementation processor configuration -->
+ <include name="org.apache.tuscany.launcher.Implementation" scdlResource="org/apache/tuscany/core/implementation.scdl"/>
+
+ <!-- Java interface definition language -->
+ <include name="org.apache.tuscany.launcher.InterfaceJava" scdlResource="org/apache/tuscany/core/interfaceJava.scdl"/>
+
+ <!-- include omposite implementation type -->
+ <include name="org.apache.tuscany.launcher.Composite" scdlResource="org/apache/tuscany/core/composite.scdl"/>
+
+ <!-- System implementation type -->
+ <include name="org.apache.tuscany.launcher.SystemImplementation" scdlResource="org/apache/tuscany/core/systemImplementation.scdl"/>
+
+ <!-- Java implementation type -->
+ <include name="org.apache.tuscany.launcher.JavaImplementation" scdlResource="org/apache/tuscany/core/javaImplementation.scdl"/>
+
+ <!-- Data Binding -->
+ <include name="org.apache.tuscany.launcher.DataBinding" scdlResource="org/apache/tuscany/core/databinding.scdl"/>
+
+ <!-- System implementation type -->
+ <include name="org.apache.tuscany.test.TestBindingImplementation" scdlLocation="test.binding.system.scdl"/>
+
+ <!-- service for resolving artifacts against the user's local Maven repository -->
+ <component name="artifactRepository">
+ <system:implementation.system class="org.apache.tuscany.core.services.artifact.LocalMavenRepository"/>
+ <property name="repository">.m2/repository</property>
+ </component>
+
+ <!-- WorkScheduler service -->
+ <component name="workManager">
+ <system:implementation.system
+ class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+ <property name="poolSize">10</property>
+ </component>
+
+ <component name="workScheduler">
+ <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
+ </component>
+
+ <component name="policyBuilderRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+ </component>
+
+ <component name="propertyFactory">
+ <system:implementation.system class="org.apache.tuscany.core.property.PropertyObjectFactoryImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/test.binding.system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/test.binding.system.scdl
new file mode 100644
index 0000000000..f59ece0b05
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/main/resources/META-INF/tuscany/test.binding.system.scdl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<!--
+ JavaScript configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="org.apache.tuscany.test.TestBindingImplementation">
+
+ <component name="BindingLoader">
+ <system:implementation.system class="org.apache.tuscany.test.binding.TestBindingLoader"/>
+ </component>
+
+ <component name="BindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.test.binding.TestBindingBuilder"/>
+ </component>
+
+ <component name="SocketBindingLoader">
+ <system:implementation.system class="org.apache.tuscany.test.binding.TestSocketBindingLoader"/>
+ </component>
+
+ <component name="SocketBindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.test.binding.TestSocketBindingBuilder"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/test/src/test/java/org/apache/tuscany/test/SCATestCaseTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/test/src/test/java/org/apache/tuscany/test/SCATestCaseTestCase.java
new file mode 100644
index 0000000000..fac190b02e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/test/src/test/java/org/apache/tuscany/test/SCATestCaseTestCase.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.test;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCATestCaseTestCase extends TestCase {
+ public void testGetRoot() throws MalformedURLException {
+ URL classUrl = getClass().getResource("SCATestCaseTestCase.class");
+ URL root = SCATestCase.getRoot(getClass());
+ assertEquals(classUrl, new URL(root, "org/apache/tuscany/test/SCATestCaseTestCase.class"));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/tools/pom.xml
new file mode 100644
index 0000000000..dfbcc827fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/pom.xml
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sca-tools</artifactId>
+ <name>Apache Tuscany SCA Tools</name>
+ <description>SCA Tools.</description>
+
+ <repositories>
+ <repository>
+ <id>eclipse.emf</id>
+ <url>http://download.eclipse.org/tools/emf/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.0-incubator-M2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>${axis2Version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-codegen</artifactId>
+ <version>${axis2Version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>codegen</artifactId>
+ <version>2.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>codegen-ecore</artifactId>
+ <version>2.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>annogen</groupId>
+ <artifactId>annogen</artifactId>
+ <version>0.1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/GenerationParameters.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/GenerationParameters.java
new file mode 100644
index 0000000000..3cb699681c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/GenerationParameters.java
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.ws.java2wsdl.Java2WSDLUtils;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+
+/**
+ * This class encapsulates the parameters that effect the generation of the
+ * WSDL. For example they contain all user settings such as source class,
+ * target location etc.
+ *
+ */
+public class GenerationParameters implements TuscanyJava2WSDLConstants
+{
+ public static final String WSDL_FILENAME_SUFFIX = ".wsdl";
+ public static final String XSD_IMPORT_DELIMITER = "[,]";
+
+ private Map cmdLineOptions = null;
+ private FileOutputStream outputFileStream = null;
+ private String sourceClassName = null;
+
+ private ArrayList extraClasses;
+ private String attrFormDefault = null;
+ private String elementFormDefault = null;
+ private String targetNamespace = null;
+ private String targetNamespacePrefix = null;
+ private String schemaTargetNamespace = null;
+ private String schemaTargetNamespacePrefix = null;
+ private ClassLoader classLoader = null;
+ private String serviceName = null;
+ private String style = DOCUMENT;
+ private String use = LITERAL;
+ private String locationUri = DEFAULT_LOCATION_URL;
+ private Map schemaLocationMap = null;
+
+ public GenerationParameters(Map cmdLineOptions) throws Exception
+ {
+ this.cmdLineOptions = cmdLineOptions;
+ loadParameters();
+ }
+
+ protected void loadParameters() throws Exception
+ {
+ initializeSourceClassName();
+ resolveFileOutputStream();
+ resolveClassLoader4InputClasspath();
+ loadSchemaLocationMap();
+ initializeOtherParams();
+ }
+
+ private Java2WSDLCommandLineOption loadOption(String shortOption, String longOption) {
+ //short option gets precedence
+ Java2WSDLCommandLineOption option = null;
+ if (longOption != null) {
+ option = (Java2WSDLCommandLineOption) cmdLineOptions.get(longOption);
+ if (option != null) {
+ return option;
+ }
+ }
+ if (shortOption != null) {
+ option = (Java2WSDLCommandLineOption) cmdLineOptions.get(shortOption);
+ }
+
+ return option;
+ }
+
+ protected void initializeSourceClassName() throws Exception
+ {
+ Java2WSDLCommandLineOption option =
+ loadOption(CLASSNAME_OPTION, CLASSNAME_OPTION_LONG);
+ sourceClassName = option == null ? null : option.getOptionValue();
+
+ if (sourceClassName == null || sourceClassName.equals("")) {
+ throw new Exception("class name must be present!");
+ }
+ }
+
+ /**
+ * @throws Exception
+ */
+ protected void resolveFileOutputStream() throws Exception
+ {
+ File outputFolder;
+ Java2WSDLCommandLineOption option = loadOption(OUTPUT_LOCATION_OPTION,
+ OUTPUT_LOCATION_OPTION_LONG);
+ String outputFolderName = option == null ? System.getProperty("user.dir") : option.getOptionValue();
+
+ outputFolder = new File(outputFolderName);
+ if (!outputFolder.exists()) {
+ outputFolder.mkdirs();
+ } else if (!outputFolder.isDirectory()) {
+ throw new Exception("The specified location " + outputFolderName + "is not a folder");
+ }
+
+ option = loadOption(OUTPUT_FILENAME_OPTION,
+ OUTPUT_FILENAME_OPTION_LONG);
+ String outputFileName = option == null ? null : option.getOptionValue();
+ //derive a file name from the class name if the filename is not specified
+ if (outputFileName == null)
+ {
+ outputFileName = Java2WSDLUtils.getSimpleClassName(sourceClassName) + WSDL_FILENAME_SUFFIX;
+ }
+
+ //first create a file in the given location
+ File outputFile = new File(outputFolder, outputFileName);
+ try
+ {
+ if (!outputFile.exists())
+ {
+ outputFile.createNewFile();
+ }
+ outputFileStream = new FileOutputStream(outputFile);
+ }
+ catch (IOException e)
+ {
+ throw new Exception(e);
+ }
+ }
+
+ protected void addToSchemaLocationMap(String optionValue) throws Exception
+ {
+ //option value will be of the form [namespace, schemalocation]
+ //hence we take the two substrings starting after '[' and upto ',' and
+ //starting after ',' and upto ']'
+ getSchemaLocationMap().put(optionValue.substring(1, optionValue.indexOf(COMMA)),
+ optionValue.substring(optionValue.indexOf(COMMA) + 1, optionValue.length() - 1));
+
+
+ }
+
+ protected void loadSchemaLocationMap() throws Exception
+ {
+ Java2WSDLCommandLineOption option = loadOption(IMPORT_XSD_OPTION, IMPORT_XSD_OPTION_LONG);
+
+ if (option != null)
+ {
+ ArrayList optionValues = option.getOptionValues();
+
+ for ( int count = 0 ; count < optionValues.size() ; ++count )
+ {
+ addToSchemaLocationMap(((String)optionValues.get(count)).trim());
+ }
+ }
+ }
+
+ protected void resolveClassLoader4InputClasspath() throws Exception
+ {
+ Java2WSDLCommandLineOption option =
+ loadOption(CLASSPATH_OPTION, CLASSPATH_OPTION_LONG);
+
+ if (option != null) {
+ ArrayList optionValues = option.getOptionValues();
+ URL[] urls = new URL[optionValues.size()];
+ String[] classPathEntries = (String[]) optionValues.toArray(new String[optionValues.size()]);
+
+ try {
+ for (int i = 0; i < classPathEntries.length; i++) {
+ String classPathEntry = classPathEntries[i];
+ //this should be a file(or a URL)
+ if (Java2WSDLUtils.isURL(classPathEntry)) {
+ urls[i] = new URL(classPathEntry);
+ } else {
+ urls[i] = new File(classPathEntry).toURL();
+ }
+ }
+ } catch (MalformedURLException e) {
+ throw new Exception(e);
+ }
+
+ classLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
+
+ } else {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ }
+
+ protected void initializeOtherParams()
+ {
+// set the other parameters to the builder
+ Java2WSDLCommandLineOption option = loadOption(SCHEMA_TARGET_NAMESPACE_OPTION,
+ SCHEMA_TARGET_NAMESPACE_OPTION_LONG);
+ schemaTargetNamespace = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION,
+ SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION_LONG);
+ schemaTargetNamespacePrefix = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(TARGET_NAMESPACE_OPTION,
+ TARGET_NAMESPACE_OPTION_LONG);
+ targetNamespace = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(TARGET_NAMESPACE_PREFIX_OPTION,
+ TARGET_NAMESPACE_PREFIX_OPTION_LONG);
+ targetNamespacePrefix = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(SERVICE_NAME_OPTION,
+ SERVICE_NAME_OPTION_LONG);
+ serviceName = (option == null) ? Java2WSDLUtils.getSimpleClassName(sourceClassName) : option.getOptionValue();
+
+ option = loadOption(STYLE_OPTION,STYLE_OPTION);
+ style = (option == null) ? null : option.getOptionValue();
+
+
+ option = loadOption(LOCATION_OPTION,
+ LOCATION_OPTION);
+ locationUri = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(USE_OPTION,USE_OPTION);
+ use = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(ATTR_FORM_DEFAULT_OPTION, ATTR_FORM_DEFAULT_OPTION_LONG);
+ attrFormDefault = (option == null) ? null : option.getOptionValue();
+
+ option = loadOption(ELEMENT_FORM_DEFAULT_OPTION,ELEMENT_FORM_DEFAULT_OPTION_LONG);
+ elementFormDefault = option == null ? null : option.getOptionValue();
+
+ option = loadOption(TuscanyJava2WSDLConstants.EXTRA_CLASSES_DEFAULT_OPTION,
+ TuscanyJava2WSDLConstants.EXTRA_CLASSES_DEFAULT_OPTION_LONG);
+ extraClasses = option == null ? new ArrayList() : option.getOptionValues();
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader)
+ {
+ this.classLoader = classLoader;
+ }
+
+ public String getLocationUri()
+ {
+ if ( locationUri == null )
+ {
+ locationUri = DEFAULT_LOCATION_URL;
+ }
+ return locationUri;
+ }
+
+ public void setLocationUri(String locationUri)
+ {
+ this.locationUri = locationUri;
+ }
+
+ public FileOutputStream getOutputFileStream()
+ {
+ return outputFileStream;
+ }
+
+ public void setOutputFileStream(FileOutputStream outputFileStream)
+ {
+ this.outputFileStream = outputFileStream;
+ }
+
+ public String getSchemaTargetNamespace() throws Exception
+ {
+ if (schemaTargetNamespace == null
+ || schemaTargetNamespace.trim().equals(""))
+ {
+ this.schemaTargetNamespace = Java2WSDLUtils
+ .schemaNamespaceFromClassName(getSourceClassName(), getClassLoader()).toString();
+ }
+ return schemaTargetNamespace;
+ }
+
+ public void setSchemaTargetNamespace(String schemaTargetNamespace)
+ {
+ this.schemaTargetNamespace = schemaTargetNamespace;
+ }
+
+ public String getSchemaTargetNamespacePrefix()
+ {
+ if (schemaTargetNamespacePrefix == null
+ || schemaTargetNamespacePrefix.trim().equals(""))
+ {
+ this.schemaTargetNamespacePrefix = SCHEMA_NAMESPACE_PRFIX;
+ }
+
+ return schemaTargetNamespacePrefix;
+ }
+
+ public void setSchemaTargetNamespacePrefix(String schemaTargetNamespacePrefix)
+ {
+ this.schemaTargetNamespacePrefix = schemaTargetNamespacePrefix;
+ }
+
+ public String getServiceName()
+ {
+ if ( serviceName == null )
+ {
+ serviceName = Java2WSDLUtils.getSimpleClassName(getSourceClassName());
+ }
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName)
+ {
+ this.serviceName = serviceName;
+ }
+
+ public String getSourceClassName()
+ {
+ return sourceClassName;
+ }
+
+ public void setSourceClassName(String sourceClassName)
+ {
+ this.sourceClassName = sourceClassName;
+ }
+
+ public String getStyle()
+ {
+ if ( style == null )
+ {
+ style = DOCUMENT;
+ }
+ return style;
+ }
+
+ public void setStyle(String style)
+ {
+ this.style = style;
+ }
+
+ public String getTargetNamespace() throws Exception
+ {
+ if ( targetNamespace == null ) {
+ targetNamespace = Java2WSDLUtils.namespaceFromClassName(this.sourceClassName, this.classLoader).toString();
+ }
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace)
+ {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public String getTargetNamespacePrefix()
+ {
+ return targetNamespacePrefix;
+ }
+
+ public void setTargetNamespacePrefix(String targetNamespacePrefix)
+ {
+ this.targetNamespacePrefix = targetNamespacePrefix;
+ }
+
+ public String getUse()
+ {
+ if ( use == null )
+ {
+ use = LITERAL;
+ }
+ return use;
+ }
+
+ public void setUse(String use)
+ {
+ this.use = use;
+ }
+
+ public Map getSchemaLocationMap()
+ {
+ if ( schemaLocationMap == null )
+ {
+ schemaLocationMap = new Hashtable();
+ }
+ return schemaLocationMap;
+ }
+
+ public void setSchemaLocationMap(Map schemaLocationMap) {
+ this.schemaLocationMap = schemaLocationMap;
+ }
+
+ public String getAttrFormDefault() {
+ if ( attrFormDefault == null )
+ {
+ attrFormDefault = FORM_DEFAULT_QUALIFIED;
+ }
+ return attrFormDefault;
+ }
+
+ public void setAttrFormDefault(String attrFormDefault) {
+ this.attrFormDefault = attrFormDefault;
+ }
+
+ public String getElementFormDefault() {
+ if ( elementFormDefault == null )
+ {
+ elementFormDefault = FORM_DEFAULT_QUALIFIED;
+ }
+ return elementFormDefault;
+ }
+
+ public void setElementFormDefault(String elementFormDefault) {
+ this.elementFormDefault = elementFormDefault;
+ }
+
+ public ArrayList getExtraClasses() {
+ return extraClasses;
+ }
+
+ public void setExtraClasses(ArrayList extraClasses) {
+ this.extraClasses = extraClasses;
+ }
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDL.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDL.java
new file mode 100644
index 0000000000..8855c3f6e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDL.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOptionParser;
+
+/**
+ * This class provides the tooling abstraction to Tuscany Java2WSDL and can be
+ * invoked from command line with the follwing options as with Axis2 Java2WSDL
+ *
+ */
+public class Java2WSDL {
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ //parse the cmd line args
+ Java2WSDLCommandLineOptionParser commandLineOptionParser =
+ new Java2WSDLCommandLineOptionParser(args);
+ // validate the arguments
+ validateCommandLineOptions(commandLineOptionParser);
+
+ Java2WSDLGeneratorFactory.getInstance().createGenerator().
+ generateWSDL(commandLineOptionParser.getAllOptions());
+
+ // Uncomment the following statement to directly run the Axis2 tool
+ // without
+ // runAxis2Tool(args);
+ }
+
+ private static void runAxis2Tool(String[] args) {
+ org.apache.ws.java2wsdl.Java2WSDL.main(args);
+ }
+
+ private static void validateCommandLineOptions(Java2WSDLCommandLineOptionParser parser) {
+ if (parser.getAllOptions().size() == 0) {
+ printUsage();
+ } else if (parser.getInvalidOptions(new TuscanyJava2WSDLOptionsValidator()).size() > 0) {
+ printUsage();
+ }
+
+ }
+
+ public static void printUsage() {
+ System.out.println("Usage java2wsdl -cn <fully qualified class name> : class file name");
+ System.out.println("-o <output Location> : output file location");
+ System.out.println("-cp <class path uri> : list of classpath entries - (urls)");
+ System.out.println("-tn <target namespace> : target namespace");
+ System.out.println("-tp <target namespace prefix> : target namespace prefix");
+ System.out.println("-stn <schema target namespace> : target namespace for schema");
+ System.out.println("-stp <schema target namespace prefix> : target namespace prefix for schema");
+ System.out.println("-sn <service name> : service name");
+ System.out.println("-of <output file name> : output file name for the WSDL");
+ System.out.println("-st <binding style> : style for the WSDL");
+ System.out.println("-u <binding use> : use for the WSDL");
+ System.out.println("-l <soap address> : address of the port for the WSDL");
+ System.out.println("-ixsd [<schema namespace>, <schema location>] : schemas to be imported (and not generated)");
+ System.out.println("-efd <unqualified> : Setting for elementFormDefault (defaults to qualified)");
+ System.out.println("-afd <unqualified> : Setting for attributeFormDefault (defaults to qualified)");
+ System.out.println("-xc <extra class> : Extra class for which schematype must be generated. " +
+ "\t\tUse as : -xc class1 -xc class2 ...");
+ System.exit(0);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGenerator.java
new file mode 100644
index 0000000000..3323113af4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGenerator.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.OutputStream;
+import java.util.Map;
+
+/**
+ * This is the Java2WSDL Generator facade that will be used by Tuscany
+ * components for java to wsdl conversion.
+ *
+ */
+public interface Java2WSDLGenerator {
+ public void generateWSDL(String[] args);
+
+ public void generateWSDL(Map commandLineOptions);
+
+ public void addWSDLGenListener(WSDLGenListener l);
+
+ public void removeWSDLGenListener(WSDLGenListener l);
+
+ public Map getCommandLineOptions();
+
+ public void setCommandLineOptoins(Map cmdLineOpts);
+
+ public OutputStream getOutputStream();
+
+ public void setOutputStream(OutputStream outStream);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorFactory.java
new file mode 100644
index 0000000000..e8f3db95b0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorFactory.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.util.Vector;
+
+/**
+ * Factory that creates Java2WSDL Generators. Presently the there is a Default
+ * Generator that wraps around the AXIS2 Java2WSDL implementation. The factory
+ * can be extended to create generators that wrap around other implementations
+ * if required.
+ */
+
+public class Java2WSDLGeneratorFactory {
+ /*
+ * singleton instance of this factory class
+ */
+ private static Java2WSDLGeneratorFactory factory = null;
+
+ /**
+ * code for the default generator
+ */
+ public static final int DEFAULT_GENERATOR = 0;
+
+ /**
+ * Default Generator class name
+ */
+ public static final String DEFAULT_GENERATOR_CLASSNAME = "org.apache.tuscany.tools.java2wsdl.generate.Java2WSDLGeneratorImpl";
+
+ /**
+ * list of generator classnames in a position that corresponds to their
+ * code. For example the default generator's code is 0 and hence this
+ * generator's classname is stored at index '0' of the list
+ */
+ protected Vector<String> generatorClassNames = new Vector<String>();
+
+ /**
+ * @return the singleton instance of this generator factory
+ */
+ public static Java2WSDLGeneratorFactory getInstance() {
+ if (factory == null) {
+ factory = new Java2WSDLGeneratorFactory();
+ }
+ return factory;
+ }
+
+ private Java2WSDLGeneratorFactory() {
+ generatorClassNames.addElement(DEFAULT_GENERATOR_CLASSNAME);
+ }
+
+ public Java2WSDLGenerator createGenerator() {
+ return createGenerator(DEFAULT_GENERATOR);
+ }
+
+ /**
+ * creates an instance of a Java2WSDL Generator based on the input type
+ *
+ * @param genType
+ * type of the generator to be created
+ * @return an instance of a Java2WSDL Generator
+ */
+ public Java2WSDLGenerator createGenerator(int genType) {
+ try {
+ return (Java2WSDLGenerator) (Class.forName(generatorClassNames
+ .elementAt(genType)).newInstance());
+ } catch (Exception e) {
+ System.out
+ .println(" Unable to create Java2WSDL generator due to .....");
+ System.out.println(e);
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorImpl.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorImpl.java
new file mode 100644
index 0000000000..9d1a9df438
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/Java2WSDLGeneratorImpl.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.ws.java2wsdl.Java2WSDL;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOptionParser;
+import org.apache.ws.java2wsdl.utils.Java2WSDLOptionsValidator;
+
+/**
+ * This is an implementation of the Java2WSDLGenerator facade. This
+ * implementation is a decorator around the Axis2 implementation of the
+ * Java2WSDL conversion. The WSDL generation is divided into phases that are
+ * stringed up as a template method. The phases are - User Input Validation -
+ * WSDL Java Model Generation - Serialization of WSDL Java Model The function of
+ * each phase is accomplished by delegation to the appropriate classes in Axis2.
+ * At the start and end of each phase an event is published to subcribers
+ * denoting the start and end of the phase.
+ *
+ * Such a spliting up of the Java2WSDL conversion into phases has been designed
+ * to enable interceptors to modify the model or apply transformations to the
+ * output. Typically the interceptors can subscribe to the start and end events
+ * of these phases and hence be able to intercept.
+ *
+ * Note: This class contains substantial AXIS2 Java2WSDL code refactored into
+ * it. These will be removed as and when the Axis2 code is fixed.
+ *
+ */
+public class Java2WSDLGeneratorImpl implements Java2WSDLGenerator, TuscanyJava2WSDLConstants
+{
+ private List<WSDLGenListener> genPhaseListeners = new Vector<WSDLGenListener>();
+ private GenerationParameters genParams = null;
+ private Map<String, Java2WSDLCommandLineOption> commandLineOptions = null;
+ private TuscanyJava2WSDLBuilder java2WsdlBuilder;
+ private OutputStream outputStream = null;
+
+ public Java2WSDLGeneratorImpl()
+ {
+
+ }
+
+ private void multicastGenPhaseCompletionEvent(int genPhase) {
+ WSDLGenEvent event = new WSDLGenEvent(this, genPhase);
+ Iterator iterator = genPhaseListeners.iterator();
+ while (iterator.hasNext()) {
+ ((WSDLGenListener) iterator.next()).WSDLGenPhaseCompleted(event);
+ }
+ }
+
+ private void initJava2WSDLBuilder() throws Exception
+ {
+// Now we are done with loading the basic values - time to create the builder
+ java2WsdlBuilder = new TuscanyJava2WSDLBuilder(genParams);
+ }
+
+ protected boolean validateInputArgs(String[] args)
+ {
+ boolean isValid = true;
+ Java2WSDLCommandLineOptionParser parser = new Java2WSDLCommandLineOptionParser(args);
+ if (parser.getAllOptions().size() == 0) {
+ Java2WSDL.printUsage();
+ isValid = false;
+ } else if (parser.getInvalidOptions(new Java2WSDLOptionsValidator())
+ .size() > 0) {
+ Java2WSDL.printUsage();
+ isValid = false;
+ }
+
+ if (isValid)
+ {
+ commandLineOptions = parser.getAllOptions();
+ }
+
+ return isValid;
+ }
+
+ public boolean buildWSDLDocument() throws Exception
+ {
+ boolean isComplete = true;
+ initJava2WSDLBuilder();
+ java2WsdlBuilder.buildWSDL();
+
+ return isComplete;
+ }
+
+ public boolean serializeWSDLDocument() throws Exception {
+ boolean isComplete = true;
+
+ if ( getOutputStream() == null )
+ {
+ setOutputStream(genParams.getOutputFileStream());
+ }
+
+ java2WsdlBuilder.getWsdlDocument().serialize(getOutputStream());
+ getOutputStream().flush();
+ getOutputStream().close();;
+
+ return isComplete;
+ }
+
+ /*
+ * This is the template method that splits the Java2WSDL generation cycle
+ * into phase / steps.
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#generateWSDL(java.lang.String[])
+ */
+ public void generateWSDL(Map commandLineOptions)
+ {
+ try
+ {
+ // load the user options into an easy to access abstraction
+ genParams = new GenerationParameters(commandLineOptions);
+
+ // if the WSDL Model generation was successul
+ if ( buildWSDLDocument() )
+ {
+ // multicast event for generation of wsdl model
+ multicastGenPhaseCompletionEvent(WSDLGenListener.WSDL_MODEL_CREATION);
+ // if the serialization of the generated (and fixed) model
+ // is successful
+ if (serializeWSDLDocument()) {
+ // multicast event for writing of the WSDL Model to
+ // supplied output stream
+ multicastGenPhaseCompletionEvent(WSDLGenListener.WSDL_MODEL_WRITING);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ // TODO Auto-generated method stub
+
+ }
+
+ public void generateWSDL(String[] args)
+ {
+ // if the argument input are found to be valid
+ if (validateInputArgs(args))
+ {
+ //multicast event for input args validation complete
+ multicastGenPhaseCompletionEvent(WSDLGenListener.INPUT_ARGS_VALIDATION);
+ generateWSDL(commandLineOptions);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#addWSDLGenListener(tuscany.tools.WSDLGenListener)
+ */
+ public void addWSDLGenListener(WSDLGenListener l) {
+ genPhaseListeners.add(l);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#removeWSDLGenListener(tuscany.tools.WSDLGenListener)
+ */
+ public void removeWSDLGenListener(WSDLGenListener l) {
+ genPhaseListeners.remove(l);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#getCommandLineOptions()
+ */
+ public Map getCommandLineOptions() {
+ return commandLineOptions;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#setCommandLineOptoins(java.util.Map)
+ */
+ public void setCommandLineOptoins(Map cmdLineOpts) {
+ commandLineOptions = cmdLineOpts;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#getOutputStream()
+ */
+ public OutputStream getOutputStream() {
+ // TODO Auto-generated method stub
+ return outputStream;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see tuscany.tools.Java2WSDLGeneratorIfc#setOutputStream(java.io.OutputStream)
+ */
+ public void setOutputStream(OutputStream outStream) {
+ outputStream = outStream;
+ }
+
+
+ public TuscanyJava2WSDLBuilder getJava2WsdlBuilder()
+ {
+ return java2WsdlBuilder;
+ }
+
+ public void setJava2WsdlBuilder(TuscanyJava2WSDLBuilder java2WsdlBuilder)
+ {
+ this.java2WsdlBuilder = java2WsdlBuilder;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
new file mode 100644
index 0000000000..67609445ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
@@ -0,0 +1,524 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaForm;
+import org.apache.ws.commons.schema.XmlSchemaGroupBase;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.apache.ws.java2wsdl.Java2WSDLUtils;
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JProperty;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.XSDHelper;
+
+public class SchemaBuilder implements TuscanyJava2WSDLConstants {
+ public static final String NAME_SPACE_PREFIX = "stn_";
+
+ private static int prefixCount = 1;
+
+ public static final String MIXED = "mixed";
+
+ public static final String GROUP = "group";
+
+ protected String attrFormDefault = null;
+
+ protected String elementFormDefault = null;
+
+ protected XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
+
+ private Hashtable schemaMap = new Hashtable();
+
+ protected Hashtable targetNamespacePrefixMap = new Hashtable();
+
+ protected TuscanyTypeTable typeTable = new TuscanyTypeTable();
+
+ protected Map schemaLocationMap = null;
+
+ private ClassLoader classLoader;
+
+ protected SchemaBuilder(XmlSchemaCollection schemaCollection,
+ Hashtable schemaMap,
+ Hashtable nsPrefixMap,
+ TuscanyTypeTable typeTable,
+ String attrFormDef,
+ String eleFormDef,
+ Map schemaLocMap,
+ ClassLoader classLoader) {
+ this.schemaMap = schemaMap;
+ this.xmlSchemaCollection = schemaCollection;
+ this.targetNamespacePrefixMap = nsPrefixMap;
+ this.typeTable = typeTable;
+ this.schemaLocationMap = schemaLocMap;
+ this.classLoader = classLoader;
+ this.attrFormDefault = attrFormDef;
+ this.elementFormDefault = eleFormDef;
+ }
+
+ private boolean isSDO(JClass javaType) throws Exception {
+ Class sdoClass = Class.forName(javaType.getQualifiedName(),
+ true,
+ classLoader);
+ return DataObject.class.isAssignableFrom(sdoClass);
+ }
+
+ private void buildComplexTypeContents_JavaType(JClass javaType,
+ XmlSchemaComplexType complexType,
+ XmlSchema xmlSchema) throws Exception {
+ JProperty[] properties = javaType.getDeclaredProperties();
+
+ for (int i = 0; i < properties.length; i++) {
+ JProperty property = properties[i];
+ String propertyName = property.getType().getQualifiedName();
+ boolean isArryType = property.getType().isArrayType();
+ if (isArryType) {
+ propertyName = property.getType().getArrayComponentType().getQualifiedName();
+ }
+
+ if (typeTable.isSimpleType(propertyName)) {
+ XmlSchemaElement elt1 = new XmlSchemaElement();
+ elt1.setName(getCorrectName(property.getSimpleName()));
+ elt1.setSchemaTypeName(typeTable.getSimpleSchemaTypeName(propertyName));
+ ((XmlSchemaGroupBase) complexType.getParticle()).getItems().add(elt1);
+ if (isArryType) {
+ elt1.setMaxOccurs(Long.MAX_VALUE);
+ elt1.setMinOccurs(0);
+ }
+ } else {
+ QName schemaTypeName = null;
+ if (isArryType) {
+ schemaTypeName = generateSchema(property.getType().getArrayComponentType());
+ } else {
+ schemaTypeName = generateSchema(property.getType());
+ }
+
+ XmlSchemaElement elt1 = new XmlSchemaElement();
+ elt1.setName(getCorrectName(property.getSimpleName()));
+ elt1.setSchemaTypeName(schemaTypeName);
+ ((XmlSchemaGroupBase) complexType.getParticle()).getItems().add(elt1);
+
+ if (isArryType) {
+ elt1.setMaxOccurs(Long.MAX_VALUE);
+ elt1.setMinOccurs(0);
+ }
+
+ addImports(xmlSchema,
+ schemaTypeName);
+ }
+ }
+ }
+
+ protected QName buildSchema_JavaType(JClass javaType) throws Exception {
+ QName schemaTypeName = typeTable.getComplexSchemaTypeName(javaType, this.classLoader);
+ if (schemaTypeName == null) {
+ String simpleName = javaType.getSimpleName();
+
+ String packageName = javaType.getContainingPackage().getQualifiedName();
+
+ String targetNameSpace =
+ Java2WSDLUtils.schemaNamespaceFromClassName(javaType.getQualifiedName(), this.classLoader)
+ .toString();
+
+ XmlSchema xmlSchema = getXmlSchema(targetNameSpace);
+ String targetNamespacePrefix = (String) targetNamespacePrefixMap.get(targetNameSpace);
+
+ schemaTypeName = new QName(targetNameSpace, simpleName, targetNamespacePrefix);
+ XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
+ complexType.setName(simpleName);
+
+ XmlSchemaSequence sequence = new XmlSchemaSequence();
+ complexType.setParticle(sequence);
+
+ createGlobalElement(xmlSchema,
+ complexType,
+ schemaTypeName);
+ xmlSchema.getItems().add(complexType);
+ xmlSchema.getSchemaTypes().add(schemaTypeName,
+ complexType);
+
+ // adding this type to the table
+ // typeTable.addComplexScheam(name, complexType.getQName());
+ typeTable.addComplexSchemaType(targetNameSpace,
+ simpleName,
+ schemaTypeName);
+ buildComplexTypeContents_JavaType(javaType,
+ complexType,
+ xmlSchema);
+ }
+ return schemaTypeName;
+ }
+
+ protected QName buildSchema_SDO(Type dataType) // throws Exception
+ {
+ QName schemaTypeName = typeTable.getComplexSchemaTypeName(dataType.getURI(),
+ dataType.getName());
+
+ if (schemaTypeName == null) {
+ // invoke XSDHelper to generate schema for this sdo type
+ XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper());
+ // it is better to check if XSDHelper can generate the schema
+ if (xsdHelper.isXSD(dataType)) {
+ // if schemalocations for xsd has been specified, include them
+ includeExtXSD(dataType);
+ } else {
+ List typeList = new Vector();
+ typeList.add(dataType);
+
+ // the xsdhelper returns a string that contains the schemas for this type
+ String schemaDefns = xsdHelper.generate(typeList,
+ schemaLocationMap);
+
+ // extract the schema elements and store them in the schema map
+ extractSchemas(schemaDefns);
+ }
+ // since the XSDHelper will not return the type name, create it and store it in typetable
+ schemaTypeName = new QName(dataType.getURI(), dataType.getName(), generatePrefix());
+ typeTable.addComplexSchemaType(dataType.getURI(),
+ dataType.getName(),
+ schemaTypeName);
+
+ }
+ return schemaTypeName;
+ }
+
+ public QName generateSchema(JClass javaType) throws Exception {
+ if (isSDO(javaType)) {
+ Type dataType = createDataObject(javaType).getType();
+ return buildSchema_SDO(dataType);
+ } else {
+ return buildSchema_JavaType(javaType);
+ }
+ }
+
+ private XmlSchema getXmlSchema(String targetNamespace) {
+ XmlSchema xmlSchema;
+
+ if ((xmlSchema = (XmlSchema) schemaMap.get(targetNamespace)) == null) {
+ String targetNamespacePrefix = generatePrefix();
+
+ xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
+ xmlSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
+ xmlSchema.setElementFormDefault(getElementFormDefaultSetting());
+
+ targetNamespacePrefixMap.put(targetNamespace,
+ targetNamespacePrefix);
+ schemaMap.put(targetNamespace,
+ xmlSchema);
+
+ NamespaceMap prefixmap = new NamespaceMap();
+ prefixmap.put(TuscanyTypeTable.XS_URI_PREFIX,
+ TuscanyTypeTable.XML_SCHEMA_URI);
+ prefixmap.put(targetNamespacePrefix,
+ targetNamespace);
+ xmlSchema.setNamespaceContext(prefixmap);
+ }
+ return xmlSchema;
+ }
+
+ /**
+ * JAM convert first name of an attribute into UpperCase as an example if there is a instance variable called foo in a bean , then Jam give that
+ * as Foo so this method is to correct that error
+ *
+ * @param wrongName
+ * @return the right name, using english as the locale for case conversion
+ */
+ public static String getCorrectName(String wrongName) {
+ if (wrongName.length() > 1) {
+ return wrongName.substring(0,
+ 1).toLowerCase(Locale.ENGLISH)
+ + wrongName.substring(1,
+ wrongName.length());
+ } else {
+ return wrongName.substring(0,
+ 1).toLowerCase(Locale.ENGLISH);
+ }
+ }
+
+ private String addImports(XmlSchema xmlSchema, QName schemaTypeName) {
+ String prefix = null;
+ String[] prefixes = xmlSchema.getNamespaceContext().getDeclaredPrefixes();
+ for (int count = 0; count < prefixes.length; ++count) {
+ if (schemaTypeName.getNamespaceURI().
+ equals(xmlSchema.getNamespaceContext().getNamespaceURI(prefixes[count])) ) {
+ return prefixes[count];
+ }
+ }
+
+ // the following lines are executed only if a prefix was not found which implies that the
+ // schemaTypeName was not imported earlier and also it does not belong to the targetnamespace
+ String schemaLocation = null;
+ XmlSchemaImport importElement = new XmlSchemaImport();
+ importElement.setNamespace(schemaTypeName.getNamespaceURI());
+ xmlSchema.getItems().add(importElement);
+ prefix = generatePrefix();
+ //it is safe to cast like this since it was this class that instantiated the
+ //NamespaceContext and assigned it to an instance of a NamespaceMap (see method getXmlSchema)
+ ((NamespaceMap)xmlSchema.getNamespaceContext()).put(prefix,
+ schemaTypeName.getNamespaceURI());
+
+ return prefix;
+ }
+
+ private String formGlobalElementName(String typeName) {
+ String firstChar = typeName.substring(0,
+ 1);
+ return typeName.replaceFirst(firstChar,
+ firstChar.toLowerCase());
+ }
+
+ private void createGlobalElement(XmlSchema xmlSchema,
+ XmlSchemaComplexType complexType,
+ QName elementName) {
+ XmlSchemaElement globalElement = new XmlSchemaElement();
+ globalElement.setSchemaTypeName(complexType.getQName());
+ globalElement.setName(formGlobalElementName(complexType.getName()));
+ globalElement.setQName(elementName);
+
+ xmlSchema.getItems().add(globalElement);
+ xmlSchema.getElements().add(elementName,
+ globalElement);
+ }
+
+ private DataObject createDataObject(JClass sdoClass) throws Exception {
+ Class sdoType = Class.forName(sdoClass.getQualifiedName(),
+ true,
+ classLoader);
+
+ Constructor constructor = sdoType.getDeclaredConstructor(new Class[0]);
+ constructor.setAccessible(true);
+ Object instance = constructor.newInstance(new Object[0]);
+ return (DataObject) instance;
+ }
+
+ private String generatePrefix() {
+ return NAME_SPACE_PREFIX + prefixCount++;
+ }
+
+ private void includeExtXSD(Type dataType) {
+ // now we know there is a type for which the xsd must come from outside
+ // create a schema for the namespace of this type and add an include in it for
+ // the xsd that is defined externally
+ XmlSchema xmlSchema = getXmlSchema(dataType.getURI());
+
+ // ideally there could be more than one external schema defintions for a namespace
+ // and hence schemalocations will be a list of locations
+ // List schemaLocations = (List)schemaLocationMap.get(dataType.getURI());
+
+ // since as per the specs the input to XSDHelper is a map of <String, String> allowing
+ // only one schemalocation for a namespace. So for now this single location will be
+ // picked up and put into a list
+ List schemaLocations = new Vector();
+
+ if (schemaLocationMap.get(dataType.getURI()) != null) {
+ schemaLocations.add(schemaLocationMap.get(dataType.getURI()));
+ }
+
+ if (schemaLocations.size() <= 0) {
+ schemaLocations.add(DEFAULT_SCHEMA_LOCATION);
+ }
+
+ Iterator includesIterator = xmlSchema.getIncludes().getIterator();
+ Iterator schemaLocIterator = schemaLocations.iterator();
+ String aSchemaLocation = null;
+ boolean includeExists = false;
+ // include all external schema locations
+ while (schemaLocIterator.hasNext()) {
+ aSchemaLocation = (String) schemaLocIterator.next();
+ while (includesIterator.hasNext()) {
+ if (!includeExists
+ && aSchemaLocation.equals(((XmlSchemaInclude) includesIterator.next()).getSchemaLocation())) {
+ includeExists = true;
+ }
+ }
+
+ if (!includeExists) {
+ XmlSchemaInclude includeElement = new XmlSchemaInclude();
+ includeElement.setSchemaLocation(aSchemaLocation);
+ xmlSchema.getIncludes().add(includeElement);
+ xmlSchema.getItems().add(includeElement);
+ }
+ }
+
+ }
+
+ private void extractSchemas(String schemaDefns) {
+ // load each schema element and add it to the schema map
+
+ String token = getToken(schemaDefns);
+ int curIndex = schemaDefns.indexOf(token);
+ int nextIndex = schemaDefns.indexOf(token,
+ curIndex + token.length());
+
+ while (curIndex != -1) {
+ StringReader sr = null;
+ if (nextIndex != -1)
+ sr = new StringReader(schemaDefns.substring(curIndex,
+ nextIndex));
+ else
+ sr = new StringReader(schemaDefns.substring(curIndex));
+
+ XmlSchemaCollection collection = new XmlSchemaCollection();
+ XmlSchema aSchema = collection.read(sr,
+ null);
+ addSchemaToMap(aSchema);
+
+ curIndex = nextIndex;
+ nextIndex = schemaDefns.indexOf(token,
+ curIndex + token.length());
+ }
+ }
+
+ private void addSchemaToMap(XmlSchema extractedSchema) {
+ // check if a Schema object already exists in schema map for targetNamespace of this schema element
+ // if it does then copy the contents of this schema element to the existing one, ensuring that
+ // duplicate elements are not created. i.e. before adding some child element like 'include' or 'import'
+ // check if it already exists, if it does don't add this
+ XmlSchema existingSchema = (XmlSchema) schemaMap.get(extractedSchema.getTargetNamespace());
+
+ if (existingSchema == null) {
+ extractedSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
+ extractedSchema.setElementFormDefault(getElementFormDefaultSetting());
+ schemaMap.put(extractedSchema.getTargetNamespace(),
+ extractedSchema);
+
+ } else {
+ copySchemaItems(existingSchema,
+ extractedSchema);
+ }
+ }
+
+ private void copySchemaItems(XmlSchema existingSchema, XmlSchema aSchema) {
+ // items to copy are imports, includes, elements, types ...
+ // each item is checked if it is a duplicate entry and copied only if it isn't
+ Iterator itemsIterator = aSchema.getItems().getIterator();
+ Object schemaObject = null;
+ XmlSchemaElement schemaElement = null;
+ XmlSchemaType schemaType = null;
+ XmlSchemaInclude schemaInclude = null;
+ QName qName = null;
+ List existingIncludes = getExistingIncludes(existingSchema);
+
+ while (itemsIterator.hasNext()) {
+ schemaObject = itemsIterator.next();
+ if (schemaObject instanceof XmlSchemaElement) {
+ schemaElement = (XmlSchemaElement) schemaObject;
+ qName = schemaElement.getQName();
+ // if the element does not exist in the existing schema
+ if (existingSchema.getElementByName(qName) == null) {
+ // add it to the existing schema
+ existingSchema.getElements().add(qName,
+ schemaElement);
+ existingSchema.getItems().add(schemaElement);
+ }
+ } else if (schemaObject instanceof XmlSchemaType) {
+ schemaType = (XmlSchemaType) itemsIterator.next();
+ qName = schemaType.getQName();
+ // if the element does not exist in the existing schema
+ if (existingSchema.getElementByName(qName) == null) {
+ // add it to the existing schema
+ existingSchema.getSchemaTypes().add(qName,
+ schemaType);
+ existingSchema.getItems().add(schemaType);
+ // add imports
+ addImports(existingSchema,
+ qName);
+ }
+ } else if (schemaObject instanceof XmlSchemaInclude) {
+ schemaInclude = (XmlSchemaInclude) itemsIterator.next();
+ if (!existingIncludes.contains(schemaInclude.getSchemaLocation())) {
+ existingSchema.getIncludes().add(schemaInclude);
+ existingSchema.getItems().add(schemaInclude);
+ }
+ }
+ }
+ }
+
+ private List getExistingIncludes(XmlSchema xmlSchema) {
+ List includeSchemaLocations = new Vector();
+ Iterator iterator = xmlSchema.getIncludes().getIterator();
+
+ while (iterator.hasNext()) {
+ includeSchemaLocations.add(((XmlSchemaInclude) iterator.next()).getSchemaLocation());
+ }
+ return includeSchemaLocations;
+ }
+
+ private XmlSchemaForm getAttrFormDefaultSetting() {
+ if (FORM_DEFAULT_UNQUALIFIED.equals(getAttrFormDefault())) {
+ return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ } else {
+ return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ }
+ }
+
+ private XmlSchemaForm getElementFormDefaultSetting() {
+ if (FORM_DEFAULT_UNQUALIFIED.equals(getElementFormDefault())) {
+ return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ } else {
+ return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ }
+ }
+
+ private String getToken(String s) {
+ // get the schema element name eg. <xs:schema or <xsd:schema. We only know that 'schema' will be used
+ // but not sure what suffix is used. Hence this method to get the actual element name used
+ int i = s.indexOf(SCHEMA_ELEMENT_NAME);
+ int j = s.substring(0,
+ i).lastIndexOf("<");
+ return s.substring(j,
+ i + SCHEMA_ELEMENT_NAME.length());
+ }
+
+ public String getAttrFormDefault() {
+ return attrFormDefault;
+ }
+
+ public void setAttrFormDefault(String attrFormDefault) {
+ this.attrFormDefault = attrFormDefault;
+ }
+
+ public String getElementFormDefault() {
+ return elementFormDefault;
+ }
+
+ public void setElementFormDefault(String elementFormDefault) {
+ this.elementFormDefault = elementFormDefault;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java
new file mode 100644
index 0000000000..e58d729981
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java
@@ -0,0 +1,521 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+import org.codehaus.jam.JMethod;
+
+public class TuscanyJava2OMBuilder implements Java2WSDLConstants {
+
+ private TuscanyTypeTable typeTable = null;
+
+ private static int prefixCount = 1;
+
+ private static final String NAMESPACE_PREFIX = "ns";
+
+ private JMethod method[];
+
+ private Collection schemaCollection;
+
+ private GenerationParameters generationParams;
+
+ private OMNamespace ns1;
+
+ private OMNamespace soap;
+
+ private OMNamespace soap12;
+
+ private OMNamespace tns;
+
+ private OMNamespace wsdl;
+
+ private OMNamespace mime;
+
+ private OMNamespace http;
+
+ public TuscanyJava2OMBuilder(JMethod[] method,
+ Collection schemaCollection,
+ TuscanyTypeTable typeTab,
+ GenerationParameters genParams) {
+ this.method = method;
+ this.schemaCollection = schemaCollection;
+ this.typeTable = typeTab;
+ this.generationParams = genParams;
+ }
+
+ public OMElement generateOM() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ wsdl = fac.createOMNamespace(WSDL_NAMESPACE,
+ DEFAULT_WSDL_NAMESPACE_PREFIX);
+ OMElement ele = fac.createOMElement("definitions",
+ wsdl);
+
+ ele.addAttribute("targetNamespace",
+ generationParams.getTargetNamespace(),
+ null);
+ generateNamespaces(fac,
+ ele);
+ generateTypes(fac,
+ ele);
+ generateMessages(fac,
+ ele);
+ generatePortType(fac,
+ ele);
+ generateBinding(fac,
+ ele);
+ generateService(fac,
+ ele);
+ return ele;
+ }
+
+ private void generateNamespaces(OMFactory fac, OMElement defintions) throws Exception {
+ soap = defintions.declareNamespace(URI_WSDL11_SOAP,
+ SOAP11_PREFIX);
+ tns = defintions.declareNamespace(generationParams.getTargetNamespace(),
+ generationParams.getTargetNamespacePrefix());
+ soap12 = defintions.declareNamespace(URI_WSDL12_SOAP,
+ SOAP12_PREFIX);
+ http = defintions.declareNamespace(HTTP_NAMESPACE,
+ HTTP_PREFIX);
+ mime = defintions.declareNamespace(MIME_NAMESPACE,
+ MIME_PREFIX);
+ }
+
+ private void generateTypes(OMFactory fac, OMElement defintions) throws Exception {
+ OMElement wsdlTypes = fac.createOMElement("types",
+ wsdl);
+ StringWriter writer = new StringWriter();
+
+ // wrap the Schema elements with this start and end tags to create a
+ // document root
+ // under which the schemas can fall into
+ writer.write("<xmlSchemas>");
+ writeSchemas(writer);
+ writer.write("</xmlSchemas>");
+
+ XMLStreamReader xmlReader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new ByteArrayInputStream(writer.toString()
+ .getBytes()));
+
+ StAXOMBuilder staxOMBuilders = new StAXOMBuilder(fac, xmlReader);
+ OMElement documentElement = staxOMBuilders.getDocumentElement();
+
+
+ Iterator iterator = documentElement.getChildElements();
+ while (iterator.hasNext()) {
+ wsdlTypes.addChild((OMNode) iterator.next());
+ }
+ defintions.addChild(wsdlTypes);
+ }
+
+ private void writeSchemas(StringWriter writer) {
+ Iterator iterator = schemaCollection.iterator();
+ XmlSchema xmlSchema = null;
+
+ while (iterator.hasNext()) {
+ xmlSchema = (XmlSchema) iterator.next();
+ // typeIterator = xmlSchema.getSchemaTypes().getValues();
+ /*
+ * while (typeIterator.hasNext()) { xmlSchema.getItems().add((XmlSchemaObject) typeIterator.next()); }
+ */
+ xmlSchema.write(writer);
+ }
+ }
+
+ private void generateMessages(OMFactory fac, OMElement definitions) throws Exception {
+ Hashtable namespaceMap = new Hashtable();
+ String namespacePrefix = null;
+ String namespaceURI = null;
+ QName messagePartType = null;
+ for (int i = 0; i < method.length; i++) {
+ JMethod jmethod = method[i];
+
+ if (jmethod.isPublic()) {
+ // Request Message
+ OMElement requestMessge = fac.createOMElement(MESSAGE_LOCAL_NAME,
+ wsdl);
+ requestMessge.addAttribute(ATTRIBUTE_NAME,
+ jmethod.getSimpleName() + MESSAGE_SUFFIX,
+ null);
+ definitions.addChild(requestMessge);
+
+ // only if a type for the message part has already been defined
+ if ((messagePartType = typeTable.getComplexSchemaTypeName(generationParams.getSchemaTargetNamespace(),
+ jmethod.getSimpleName())) != null) {
+ namespaceURI = messagePartType.getNamespaceURI();
+ // avoid duplicate namespaces
+ if ((namespacePrefix = (String) namespaceMap.get(namespaceURI)) == null) {
+ namespacePrefix = generatePrefix();
+ namespaceMap.put(namespaceURI,
+ namespacePrefix);
+ }
+
+ OMElement requestPart = fac.createOMElement(PART_ATTRIBUTE_NAME,
+ wsdl);
+ requestMessge.addChild(requestPart);
+ requestPart.addAttribute(ATTRIBUTE_NAME,
+ "part1",
+ null);
+
+ requestPart.addAttribute(ELEMENT_ATTRIBUTE_NAME,
+ namespacePrefix + COLON_SEPARATOR
+ + jmethod.getSimpleName(),
+ null);
+ }
+
+ // only if a type for the message part has already been defined
+ if ((messagePartType = typeTable.getComplexSchemaTypeName(generationParams.getSchemaTargetNamespace(),
+ jmethod.getSimpleName()
+ + RESPONSE)) != null) {
+ namespaceURI = messagePartType.getNamespaceURI();
+ if ((namespacePrefix = (String) namespaceMap.get(namespaceURI)) == null) {
+ namespacePrefix = generatePrefix();
+ namespaceMap.put(namespaceURI,
+ namespacePrefix);
+ }
+ // Response Message
+ OMElement responseMessge = fac.createOMElement(MESSAGE_LOCAL_NAME,
+ wsdl);
+ responseMessge.addAttribute(ATTRIBUTE_NAME,
+ jmethod.getSimpleName() + RESPONSE_MESSAGE,
+ null);
+ definitions.addChild(responseMessge);
+ OMElement responsePart = fac.createOMElement(PART_ATTRIBUTE_NAME,
+ wsdl);
+ responseMessge.addChild(responsePart);
+ responsePart.addAttribute(ATTRIBUTE_NAME,
+ "part1",
+ null);
+
+ responsePart.addAttribute(ELEMENT_ATTRIBUTE_NAME,
+ namespacePrefix + COLON_SEPARATOR
+ + jmethod.getSimpleName() + RESPONSE,
+ null);
+ }
+ }
+ }
+
+ // now add these unique namespaces to the the definitions element
+ Enumeration enumeration = namespaceMap.keys();
+ while (enumeration.hasMoreElements()) {
+ namespaceURI = (String) enumeration.nextElement();
+ definitions.declareNamespace(namespaceURI,
+ (String) namespaceMap.get(namespaceURI));
+ }
+ }
+
+ /**
+ * Generate the porttypes
+ */
+ private void generatePortType(OMFactory fac, OMElement defintions) {
+ JMethod jmethod = null;
+ OMElement operation = null;
+ OMElement message = null;
+ OMElement portType = fac.createOMElement(PORT_TYPE_LOCAL_NAME,
+ wsdl);
+ defintions.addChild(portType);
+ portType.addAttribute(ATTRIBUTE_NAME,
+ generationParams.getServiceName() + PORT_TYPE_SUFFIX,
+ null);
+ // adding message refs
+ for (int i = 0; i < method.length; i++) {
+ jmethod = method[i];
+
+ if (jmethod.isPublic()) {
+ operation = fac.createOMElement(OPERATION_LOCAL_NAME,
+ wsdl);
+ portType.addChild(operation);
+ operation.addAttribute(ATTRIBUTE_NAME,
+ jmethod.getSimpleName(),
+ null);
+
+ message = fac.createOMElement(IN_PUT_LOCAL_NAME,
+ wsdl);
+ message.addAttribute(MESSAGE_LOCAL_NAME,
+ tns.getPrefix() + COLON_SEPARATOR + jmethod.getSimpleName()
+ + MESSAGE_SUFFIX,
+ null);
+ operation.addChild(message);
+
+ if (!jmethod.getReturnType().isVoidType()) {
+ message = fac.createOMElement(OUT_PUT_LOCAL_NAME,
+ wsdl);
+ message.addAttribute(MESSAGE_LOCAL_NAME,
+ tns.getPrefix() + COLON_SEPARATOR
+ + jmethod.getSimpleName() + RESPONSE_MESSAGE,
+ null);
+ operation.addChild(message);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Generate the service
+ */
+ public void generateService(OMFactory fac, OMElement defintions) {
+ OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME,
+ wsdl);
+ defintions.addChild(service);
+ service.addAttribute(ATTRIBUTE_NAME,
+ generationParams.getServiceName(),
+ null);
+ OMElement port = fac.createOMElement(PORT,
+ wsdl);
+ service.addChild(port);
+ port.addAttribute(ATTRIBUTE_NAME,
+ generationParams.getServiceName() + SOAP11PORT,
+ null);
+ port.addAttribute(BINDING_LOCAL_NAME,
+ tns.getPrefix() + COLON_SEPARATOR + generationParams.getServiceName()
+ + BINDING_NAME_SUFFIX,
+ null);
+ addExtensionElement(fac,
+ port,
+ soap,
+ SOAP_ADDRESS,
+ LOCATION,
+ generationParams.getLocationUri() + generationParams.getServiceName());
+
+ port = fac.createOMElement(PORT,
+ wsdl);
+ service.addChild(port);
+ port.addAttribute(ATTRIBUTE_NAME,
+ generationParams.getServiceName() + SOAP12PORT,
+ null);
+ port.addAttribute(BINDING_LOCAL_NAME,
+ tns.getPrefix() + COLON_SEPARATOR + generationParams.getServiceName()
+ + SOAP12BINDING_NAME_SUFFIX,
+ null);
+ addExtensionElement(fac,
+ port,
+ soap12,
+ SOAP_ADDRESS,
+ LOCATION,
+ generationParams.getLocationUri() + generationParams.getServiceName());
+ }
+
+ /**
+ * Generate the bindings
+ */
+ private void generateBinding(OMFactory fac, OMElement defintions) throws Exception {
+ generateSoap11Binding(fac,
+ defintions);
+ generateSoap12Binding(fac,
+ defintions);
+ }
+
+ private void generateSoap11Binding(OMFactory fac, OMElement defintions) throws Exception {
+ OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME,
+ wsdl);
+ defintions.addChild(binding);
+ binding.addAttribute(ATTRIBUTE_NAME,
+ generationParams.getServiceName() + BINDING_NAME_SUFFIX,
+ null);
+ binding.addAttribute("type",
+ tns.getPrefix() + COLON_SEPARATOR + generationParams.getServiceName()
+ + PORT_TYPE_SUFFIX,
+ null);
+
+ addExtensionElement(fac,
+ binding,
+ soap,
+ BINDING_LOCAL_NAME,
+ TRANSPORT,
+ TRANSPORT_URI,
+ STYLE,
+ generationParams.getStyle());
+
+ for (int i = 0; i < method.length; i++) {
+ JMethod jmethod = method[i];
+ if (jmethod.isPublic()) {
+ OMElement operation = fac.createOMElement(OPERATION_LOCAL_NAME,
+ wsdl);
+ binding.addChild(operation);
+
+ addExtensionElement(fac,
+ operation,
+ soap,
+ OPERATION_LOCAL_NAME,
+ SOAP_ACTION,
+ URN_PREFIX + COLON_SEPARATOR + jmethod.getSimpleName(),
+ STYLE,
+ generationParams.getStyle());
+ operation.addAttribute(ATTRIBUTE_NAME,
+ jmethod.getSimpleName(),
+ null);
+
+ OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME,
+ wsdl);
+ addExtensionElement(fac,
+ input,
+ soap,
+ SOAP_BODY,
+ SOAP_USE,
+ generationParams.getUse(),
+ "namespace",
+ generationParams.getTargetNamespace());
+ operation.addChild(input);
+
+ if (!jmethod.getReturnType().isVoidType()) {
+ OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME,
+ wsdl);
+ addExtensionElement(fac,
+ output,
+ soap,
+ SOAP_BODY,
+ SOAP_USE,
+ generationParams.getUse(),
+ "namespace",
+ generationParams.getTargetNamespace());
+ operation.addChild(output);
+ }
+ }
+ }
+ }
+
+ private void generateSoap12Binding(OMFactory fac, OMElement defintions) throws Exception {
+ OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME,
+ wsdl);
+ defintions.addChild(binding);
+ binding.addAttribute(ATTRIBUTE_NAME,
+ generationParams.getServiceName() + SOAP12BINDING_NAME_SUFFIX,
+ null);
+ binding.addAttribute("type",
+ tns.getPrefix() + COLON_SEPARATOR + generationParams.getServiceName()
+ + PORT_TYPE_SUFFIX,
+ null);
+
+ addExtensionElement(fac,
+ binding,
+ soap12,
+ BINDING_LOCAL_NAME,
+ TRANSPORT,
+ TRANSPORT_URI,
+ STYLE,
+ generationParams.getStyle());
+
+ for (int i = 0; i < method.length; i++) {
+ JMethod jmethod = method[i];
+
+ if (jmethod.isPublic()) {
+ OMElement operation = fac.createOMElement(OPERATION_LOCAL_NAME,
+ wsdl);
+ binding.addChild(operation);
+ operation.declareNamespace(URI_WSDL12_SOAP,
+ SOAP12_PREFIX);
+
+ addExtensionElement(fac,
+ operation,
+ soap12,
+ OPERATION_LOCAL_NAME,
+ SOAP_ACTION,
+ URN_PREFIX + COLON_SEPARATOR + jmethod.getSimpleName(),
+ STYLE,
+ generationParams.getStyle());
+ operation.addAttribute(ATTRIBUTE_NAME,
+ jmethod.getSimpleName(),
+ null);
+
+ OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME,
+ wsdl);
+ addExtensionElement(fac,
+ input,
+ soap12,
+ SOAP_BODY,
+ SOAP_USE,
+ generationParams.getUse(),
+ "namespace",
+ generationParams.getTargetNamespace());
+ operation.addChild(input);
+
+ if (!jmethod.getReturnType().isVoidType()) {
+ OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME,
+ wsdl);
+ addExtensionElement(fac,
+ output,
+ soap12,
+ SOAP_BODY,
+ SOAP_USE,
+ generationParams.getUse(),
+ "namespace",
+ generationParams.getTargetNamespace());
+ operation.addChild(output);
+ }
+ }
+ }
+ }
+
+ private void addExtensionElement(OMFactory fac,
+ OMElement element,
+ OMNamespace namespace,
+ String name,
+ String att1Name,
+ String att1Value,
+ String att2Name,
+ String att2Value) {
+ OMElement soapbinding = fac.createOMElement(name,
+ namespace);
+ element.addChild(soapbinding);
+ soapbinding.addAttribute(att1Name,
+ att1Value,
+ null);
+ soapbinding.addAttribute(att2Name,
+ att2Value,
+ null);
+ }
+
+ private void addExtensionElement(OMFactory fac,
+ OMElement element,
+ OMNamespace namespace,
+ String name,
+ String att1Name,
+ String att1Value) {
+ OMElement soapbinding = fac.createOMElement(name,
+ namespace);
+ element.addChild(soapbinding);
+ soapbinding.addAttribute(att1Name,
+ att1Value,
+ null);
+ }
+
+ private String generatePrefix() {
+ return NAMESPACE_PREFIX + prefixCount++;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLBuilder.java
new file mode 100644
index 0000000000..b23726f6fa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLBuilder.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+
+public class TuscanyJava2WSDLBuilder implements Java2WSDLConstants {
+
+ private OutputStream out;
+ private String className;
+ private ClassLoader classLoader;
+ private String wsdlPrefix = "wsdl";
+
+ // these apply for the WSDL
+ private GenerationParameters generationParams;
+
+ private OMElement wsdlDocument = null;
+
+ public String getWsdlPrefix() {
+ return wsdlPrefix;
+ }
+
+ public void setWsdlPrefix(String wsdlPrefix) {
+ this.wsdlPrefix = wsdlPrefix;
+ }
+
+ public TuscanyJava2WSDLBuilder(GenerationParameters genParams) {
+ this.generationParams = genParams;
+ }
+
+ /**
+ * Externally visible generator method
+ *
+ * @throws Exception
+ */
+ public void buildWSDL() throws Exception {
+ ArrayList excludeOpeartion = new ArrayList();
+ excludeOpeartion.add("init");
+ excludeOpeartion.add("setOperationContext");
+ excludeOpeartion.add("destroy");
+
+ TuscanyWSDLTypesGenerator typesGenerator = new TuscanyWSDLTypesGenerator(generationParams);
+ typesGenerator.setExcludeMethods(excludeOpeartion);
+ Collection schemaCollection = typesGenerator.buildWSDLTypes();
+
+ TuscanyJava2OMBuilder java2OMBuilder =
+ new TuscanyJava2OMBuilder(typesGenerator.getMethods(), schemaCollection, typesGenerator
+ .getTypeTable(), generationParams);
+
+ wsdlDocument = java2OMBuilder.generateOM();
+ }
+
+ public OMElement getWsdlDocument() {
+ return wsdlDocument;
+ }
+
+ public void setWsdlDocument(OMElement wsdlDocument) {
+ this.wsdlDocument = wsdlDocument;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLConstants.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLConstants.java
new file mode 100644
index 0000000000..cde870fff4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLConstants.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+
+/**
+ * This is a extension from the Axis2 Java2WSDLConstants to handle additions specific to Tuscany.
+ * This class can be done away with once Axis2 is also enhanced to support these
+ * additional options.
+ *
+ */
+public interface TuscanyJava2WSDLConstants extends Java2WSDLConstants
+{
+ public static final char OPEN_BRACKET = '[';
+ public static final char COMMA = ',';
+ public static final char CLOSE_BRACKET = ']';
+ public static final String DEFAULT_SCHEMA_LOCATION = "*.xsd";
+ public static final String SCHEMA_ELEMENT_NAME = "schema";
+
+ String FORM_DEFAULT_QUALIFIED = "qualified";
+ String FORM_DEFAULT_UNQUALIFIED = "unqualified";
+
+ //short options
+ String IMPORT_XSD_OPTION = "ixsd"; //option for importing XSDs
+ String ATTR_FORM_DEFAULT_OPTION = "afd";
+ String ELEMENT_FORM_DEFAULT_OPTION = "efd";
+ String EXTRA_CLASSES_DEFAULT_OPTION = "xc";
+
+ //long options
+ String IMPORT_XSD_OPTION_LONG = "import_xsd"; //option for importing XSDs
+ String ATTR_FORM_DEFAULT_OPTION_LONG = "attributeFormDefault";
+ String ELEMENT_FORM_DEFAULT_OPTION_LONG = "elementFormDefault";
+ String EXTRA_CLASSES_DEFAULT_OPTION_LONG = "extraClasses";
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLOptionsValidator.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLOptionsValidator.java
new file mode 100644
index 0000000000..6411327abf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLOptionsValidator.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.util.ArrayList;
+
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+import org.apache.ws.java2wsdl.utils.Java2WSDLOptionsValidator;
+
+/**
+ * This class is an extension from the Axis2 implementation in order to handle additional optoins
+ * specific to Tuscany. This class can be done away with once Axis2 is also enhanced to support these
+ * additional options.
+ *
+ */
+public class TuscanyJava2WSDLOptionsValidator extends Java2WSDLOptionsValidator implements
+ TuscanyJava2WSDLConstants {
+ public boolean isInvalid(Java2WSDLCommandLineOption option) {
+ boolean invalid;
+ String optionType = option.getOptionType();
+
+ invalid = !((IMPORT_XSD_OPTION).equalsIgnoreCase(optionType)
+ || (IMPORT_XSD_OPTION_LONG).equalsIgnoreCase(optionType)
+ || (TuscanyJava2WSDLConstants.EXTRA_CLASSES_DEFAULT_OPTION_LONG).equalsIgnoreCase(optionType)
+ || (TuscanyJava2WSDLConstants.EXTRA_CLASSES_DEFAULT_OPTION).equalsIgnoreCase(optionType)
+ || !super.isInvalid(option));
+
+ invalid = validateImportXSDOption(invalid,
+ option);
+
+ return invalid;
+ }
+
+ private boolean validateImportXSDOption(boolean invalid, Java2WSDLCommandLineOption option) {
+ String optionType = option.getOptionType();
+ String schemaNSLocationPair = null;
+
+ if (!invalid && (IMPORT_XSD_OPTION).equalsIgnoreCase(optionType)
+ || (IMPORT_XSD_OPTION_LONG).equalsIgnoreCase(optionType)) {
+ ArrayList optionValues = option.getOptionValues();
+
+ for (int count = 0; count < optionValues.size(); ++count) {
+ schemaNSLocationPair = ((String) optionValues.get(count)).trim();
+ if ((schemaNSLocationPair.charAt(0) != OPEN_BRACKET)
+ || (schemaNSLocationPair.charAt(schemaNSLocationPair.length() - 1) != CLOSE_BRACKET)
+ || (schemaNSLocationPair.indexOf(COMMA) == -1))
+
+ {
+ System.out.println("Schema Namespace-Location pair option not specified properly!!");
+ invalid = true;
+ }
+ }
+ }
+
+ return invalid;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanySchemaGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanySchemaGenerator.java
new file mode 100644
index 0000000000..4f3371126d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanySchemaGenerator.java
@@ -0,0 +1,410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaForm;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+import org.apache.ws.java2wsdl.SchemaGenerator;
+import org.apache.ws.java2wsdl.bytecode.MethodTable;
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JMethod;
+import org.codehaus.jam.JParameter;
+import org.codehaus.jam.JamClassIterator;
+import org.codehaus.jam.JamService;
+import org.codehaus.jam.JamServiceFactory;
+import org.codehaus.jam.JamServiceParams;
+
+
+public class TuscanySchemaGenerator implements TuscanyJava2WSDLConstants
+{
+ public static final String NAME_SPACE_PREFIX = "stn_";
+ public static final String PERIOD_SEPARATOR = ".";
+ private static int prefixCount = 1;
+
+ protected String attrFormDefault = null;
+ protected String elementFormDefault = null;
+ protected Hashtable targetNamespacePrefixMap = new Hashtable();
+ protected Hashtable schemaMap = new Hashtable();
+ protected Hashtable sdoAnnoMap = new Hashtable();
+ protected XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
+ private TuscanyTypeTable typeTable = new TuscanyTypeTable();
+ protected SchemaBuilder schemaBuilder = null;
+ protected Map schemaLocationMap = null;
+
+ private static final Log log = LogFactory.getLog(SchemaGenerator.class);
+ private ClassLoader classLoader;
+ private String className;
+
+ // to keep loadded method using JAM
+ private JMethod methods [];
+
+ //to store byte code method using Axis 1.x codes
+ private MethodTable methodTable;
+ private String schemaTargetNameSpace;
+ private String schema_namespace_prefix;
+ private Class clazz;
+ private ArrayList excludeMethods = new ArrayList();
+
+ public TuscanySchemaGenerator(ClassLoader loader,
+ String className,
+ String schematargetNamespace,
+ String schematargetNamespacePrefix,
+ Map schemaLocMap)
+ throws Exception
+ {
+ DataObjectUtil.initRuntime();
+ this.classLoader = loader;
+ this.className = className;
+ clazz = Class.forName(className, true, loader);
+ methodTable = new MethodTable(clazz);
+ this.schemaTargetNameSpace = schematargetNamespace;
+ this.schema_namespace_prefix = schematargetNamespacePrefix;
+ this.schemaLocationMap = schemaLocMap;
+
+ initializeSchemaMap(this.schemaTargetNameSpace, this.schema_namespace_prefix);
+ schemaBuilder = new SchemaBuilder(xmlSchemaCollection,
+ schemaMap,
+ targetNamespacePrefixMap,
+ typeTable,
+ getAttrFormDefault(),
+ getElementFormDefault(),
+ schemaLocMap,
+ this.classLoader );
+ }
+
+ /**
+ * Generates schema for all the parameters in method. First generates schema
+ * for all different parameter type and later refers to them.
+ *
+ * @return Returns XmlSchema.
+ * @throws Exception
+ */
+ public Collection buildWSDLTypes() throws Exception
+ {
+ JamServiceFactory factory = JamServiceFactory.getInstance();
+ JamServiceParams jam_service_parms = factory.createServiceParams();
+ //setting the classLoder
+// jam_service_parms.setParentClassLoader(factory.createJamClassLoader(classLoader));
+ //it can posible to add the classLoader as well
+ jam_service_parms.addClassLoader(classLoader);
+ jam_service_parms.includeClass(className);
+ JamService service = factory.createService(jam_service_parms);
+
+ JamClassIterator jClassIter = service.getClasses();
+ //all most all the time the ittr will have only one class in it
+ while (jClassIter.hasNext())
+ {
+ JClass jclass = (JClass) jClassIter.next();
+ // serviceName = jclass.getSimpleName();
+ //todo in the future , when we support annotation we can use this
+ //JAnnotation[] annotations = jclass.getAnnotations();
+
+ /**
+ * Schema genertaion done in two stage 1. Load all the methods and
+ * create type for methods parameters (if the parameters are Bean
+ * then it will create Complex types for those , and if the
+ * parameters are simple type which decribe in SimpleTypeTable
+ * nothing will happen) 2. In the next stage for all the methods
+ * messages and port types will be creteated
+ */
+ methods = jclass.getDeclaredMethods();
+
+ // since we do not support overload
+ HashMap uniqueMethods = new HashMap();
+ XmlSchemaComplexType methodSchemaType = null;
+ XmlSchemaSequence sequence = null;
+ QName methodPartSchemaTypeName = null;
+ for (int i = 0; i < methods.length; i++)
+ {
+ String methodName = methods[i].getSimpleName();
+ JMethod jMethod = methods[i];
+ // no need to think abt this method , since that is system
+ // config method
+ if (excludeMethods.contains(jMethod.getSimpleName())) {
+ continue;
+ }
+ //if (jMethod.getSimpleName().equals("init")
+ // || "setOperationContext".equals(jMethod.getSimpleName())
+ // || "destroy".equals(jMethod.getSimpleName()))
+ // continue;
+ if (uniqueMethods.get(jMethod.getSimpleName()) != null) {
+ throw new Exception(
+ " Sorry we don't support methods overloading !!!! ");
+ }
+
+ if (!jMethod.isPublic()) {
+ // no need to generate Schema for non public methods
+ continue;
+ }
+
+ uniqueMethods.put(jMethod.getSimpleName(), jMethod);
+ JParameter [] paras = jMethod.getParameters();
+ String parameterNames [] = null;
+ if (paras.length > 0)
+ {
+ parameterNames = methodTable.getParameterNames(methodName);
+ sequence = new XmlSchemaSequence();
+
+ //create the schema type for the method wrapper
+ methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName());
+ methodSchemaType.setParticle(sequence);
+ }
+
+ for (int j = 0; j < paras.length; j++)
+ {
+ JParameter methodParameter = paras[j];
+ JClass paraType = methodParameter.getType();
+ generateSchemaForType(sequence, paraType,
+ ( parameterNames != null && parameterNames[j] != null )? parameterNames[j] : methodParameter.getSimpleName());
+ }
+ // for its return type
+ JClass returnType = jMethod.getReturnType();
+ QName methodReturnSchemaTypeName = null;
+
+ if (!returnType.isVoidType())
+ {
+ methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName() + RESPONSE);
+ sequence = new XmlSchemaSequence();
+ methodSchemaType.setParticle(sequence);
+ generateSchemaForType(sequence, returnType, "return");
+ }
+ }
+ //generateWrapperElements(methods);
+ }
+ return schemaMap.values();
+ }
+
+ private QName generateSchemaForType(XmlSchemaSequence sequence, JClass type, String partName) throws Exception
+ {
+ boolean isArrayType = type.isArrayType();
+ if ( isArrayType )
+ {
+ type = type.getArrayComponentType();
+ }
+
+ String classTypeName = type.getQualifiedName();
+
+ QName schemaTypeName = typeTable.getSimpleSchemaTypeName(classTypeName);
+ if ( schemaTypeName == null )
+ {
+ schemaTypeName =
+ schemaBuilder.generateSchema(type);
+ addContentToMethodSchemaType(sequence,
+ schemaTypeName,
+ partName,
+ type.isArrayType());
+ addImportORInclude((XmlSchema)schemaMap.get(schemaTargetNameSpace), schemaTypeName);
+
+ }
+ else
+ {
+ addContentToMethodSchemaType(sequence,
+ schemaTypeName,
+ partName,
+ type.isArrayType());
+ }
+
+ return schemaTypeName;
+ }
+
+ private void addContentToMethodSchemaType(XmlSchemaSequence sequence,
+ QName schemaTypeName,
+ String paraName,
+ boolean isArray )
+ {
+ XmlSchemaElement elt1 = new XmlSchemaElement();
+ elt1.setName(paraName);
+ elt1.setSchemaTypeName(schemaTypeName);
+ sequence.getItems().add(elt1);
+
+ if ( isArray )
+ {
+ elt1.setMaxOccurs(Long.MAX_VALUE);
+ elt1.setMinOccurs(0);
+ }
+ }
+
+ private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName)
+ {
+ XmlSchema xmlSchema = (XmlSchema)schemaMap.get(schemaTargetNameSpace);
+ QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix);
+ XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
+
+ XmlSchemaElement globalElement = new XmlSchemaElement();
+ globalElement.setSchemaType(complexType);
+ globalElement.setName(formGlobalElementName(localPartName));
+ globalElement.setQName(elementName);
+
+ xmlSchema.getItems().add(globalElement);
+ xmlSchema.getElements().add(elementName, globalElement);
+
+ typeTable.addComplexSchemaType(this.schemaTargetNameSpace, globalElement.getName(), elementName);
+
+ return complexType;
+ }
+
+
+ private String formGlobalElementName(String typeName)
+ {
+ String firstChar = typeName.substring(0,1);
+ return typeName.replaceFirst(firstChar, firstChar.toLowerCase());
+ }
+
+ public TuscanyTypeTable getTypeTable() {
+ return typeTable;
+ }
+
+ public JMethod[] getMethods() {
+ return methods;
+ }
+
+ private String generatePrefix() {
+ return NAME_SPACE_PREFIX + prefixCount++;
+ }
+
+ public void setExcludeMethods(ArrayList excludeMethods) {
+ this.excludeMethods = excludeMethods;
+ }
+
+ private void initializeSchemaMap(String targetNamespace, String targetNamespacePrefix)
+ {
+ XmlSchema xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
+ xmlSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
+ xmlSchema.setElementFormDefault(getElementFormDefaultSetting());
+
+ targetNamespacePrefixMap.put(targetNamespace, targetNamespacePrefix);
+ schemaMap.put(targetNamespace, xmlSchema);
+
+
+ NamespaceMap prefixmap = new NamespaceMap();
+ prefixmap.put(TuscanyTypeTable.XS_URI_PREFIX, TuscanyTypeTable.XML_SCHEMA_URI);
+ prefixmap.put(targetNamespacePrefix, targetNamespace);
+ xmlSchema.setNamespaceContext(prefixmap);
+ }
+
+ private void setFormDefaults()
+ {
+
+ }
+
+ public Hashtable getSdoAnnoMap() {
+ return sdoAnnoMap;
+ }
+
+ public void setSdoAnnoMap(Hashtable sdoAnnoMap) {
+ this.sdoAnnoMap = sdoAnnoMap;
+ }
+
+ private void addImportORInclude(XmlSchema xmlSchema, QName schemaTypeName)
+ {
+ //decide whether there must be an import or an include
+ if ( xmlSchema.getTargetNamespace().equals(schemaTypeName.getNamespaceURI()) )
+ {
+ XmlSchema containingSchema = (XmlSchema)schemaMap.get(schemaTypeName.getNamespaceURI());
+ //if the type is not defined in the Schema then include
+ if ( containingSchema.getTypeByName(schemaTypeName) == null )
+ {
+ String schemaLocation = null;
+ if ( (schemaLocation = (String)schemaLocationMap.get(schemaTypeName.getNamespaceURI())) != null )
+ {
+ schemaLocation = DEFAULT_SCHEMA_LOCATION;
+ }
+
+ XmlSchemaInclude includeElement = new XmlSchemaInclude();
+ includeElement.setSchemaLocation(schemaLocation);
+
+ if ( !xmlSchema.getIncludes().contains(includeElement) )
+ {
+ xmlSchema.getIncludes().add(includeElement);
+ }
+ }
+ }
+ else
+ {
+ if (!((NamespaceMap)xmlSchema.getNamespaceContext()).values().
+ contains(schemaTypeName.getNamespaceURI()))
+ {
+ XmlSchemaImport importElement = new XmlSchemaImport();
+ importElement.setNamespace(schemaTypeName.getNamespaceURI());
+ xmlSchema.getItems().add(importElement);
+ ((NamespaceMap)xmlSchema.getNamespaceContext()).
+ put(generatePrefix(), schemaTypeName.getNamespaceURI());
+ }
+ }
+ }
+
+ private XmlSchemaForm getAttrFormDefaultSetting()
+ {
+ if ( FORM_DEFAULT_UNQUALIFIED.equals(getAttrFormDefault()) )
+ {
+ return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ }
+ else
+ {
+ return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ }
+ }
+
+ private XmlSchemaForm getElementFormDefaultSetting()
+ {
+ if ( FORM_DEFAULT_UNQUALIFIED.equals(getElementFormDefault()) )
+ {
+ return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ }
+ else
+ {
+ return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ }
+ }
+
+ public String getAttrFormDefault() {
+ return attrFormDefault;
+ }
+
+ public void setAttrFormDefault(String attrFormDefault) {
+ this.attrFormDefault = attrFormDefault;
+ }
+
+ public String getElementFormDefault() {
+ return elementFormDefault;
+ }
+
+ public void setElementFormDefault(String elementFormDefault) {
+ this.elementFormDefault = elementFormDefault;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyTypeTable.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyTypeTable.java
new file mode 100644
index 0000000000..4abd7a7ce7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyTypeTable.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.ws.java2wsdl.Java2WSDLUtils;
+import org.codehaus.jam.JClass;
+
+public class TuscanyTypeTable
+{
+ public static final String XML_SCHEMA_URI = "http://www.w3.org/2001/XMLSchema";
+ public static final String XS_URI_PREFIX = "xs";
+ public static final QName XS_QNAME = new QName(XML_SCHEMA_URI, "schema", XS_URI_PREFIX);
+ public static final String DELIMITER = "#";
+
+ private Hashtable simpleXSDTypes;
+ private Hashtable complexXSDTypes;
+
+ public static String asQualifiedName(String uri, String typeName)
+ {
+ return (uri + DELIMITER + typeName);
+ }
+
+
+ public TuscanyTypeTable()
+ {
+ simpleXSDTypes = new Hashtable();
+ complexXSDTypes = new Hashtable();
+ populateSimpleXSDTypes();
+ populateStdSDOTypes();
+ }
+
+ private void populateStdSDOTypes()
+ {
+ simpleXSDTypes.put("Boolean",
+ new QName(XML_SCHEMA_URI, "boolean", XS_URI_PREFIX));
+ simpleXSDTypes.put("Byte",
+ new QName(XML_SCHEMA_URI, "byte", XS_URI_PREFIX));
+ simpleXSDTypes.put("Bytes",
+ new QName(XML_SCHEMA_URI, "hexBinary", XS_URI_PREFIX));
+ simpleXSDTypes.put("Character",
+ new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX));
+ simpleXSDTypes.put("DataObject",
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put("Date",
+ new QName(XML_SCHEMA_URI, "dateTime", XS_URI_PREFIX));
+ simpleXSDTypes.put("Day",
+ new QName(XML_SCHEMA_URI, "gDay", XS_URI_PREFIX));
+ simpleXSDTypes.put("Decimal",
+ new QName(XML_SCHEMA_URI, "decimal", XS_URI_PREFIX));
+ simpleXSDTypes.put("Double",
+ new QName(XML_SCHEMA_URI, "double", XS_URI_PREFIX));
+ simpleXSDTypes.put("Duration",
+ new QName(XML_SCHEMA_URI, "duration", XS_URI_PREFIX));
+ simpleXSDTypes.put("Float",
+ new QName(XML_SCHEMA_URI, "float", XS_URI_PREFIX));
+ simpleXSDTypes.put("Int",
+ new QName(XML_SCHEMA_URI, "int", XS_URI_PREFIX));
+ simpleXSDTypes.put("Integer",
+ new QName(XML_SCHEMA_URI, "integer", XS_URI_PREFIX));
+ simpleXSDTypes.put("Long",
+ new QName(XML_SCHEMA_URI, "long", XS_URI_PREFIX));
+ simpleXSDTypes.put("Month",
+ new QName(XML_SCHEMA_URI, "gMonth", XS_URI_PREFIX));
+ simpleXSDTypes.put("monthDay",
+ new QName(XML_SCHEMA_URI, "gMonthDay", XS_URI_PREFIX));
+ simpleXSDTypes.put("Object",
+ new QName(XML_SCHEMA_URI, "anySimpleType", XS_URI_PREFIX));
+ simpleXSDTypes.put("Short",
+ new QName(XML_SCHEMA_URI, "short", XS_URI_PREFIX));
+ simpleXSDTypes.put("String",
+ new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX));
+ simpleXSDTypes.put("Strings",
+ new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX));
+ simpleXSDTypes.put("Time",
+ new QName(XML_SCHEMA_URI, "time", XS_URI_PREFIX));
+ simpleXSDTypes.put("Year",
+ new QName(XML_SCHEMA_URI, "gYear", XS_URI_PREFIX));
+ simpleXSDTypes.put("YearMonth",
+ new QName(XML_SCHEMA_URI, "gYearMonth", XS_URI_PREFIX));
+ simpleXSDTypes.put("YearMonthDay",
+ new QName(XML_SCHEMA_URI, "date", XS_URI_PREFIX));
+ simpleXSDTypes.put("URI",
+ new QName(XML_SCHEMA_URI, "anyURI", XS_URI_PREFIX));
+ }
+
+ private void populateSimpleXSDTypes() {
+ //todo pls use the types from org.apache.ws.commons.schema.constants.Constants
+ simpleXSDTypes.put("int",
+ new QName(XML_SCHEMA_URI, "int", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.String",
+ new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX));
+ simpleXSDTypes.put("boolean",
+ new QName(XML_SCHEMA_URI, "boolean", XS_URI_PREFIX));
+ simpleXSDTypes.put("float",
+ new QName(XML_SCHEMA_URI, "float", XS_URI_PREFIX));
+ simpleXSDTypes.put("double",
+ new QName(XML_SCHEMA_URI, "double", XS_URI_PREFIX));
+ simpleXSDTypes.put("short",
+ new QName(XML_SCHEMA_URI, "short", XS_URI_PREFIX));
+ simpleXSDTypes.put("long",
+ new QName(XML_SCHEMA_URI, "long", XS_URI_PREFIX));
+ simpleXSDTypes.put("byte",
+ new QName(XML_SCHEMA_URI, "byte", XS_URI_PREFIX));
+ simpleXSDTypes.put("char",
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Integer",
+ new QName(XML_SCHEMA_URI, "int", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Double",
+ new QName(XML_SCHEMA_URI, "double", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Float",
+ new QName(XML_SCHEMA_URI, "float", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Long",
+ new QName(XML_SCHEMA_URI, "long", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Character",
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Boolean",
+ new QName(XML_SCHEMA_URI, "boolean", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Byte",
+ new QName(XML_SCHEMA_URI, "byte", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Short",
+ new QName(XML_SCHEMA_URI, "short", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.util.Date",
+ new QName(XML_SCHEMA_URI, "dateTime", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.util.Calendar",
+ new QName(XML_SCHEMA_URI, "dateTime", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.lang.Object",
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put("java.math.BigDecimal",
+ new QName(XML_SCHEMA_URI, "decimal", XS_URI_PREFIX));
+
+ // Any types
+ simpleXSDTypes.put(OMElement.class.getName(),
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put(ArrayList.class.getName(),
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put(Vector.class.getName(),
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ simpleXSDTypes.put(List.class.getName(),
+ new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX));
+ }
+
+ public QName getStdSdoType(String typename)
+ {
+ return (QName) simpleXSDTypes.get(typename);
+ }
+
+ public QName getComplexSchemaTypeName(String sdoURI, String sdoTypeName)
+ {
+ return (QName) complexXSDTypes.get(asQualifiedName(sdoURI, sdoTypeName));
+ }
+
+ public QName getComplexSchemaTypeName(JClass javaClass, ClassLoader cl) throws Exception
+ {
+ String namespace = Java2WSDLUtils.schemaNamespaceFromClassName(
+ javaClass.getQualifiedName(), cl).toString();
+ return (QName) complexXSDTypes.get(asQualifiedName(namespace, javaClass.getSimpleName()));
+ }
+
+ public boolean isSimpleType(String typeName)
+ {
+ Iterator keys = simpleXSDTypes.keySet().iterator();
+ while (keys.hasNext()) {
+ String s = (String) keys.next();
+ if (s.equals(typeName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public QName getSimpleSchemaTypeName(String typename)
+ {
+ return (QName) simpleXSDTypes.get(typename);
+ }
+
+ public void addSimpleSchemaType(String typeName, QName schemaType)
+ {
+ simpleXSDTypes.put(typeName, schemaType);
+ }
+
+
+ public void addComplexSchemaType(String namespaceURI, String name, QName schemaType)
+ {
+ complexXSDTypes.put(asQualifiedName(namespaceURI, name), schemaType);
+ }
+
+
+ public QName getQNamefortheType(String namespaceURI, String typeName)
+ {
+ if ( XML_SCHEMA_URI.equals(namespaceURI))
+ {
+ return getSimpleSchemaTypeName(typeName);
+ }
+ else
+ {
+ return getComplexSchemaTypeName(namespaceURI, typeName);
+ }
+ }
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java
new file mode 100644
index 0000000000..a742e8913d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java
@@ -0,0 +1,373 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaForm;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+import org.apache.ws.java2wsdl.SchemaGenerator;
+import org.apache.ws.java2wsdl.bytecode.MethodTable;
+import org.codehaus.jam.JClass;
+import org.codehaus.jam.JMethod;
+import org.codehaus.jam.JParameter;
+import org.codehaus.jam.JamClassIterator;
+import org.codehaus.jam.JamService;
+import org.codehaus.jam.JamServiceFactory;
+import org.codehaus.jam.JamServiceParams;
+
+public class TuscanyWSDLTypesGenerator implements TuscanyJava2WSDLConstants {
+ public static final String NAME_SPACE_PREFIX = "stn_";
+
+ public static final String PERIOD_SEPARATOR = ".";
+
+ private static int prefixCount = 1;
+
+ protected GenerationParameters generationParams;
+
+ protected Hashtable targetNamespacePrefixMap = new Hashtable();
+
+ protected Hashtable schemaMap = new Hashtable();
+
+ protected XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
+
+ private TuscanyTypeTable typeTable = new TuscanyTypeTable();
+
+ protected SchemaBuilder schemaBuilder = null;
+
+ protected Map schemaLocationMap = null;
+
+ private static final Log log = LogFactory.getLog(SchemaGenerator.class);
+
+ // to keep loadded method using JAM
+ private JMethod methods[];
+
+ //to store byte code method using Axis 1.x codes
+ private MethodTable methodTable;
+
+ private Class clazz;
+
+ private ArrayList excludeMethods = new ArrayList();
+
+ public TuscanyWSDLTypesGenerator(GenerationParameters genParams) throws Exception {
+ DataObjectUtil.initRuntime();
+ this.generationParams = genParams;
+
+ clazz = Class.forName(generationParams.getSourceClassName(),
+ true,
+ generationParams.getClassLoader());
+ methodTable = new MethodTable(clazz);
+
+ initializeSchemaMap(generationParams.getSchemaTargetNamespace(),
+ generationParams.getSchemaTargetNamespacePrefix());
+ schemaBuilder = new SchemaBuilder(xmlSchemaCollection,
+ schemaMap,
+ targetNamespacePrefixMap,
+ typeTable,
+ generationParams.getAttrFormDefault(),
+ generationParams.getElementFormDefault(),
+ generationParams.getSchemaLocationMap(),
+ generationParams.getClassLoader());
+ }
+
+ /**
+ * Generates schema for all the parameters in method. First generates schema
+ * for all different parameter type and later refers to them.
+ *
+ * @return Returns XmlSchema.
+ * @throws Exception
+ */
+ public Collection buildWSDLTypes() throws Exception {
+ JamServiceFactory factory = JamServiceFactory.getInstance();
+ JamServiceParams jam_service_parms = factory.createServiceParams();
+ //setting the classLoder
+// jam_service_parms.setParentClassLoader(factory.createJamClassLoader(classLoader));
+ //it can posible to add the classLoader as well
+ jam_service_parms.addClassLoader(generationParams.getClassLoader());
+ jam_service_parms.includeClass(generationParams.getSourceClassName());
+
+ for ( int count = 0 ; count < generationParams.getExtraClasses().size() ; ++count )
+ {
+ jam_service_parms.includeClass((String)generationParams.getExtraClasses().get(count));
+ }
+
+ JamService service = factory.createService(jam_service_parms);
+ QName extraSchemaTypeName = null;
+ JamClassIterator jClassIter = service.getClasses();
+ //all most all the time the ittr will have only one class in it
+ while (jClassIter.hasNext()) {
+ JClass jclass = (JClass) jClassIter.next();
+ // serviceName = jclass.getSimpleName();
+ //todo in the future , when we support annotation we can use this
+ //JAnnotation[] annotations = jclass.getAnnotations();
+
+ if ( jclass.getQualifiedName().equals(generationParams.getSourceClassName()) )
+ {
+ /**
+ * Schema genertaion done in two stage 1. Load all the methods and
+ * create type for methods parameters (if the parameters are Bean
+ * then it will create Complex types for those , and if the
+ * parameters are simple type which decribe in SimpleTypeTable
+ * nothing will happen) 2. In the next stage for all the methods
+ * messages and port types will be creteated
+ */
+ methods = jclass.getDeclaredMethods();
+ //short the elements in the array
+ Arrays.sort(methods);
+
+ // since we do not support overload
+ HashMap uniqueMethods = new HashMap();
+ XmlSchemaComplexType methodSchemaType;
+ XmlSchemaSequence sequence = null;
+
+ for (int i = 0; i < methods.length; i++) {
+ JMethod jMethod = methods[i];
+
+ String methodName = methods[i].getSimpleName();
+ // no need to think abt this method , since that is system
+ // config method
+ if (excludeMethods.contains(jMethod.getSimpleName())) {
+ continue;
+ }
+
+ if (uniqueMethods.get(jMethod.getSimpleName()) != null) {
+ throw new Exception(
+ " Sorry we don't support methods overloading !!!! ");
+ }
+
+ if (!jMethod.isPublic()) {
+ // no need to generate Schema for non public methods
+ continue;
+ }
+ uniqueMethods.put(jMethod.getSimpleName(), jMethod);
+ //create the schema type for the method wrapper
+
+ uniqueMethods.put(jMethod.getSimpleName(), jMethod);
+ JParameter [] paras = jMethod.getParameters();
+ String parameterNames [] = null;
+ if (paras.length > 0) {
+ parameterNames = methodTable.getParameterNames(methodName);
+ sequence = new XmlSchemaSequence();
+
+ methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName());
+ methodSchemaType.setParticle(sequence);
+ }
+
+ for (int j = 0; j < paras.length; j++) {
+ JParameter methodParameter = paras[j];
+ JClass paraType = methodParameter.getType();
+ generateSchemaForType(sequence, paraType,
+ (parameterNames != null && parameterNames[j] != null) ? parameterNames[j] : methodParameter.getSimpleName());
+ }
+ // for its return type
+ JClass returnType = jMethod.getReturnType();
+
+ if (!returnType.isVoidType()) {
+ methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName() + RESPONSE);
+ sequence = new XmlSchemaSequence();
+ methodSchemaType.setParticle(sequence);
+ generateSchemaForType(sequence, returnType, "return");
+ }
+ }
+ }
+ else
+ {
+ //generate the schema type for extra classes
+ extraSchemaTypeName = typeTable.getSimpleSchemaTypeName(jclass.getQualifiedName());
+ if (extraSchemaTypeName == null)
+ {
+ extraSchemaTypeName = schemaBuilder.generateSchema(jclass);
+ }
+ }
+ }
+ return schemaMap.values();
+ }
+
+ private QName generateSchemaForType(XmlSchemaSequence sequence, JClass type, String partName) throws Exception {
+ boolean isArrayType = type.isArrayType();
+ if (isArrayType) {
+ type = type.getArrayComponentType();
+ }
+
+ String classTypeName = type.getQualifiedName();
+
+ QName schemaTypeName = typeTable.getSimpleSchemaTypeName(classTypeName);
+ if (schemaTypeName == null) {
+ schemaTypeName = schemaBuilder.generateSchema(type);
+ addContentToMethodSchemaType(sequence,
+ schemaTypeName,
+ partName,
+ type.isArrayType());
+ addImportORInclude((XmlSchema) schemaMap.get(generationParams.getSchemaTargetNamespace()),
+ schemaTypeName);
+
+ } else {
+ addContentToMethodSchemaType(sequence,
+ schemaTypeName,
+ partName,
+ type.isArrayType());
+ }
+
+ return schemaTypeName;
+ }
+
+ private void addContentToMethodSchemaType(XmlSchemaSequence sequence,
+ QName schemaTypeName,
+ String paraName,
+ boolean isArray) {
+ XmlSchemaElement elt1 = new XmlSchemaElement();
+ elt1.setName(paraName);
+ elt1.setSchemaTypeName(schemaTypeName);
+ sequence.getItems().add(elt1);
+
+ if (isArray) {
+ elt1.setMaxOccurs(Long.MAX_VALUE);
+ elt1.setMinOccurs(0);
+ }
+ }
+
+ private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) throws Exception {
+ XmlSchema xmlSchema = (XmlSchema) schemaMap.get(generationParams.getSchemaTargetNamespace());
+ QName elementName = new QName(generationParams.getSchemaTargetNamespace(),
+ localPartName,
+ generationParams.getSchemaTargetNamespacePrefix());
+ XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
+
+ XmlSchemaElement globalElement = new XmlSchemaElement();
+ globalElement.setSchemaType(complexType);
+ globalElement.setName(formGlobalElementName(localPartName));
+ globalElement.setQName(elementName);
+
+ xmlSchema.getItems().add(globalElement);
+ xmlSchema.getElements().add(elementName,
+ globalElement);
+
+ typeTable.addComplexSchemaType(generationParams.getSchemaTargetNamespace(),
+ globalElement.getName(),
+ elementName);
+
+ return complexType;
+ }
+
+ private String formGlobalElementName(String typeName) {
+ String firstChar = typeName.substring(0,
+ 1);
+ return typeName.replaceFirst(firstChar,
+ firstChar.toLowerCase());
+ }
+
+ public TuscanyTypeTable getTypeTable() {
+ return typeTable;
+ }
+
+ public JMethod[] getMethods() {
+ return methods;
+ }
+
+ private String generatePrefix() {
+ return NAME_SPACE_PREFIX + prefixCount++;
+ }
+
+ public void setExcludeMethods(ArrayList excludeMethods) {
+ this.excludeMethods = excludeMethods;
+ }
+
+ private void initializeSchemaMap(String targetNamespace, String targetNamespacePrefix) {
+ XmlSchema xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
+ xmlSchema.setAttributeFormDefault(getAttrFormDefaultSetting());
+ xmlSchema.setElementFormDefault(getElementFormDefaultSetting());
+
+ targetNamespacePrefixMap.put(targetNamespace,
+ targetNamespacePrefix);
+ schemaMap.put(targetNamespace,
+ xmlSchema);
+
+ NamespaceMap prefixmap = new NamespaceMap();
+ prefixmap.put(TuscanyTypeTable.XS_URI_PREFIX,
+ TuscanyTypeTable.XML_SCHEMA_URI);
+ prefixmap.put(targetNamespacePrefix,
+ targetNamespace);
+ xmlSchema.setNamespaceContext(prefixmap);
+ }
+
+
+ private void addImportORInclude(XmlSchema xmlSchema, QName schemaTypeName) {
+ //decide whether there must be an import or an include
+ if (xmlSchema.getTargetNamespace().equals(schemaTypeName.getNamespaceURI())) {
+ XmlSchema containingSchema = (XmlSchema) schemaMap.get(schemaTypeName.getNamespaceURI());
+ //if the type is not defined in the Schema then include
+ if (containingSchema.getTypeByName(schemaTypeName) == null) {
+ String schemaLocation = null;
+ if ((schemaLocation = (String) schemaLocationMap.get(schemaTypeName.getNamespaceURI())) != null) {
+ schemaLocation = DEFAULT_SCHEMA_LOCATION;
+ }
+
+ XmlSchemaInclude includeElement = new XmlSchemaInclude();
+ includeElement.setSchemaLocation(schemaLocation);
+
+ if (!xmlSchema.getIncludes().contains(includeElement)) {
+ xmlSchema.getIncludes().add(includeElement);
+ }
+ }
+ } else {
+ if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values()
+ .contains(schemaTypeName.getNamespaceURI())) {
+ XmlSchemaImport importElement = new XmlSchemaImport();
+ importElement.setNamespace(schemaTypeName.getNamespaceURI());
+ xmlSchema.getItems().add(importElement);
+ ((NamespaceMap) xmlSchema.getNamespaceContext()).put(generatePrefix(),
+ schemaTypeName.getNamespaceURI());
+ }
+ }
+ }
+
+ private XmlSchemaForm getAttrFormDefaultSetting() {
+ if (FORM_DEFAULT_UNQUALIFIED.equals(generationParams.getAttrFormDefault())) {
+ return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ } else {
+ return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ }
+ }
+
+ private XmlSchemaForm getElementFormDefaultSetting() {
+ if (FORM_DEFAULT_UNQUALIFIED.equals(generationParams.getElementFormDefault())) {
+ return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ } else {
+ return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenEvent.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenEvent.java
new file mode 100644
index 0000000000..26b3d092de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.util.EventObject;
+
+public class WSDLGenEvent extends EventObject {
+ private int generationPhase = WSDLGenListener.UNKNOWN;
+
+ public WSDLGenEvent(Object source, int genPhase) {
+ super(source);
+ this.generationPhase = genPhase;
+ }
+
+ public int getGenerationPhase() {
+ return generationPhase;
+ }
+
+ public void setGenerationPhase(int generationPhase) {
+ this.generationPhase = generationPhase;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenListener.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenListener.java
new file mode 100644
index 0000000000..788d162f34
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/WSDLGenListener.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+public interface WSDLGenListener {
+ public static int UNKNOWN = 0;
+
+ public static int INPUT_ARGS_PARSING = 1;
+
+ public static int INPUT_ARGS_VALIDATION = 2;
+
+ public static int WSDL_MODEL_CREATION = 3;
+
+ public static int WSDL_MODEL_WRITING = 4;
+
+ public static String[] phaseAsString = { "Unknown",
+ "Input Arguments Parsing", "Input Arguments Validation",
+ "WSDL Model Creation", "WSDL Model Writing" };
+
+ public void WSDLGenPhaseStarted(WSDLGenEvent event);
+
+ public void WSDLGenPhaseCompleted(WSDLGenEvent event);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/util/XMLNameUtil.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/util/XMLNameUtil.java
new file mode 100644
index 0000000000..b30b8cd62b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/java2wsdl/util/XMLNameUtil.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class XMLNameUtil {
+
+ /**
+ * Returns a valid Java name from an XML Name.
+ *
+ * @param name
+ * @param isUpperCase
+ * @return a valid Java name from an XML Name
+ */
+ public static String getJavaNameFromXMLName(String name, boolean isUpperCase) {
+ List<String> parsedName = parseName(name, '_');
+ StringBuilder result = new StringBuilder(64 * parsedName.size());
+ for (String nameComponent: parsedName) {
+ if (nameComponent.length() > 0) {
+ if (result.length() > 0 || isUpperCase) {
+ result.append(Character.toUpperCase(nameComponent.charAt(0)));
+ result.append(nameComponent.substring(1));
+ } else {
+ result.append(nameComponent);
+ }
+ }
+ }
+
+ if (result.length() == 0) {
+ return "_";
+ }
+ if (Character.isJavaIdentifierStart(result.charAt(0))) {
+ return isUpperCase ? result.toString() : decapitalizeName(result.toString());
+ }
+ return "_" + result;
+ }
+
+ /**
+ * Decapitalize a name.
+ * @param name
+ * @return a decapitalized name
+ */
+ public static String decapitalizeName(String name) {
+ if (name.length() == 0) {
+ return name;
+ } else {
+ String lowerName = name.toLowerCase();
+ int i;
+ for (i = 0; i < name.length(); i++) {
+ if (name.charAt(i) == lowerName.charAt(i)) {
+ break;
+ }
+ }
+ if (i > 1 && i < name.length()) {
+ --i;
+ }
+ return name.substring(0, i).toLowerCase() + name.substring(i);
+ }
+ }
+
+ /**
+ * Parse the given name.
+ *
+ * @param sourceName
+ * @param separator
+ * @return some stuff parsed from the name
+ */
+ private static List<String> parseName(String sourceName, char separator) {
+ List<String> result = new ArrayList<String>();
+ if (sourceName != null) {
+ StringBuilder currentWord = new StringBuilder(64);
+ boolean lastIsLower = false;
+ int index;
+ int length;
+ for (index = 0, length = sourceName.length(); index < length; ++index) {
+ char curChar = sourceName.charAt(index);
+ if (!Character.isJavaIdentifierPart(curChar)) {
+ curChar = separator;
+ }
+ if (Character.isUpperCase(curChar)
+ || (!lastIsLower && Character.isDigit(curChar))
+ || curChar == separator) {
+
+ if (lastIsLower && currentWord.length() > 1
+ || curChar == separator && currentWord.length() > 0) {
+ result.add(currentWord.toString());
+ currentWord = new StringBuilder(64);
+ }
+ lastIsLower = false;
+ } else {
+ if (!lastIsLower) {
+ int currentWordLength = currentWord.length();
+ if (currentWordLength > 1) {
+ char lastChar = currentWord.charAt(--currentWordLength);
+ currentWord.setLength(currentWordLength);
+ result.add(currentWord.toString());
+ currentWord = new StringBuilder(64);
+ currentWord.append(lastChar);
+ }
+ }
+ lastIsLower = true;
+ }
+
+ if (curChar != separator) {
+ currentWord.append(curChar);
+ }
+ }
+
+ result.add(currentWord.toString());
+ }
+ return result;
+ }
+
+ /**
+ * Return an EPackage name for the given namespace.
+ *
+ * @param namespace
+ * @return an EPackage name for the given namespace
+ */
+ public static String getPackageNameFromNamespace(String namespace) {
+ return org.apache.tuscany.sdo.helper.SDOXSDEcoreBuilder.getDefaultPackageName(namespace);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceEmitter.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceEmitter.java
new file mode 100644
index 0000000000..22383e99db
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceEmitter.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.util.FileWriter;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.emitter.JavaEmitter;
+import org.apache.axis2.wsdl.codegen.writer.InterfaceWriter;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import static org.apache.tuscany.tools.java2wsdl.util.XMLNameUtil.getJavaNameFromXMLName;
+
+/**
+ * Overrides the Axis2 JavaEmitter to generate unwrapped methods.
+ */
+public class JavaInterfaceEmitter extends JavaEmitter {
+
+ private CodeGenConfiguration codegenConfiguration;
+ private TypeMapper typeMapper;
+
+ public void setCodeGenConfiguration(CodeGenConfiguration configuration) {
+ super.setCodeGenConfiguration(configuration);
+ codegenConfiguration=configuration;
+ }
+
+ public void setMapper(TypeMapper typeMapper) {
+ super.setMapper(typeMapper);
+ this.typeMapper = typeMapper;
+ }
+
+ private List getParameterElementList(Document doc, AxisMessage message, boolean wrapped) {
+ List parameterElementList = new ArrayList();
+
+ if (message != null && message.getElementQName()!=null) {
+
+ SDODataBindingTypeMappingEntry typeMappingEntry =
+ (SDODataBindingTypeMappingEntry)this.typeMapper.getTypeMappingObject(message.getElementQName());
+ List typeMappings;
+ if (wrapped) {
+ typeMappings = (List)typeMappingEntry.getPropertyClassNames();
+ } else {
+ typeMappings = new ArrayList();
+ typeMappings.add(typeMappingEntry.getClassName());
+ }
+
+ for (int i=0; i<typeMappings.size(); i++) {
+ Element param = doc.createElement("param");
+ parameterElementList.add(param);
+
+ String typeMapping = (String)typeMappings.get(i);
+
+ addAttribute(doc, "name", this.typeMapper.getParameterName(message.getElementQName()), param);
+ addAttribute(doc, "type", (typeMapping == null)
+ ? ""
+ : typeMapping, param);
+
+ // add an extra attribute to say whether the type mapping is the default
+ // if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMapping)) {
+ if (typeMapper.getDefaultMappingName().equals(typeMapping)) {
+
+ addAttribute(doc, "default", "yes", param);
+ }
+
+ addAttribute(doc, "value", null, param);
+
+ // add this as a body parameter
+ addAttribute(doc, "location", "body", param);
+
+ }
+ }
+
+ return parameterElementList;
+ }
+
+ public List getParameterElementList(Document doc, List parameters, String location) {
+ List parameterElementList = new ArrayList();
+
+ if ((parameters != null) && !parameters.isEmpty()) {
+ int count = parameters.size();
+
+ for (int i = 0; i < count; i++) {
+ Element param = doc.createElement("param");
+ QName name = (QName) parameters.get(i);
+
+ addAttribute(doc, "name", this.typeMapper.getParameterName(name), param);
+
+ String typeMapping = this.typeMapper.getTypeMappingName(name);
+ String typeMappingStr = (typeMapping == null)
+ ? ""
+ : typeMapping;
+
+ addAttribute(doc, "type", typeMappingStr, param);
+ addAttribute(doc, "location", location, param);
+ parameterElementList.add(param);
+ }
+ }
+
+ return parameterElementList;
+ }
+
+ protected boolean isWrapped(AxisOperation operation) {
+ boolean wrapped = false;
+
+ if (isInputPresentForMEP(operation.getMessageExchangePattern())) {
+ QName qname = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getElementQName();
+ if (qname != null && qname.getLocalPart().equals(operation.getName().getLocalPart())) {
+
+ SDODataBindingTypeMappingEntry typeMappingEntry =
+ (SDODataBindingTypeMappingEntry)this.typeMapper.getTypeMappingObject(qname);
+ if (typeMappingEntry.isAnonymous()) {
+ wrapped = true;
+ }
+ }
+ }
+
+ return wrapped;
+ }
+
+ private boolean isInputPresentForMEP(String MEP) {
+
+
+ return
+ WSDLConstants.WSDL20_2004Constants.MEP_URI_IN_ONLY.equals(MEP) ||
+ WSDLConstants.WSDL20_2004Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP) ||
+ WSDLConstants.WSDL20_2004Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP) ||
+ WSDLConstants.WSDL20_2004Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP) ||
+ WSDLConstants.WSDL20_2004Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP) ||
+ WSDLConstants.WSDL20_2004Constants.MEP_URI_IN_OUT.equals(MEP) ||
+
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY.equals(MEP) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT.equals(MEP) ||
+
+ WSDLConstants.WSDL_MESSAGE_DIRECTION_IN.endsWith(MEP);
+
+
+
+
+ }
+
+ protected Element getInputElement(Document doc, AxisOperation operation, List headerParameterQNameList) {
+ return getElement(doc, "input", operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE), isWrapped(operation), headerParameterQNameList);
+ }
+
+ protected Element getOutputElement(Document doc, AxisOperation operation, List headerParameterQNameList) {
+ return getElement(doc, "output", operation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE), isWrapped(operation), headerParameterQNameList);
+ }
+
+ protected Element getElement(Document doc, String elementName, AxisMessage message, boolean wrapped, List headerParameterQNameList) {
+ Element element = doc.createElement(elementName);
+
+ List parameterElementList = getParameterElementList(doc, message, wrapped);
+ for (int i = 0; i < parameterElementList.size(); i++) {
+ element.appendChild((Element) parameterElementList.get(i));
+ }
+
+ List outputElementList = getParameterElementList(doc, headerParameterQNameList, "header");
+
+ for (int i = 0; i < outputElementList.size(); i++) {
+ element.appendChild((Element) outputElementList.get(i));
+ }
+
+ return element;
+ }
+
+ protected void writeInterface(boolean writeDatabinders) throws Exception {
+ Document interfaceModel = createDOMDocumentForInterface(writeDatabinders);
+ if (!codegenConfiguration.getOutputLocation().exists()) {
+ codegenConfiguration.getOutputLocation().mkdirs();
+ }
+ InterfaceWriter interfaceWriter = new RemotableInterfaceWritter(this.codegenConfiguration
+ .getOutputLocation(), this.codegenConfiguration.getOutputLanguage());
+
+ String packageName = interfaceModel.getDocumentElement().getAttribute("package");
+ String className = interfaceModel.getDocumentElement().getAttribute("name");
+
+ System.out.println(">> Generating Java class " + packageName + "." + className);
+ File outputFile = FileWriter.createClassFile(this.codegenConfiguration.getOutputLocation(),
+ packageName, className, ".java");
+ if (outputFile.exists()) {
+ outputFile.delete();
+ }
+
+ writeClass(interfaceModel, interfaceWriter);
+ }
+
+ protected String makeJavaClassName(String word) {
+ //return XMLNameUtil.getJavaNameFromXMLName(word, true);
+ return getJavaNameFromXMLName(word, true);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java
new file mode 100644
index 0000000000..b68277566a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import static org.apache.tuscany.tools.java2wsdl.util.XMLNameUtil.getPackageNameFromNamespace;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.util.XMLUtils;
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.extension.CodeGenExtension;
+import org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension;
+import org.apache.axis2.wsdl.codegen.extension.PackageFinder;
+import org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension;
+import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class JavaInterfaceGenerator {
+
+ private List codegenExtensions = new ArrayList();
+ private List<CodeGenConfiguration> codegenConfigurations= new LinkedList<CodeGenConfiguration>();
+
+
+
+
+ public JavaInterfaceGenerator(String uri, String ports[], String outputLocation, String packageName,
+ Map<QName, SDODataBindingTypeMappingEntry> typeMapping) throws CodeGenerationException {
+
+ Definition definition;
+ try {
+ definition = readWSDL(uri);
+ } catch (WSDLException e) {
+ throw new CodeGenerationException(e);
+ }
+
+ HashSet interestedPorts= ports == null ? null : new HashSet(Arrays.asList(ports));
+
+ // Service service=(Service)definition.getServices().values().().next();
+
+ HashSet<QName> donePortTypes= new HashSet<QName>();
+
+ for (Iterator sIter = definition.getServices().values().iterator(); sIter.hasNext(); ) {
+ Service service = (Service) sIter.next();
+
+ QName serviceQname = service.getQName();
+ for (Iterator pIter= service.getPorts().values().iterator(); pIter.hasNext(); ) {
+ Port port= (Port) pIter.next();
+ if(interestedPorts != null && ! interestedPorts.contains(port.getName())) continue;//not iterested.
+ PortType portType= getPortType(port);
+ if(null == portType) continue; // not connected.
+ QName pQName= portType.getQName();
+ if(donePortTypes.contains(pQName)) continue; //allready did it.
+ donePortTypes.add(pQName);
+
+ if (packageName == null) {
+
+ packageName = getPackageNameFromNamespace(definition.getTargetNamespace());
+ }
+ JavaTypeMapper typeMapper = new JavaTypeMapper();
+ for (Map.Entry<QName, SDODataBindingTypeMappingEntry> e : typeMapping.entrySet()) {
+ typeMapper.addTypeMappingObject(e.getKey(), e.getValue());
+ }
+ AxisService axisService;
+ try {
+ axisService = new WSDL11ToAxisServiceBuilder(definition, serviceQname, port.getName()).populateService();
+ } catch (AxisFault e) {
+ throw new CodeGenerationException(e);
+ }
+ axisService.setName(port.getBinding().getPortType().getQName().getLocalPart());
+ CodeGenConfiguration codegenConfiguration = new CodeGenConfiguration(Collections.EMPTY_MAP);
+ codegenConfigurations.add(codegenConfiguration);
+ codegenConfiguration.setAxisService(axisService);
+ codegenConfiguration.setAdvancedCodeGenEnabled(false);
+ codegenConfiguration.setAsyncOn(false);
+ codegenConfiguration.setDatabindingType("sdo");
+ codegenConfiguration.setGenerateAll(true);
+ codegenConfiguration.setGenerateDeployementDescriptor(false);
+ codegenConfiguration.setOutputLanguage("java");
+ codegenConfiguration.setOutputLocation(new File(outputLocation));
+ codegenConfiguration.setPackageName(packageName);
+ codegenConfiguration.setPackClasses(false);
+ codegenConfiguration.setPolicyMap(Collections.EMPTY_MAP);
+ codegenConfiguration.setPortName(port.getName());
+ codegenConfiguration.setServerSide(false);
+ codegenConfiguration.setServiceName(service.getQName().getLocalPart());
+ codegenConfiguration.setSyncOn(true);
+ codegenConfiguration.setTypeMapper(typeMapper);
+ codegenConfiguration.setWriteMessageReceiver(false);
+ codegenConfiguration.setWriteTestCase(false);
+ addExtension(new WSDLValidatorExtension(), codegenConfiguration);
+ addExtension(new PackageFinder(), codegenConfiguration);
+ addExtension(new SDODataBindingCodegenExtension(typeMapper), codegenConfiguration);
+ addExtension(new DefaultDatabindingExtension(), codegenConfiguration);
+ }
+ }
+ }
+
+
+ private PortType getPortType(Port port) {
+ Binding binding = port.getBinding();
+ if(null != binding){
+ return binding.getPortType();
+ }
+ return null;
+
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private void addExtension(CodeGenExtension ext, CodeGenConfiguration codegenConfiguration) {
+ //ext.init(codegenConfiguration);
+ codegenExtensions.add(new Object[]{ext, codegenConfiguration});
+ }
+
+ public void generate() throws CodeGenerationException {
+ try {
+ for (int i = 0; i < codegenExtensions.size(); i++) {
+ //CodeGenExtension
+ Object[] pair = (Object[])codegenExtensions.get(i);
+
+ CodeGenExtension cge= (CodeGenExtension) pair[0];
+ CodeGenConfiguration cgf= (CodeGenConfiguration)pair[1];
+
+ cge.engage(cgf);
+
+ }
+
+ for(CodeGenConfiguration codegenConfiguration : codegenConfigurations){
+ JavaInterfaceEmitter emitter = new JavaInterfaceEmitter();
+ emitter.setCodeGenConfiguration(codegenConfiguration);
+ emitter.setMapper(codegenConfiguration.getTypeMapper());
+
+ emitter.writeInterface(false);
+ }
+
+ } catch (Exception e) {
+ throw new CodeGenerationException(e);
+ }
+ }
+
+ /**
+ * Read the WSDL file
+ * @param uri
+ * @return
+ * @throws WSDLException
+ */
+ private Definition readWSDL(String uri) throws WSDLException {
+
+ WSDLReader reader =
+ WSDLFactory.newInstance().newWSDLReader();
+ reader.setFeature("javax.wsdl.importDocuments", true);
+
+ File file = new File(uri);
+ String baseURI;
+
+ if (uri.startsWith("http://")){
+ baseURI = uri;
+ } else{
+ if(file.getParentFile() == null){
+ try {
+ baseURI = new File(".").getCanonicalFile().toURI().toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ baseURI = file.getParentFile().toURI().toString();
+ }
+ }
+
+ Document doc;
+ try {
+ doc = XMLUtils.newDocument(uri);
+ } catch (ParserConfigurationException e) {
+ throw new WSDLException(WSDLException.PARSER_ERROR,
+ "Parser Configuration Error",
+ e);
+ } catch (SAXException e) {
+ throw new WSDLException(WSDLException.PARSER_ERROR,
+ "Parser SAX Error",
+ e);
+
+ } catch (IOException e) {
+ throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
+ }
+
+ return reader.readWSDL(baseURI, doc);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/RemotableInterfaceWritter.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/RemotableInterfaceWritter.java
new file mode 100644
index 0000000000..cb413bca50
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/RemotableInterfaceWritter.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import java.io.File;
+
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.writer.InterfaceWriter;
+
+/**
+ * @author lresende
+ */
+public class RemotableInterfaceWritter extends InterfaceWriter {
+ private static final String REMOTABLE_INTERFACE_TEMPLATE="/RemotableInterfaceTemplate.xsl";
+
+ public RemotableInterfaceWritter(String outputFileLocation) {
+ super(outputFileLocation);
+ }
+
+ public RemotableInterfaceWritter(File outputFileLocation, String language) {
+ super(outputFileLocation, language);
+ }
+
+ /**
+ * Loads the template.
+ */
+ @Override
+ public void loadTemplate() throws CodeGenerationException {
+ // the default behavior for the class writers is to use the property map from the languge specific types
+ // The properties are arranged in the following order
+ // <lang-name>.* .template=<write-class>,<template-name>
+
+ //overrida original behaviour to always load the template we specified
+ this.xsltStream = this.getClass().getResourceAsStream(REMOTABLE_INTERFACE_TEMPLATE);
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java
new file mode 100644
index 0000000000..075959f985
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.extension.AbstractDBProcessingExtension;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+
+/**
+ * SDO data binding codegen extension.
+ */
+public class SDODataBindingCodegenExtension extends AbstractDBProcessingExtension {
+
+ private TypeMapper typeMapper;
+
+ public SDODataBindingCodegenExtension(TypeMapper typeMapper) {
+ this.typeMapper=typeMapper;
+ }
+
+ protected boolean testFallThrough(String dbFrameworkName) {
+ return !dbFrameworkName.equals("sdo");
+ }
+
+// public void engage() {
+// if (testFallThrough(configuration.getDatabindingType())) {
+// return;
+// }
+//
+// // Set the type mapper into the config
+// configuration.setTypeMapper(typeMapper);
+//
+// }
+
+ public void engage(CodeGenConfiguration configuration) throws CodeGenerationException {
+ // TODO Auto-generated method stub
+ if (testFallThrough(configuration.getDatabindingType())) {
+ return;
+ }
+
+ // Set the type mapper into the config
+ configuration.setTypeMapper(typeMapper);
+
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingTypeMappingEntry.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingTypeMappingEntry.java
new file mode 100644
index 0000000000..2d81ef12bf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingTypeMappingEntry.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import java.util.List;
+
+/**
+ * This represents a type mapping entry, used by the JavaInterfaceEmitter to generate
+ * method signatures.
+ */
+public class SDODataBindingTypeMappingEntry {
+
+ private final boolean anonymous;
+ private final List<String> propertyClassNames;
+ private final String className;
+
+ public SDODataBindingTypeMappingEntry(String className, boolean anonymous, List<String> propertyClassNames) {
+ this.className = className;
+ this.anonymous = anonymous;
+ this.propertyClassNames = propertyClassNames;
+ }
+
+ public boolean isAnonymous() {
+ return anonymous;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public List<String> getPropertyClassNames() {
+ return propertyClassNames;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java
new file mode 100644
index 0000000000..3fe87db153
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sdo.helper.XSDHelperImpl;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+
+import commonj.sdo.helper.XSDHelper;
+
+public class WSDL2JavaGenerator {
+
+ /**
+ * Generate Java interfaces from WSDL Usage arguments: [ -targetDirectory
+ * <target-root-directory> ] [ -javaPackage <java-package-name> ]
+ * <wsdl-file> For example: generate somedir/somefile.wsdl Basic options:
+ * -targetDirectory Generates the Java source code in the specified
+ * directory. By default, the code is generated in the same directory as the
+ * input wsdl file. -javaPackage Overrides the Java package for the
+ * generated classes. By default the package name is derived from the
+ * targetNamespace of the WSDL definition being generated. For example, if
+ * the targetNamespace is "http://www.example.com/simple", the default
+ * package will be "com.example.simple".
+ */
+ public static void main(String args[]) {
+ if (args.length == 0) {
+ printUsage();
+ return;
+ }
+
+ String portName = null;
+ String targetDirectory = null;
+ String wsdlJavaPackage = null;
+ String xsdJavaPackage = null;
+
+ int index = 0;
+ for (; index < args.length && args[index].startsWith("-"); ++index) {
+ if (args[index].equalsIgnoreCase("-port")) {
+ portName = args[++index];
+ } else if (args[index].equalsIgnoreCase("-targetDirectory")) {
+ targetDirectory = args[++index];
+ } else if (args[index].equalsIgnoreCase("-javaPackage")) {
+ wsdlJavaPackage = args[++index];
+ }
+ // else if (...)
+ else {
+ printUsage();
+ return;
+ }
+ }
+
+ String wsdlFileName = args[index];
+ if (wsdlFileName == null || targetDirectory == null) {
+ printUsage();
+ return;
+ }
+
+ generateFromWSDL(wsdlFileName, portName!=null? new String[]{portName}:null, targetDirectory, wsdlJavaPackage, xsdJavaPackage, 0);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void generateFromWSDL(String wsdlFileName, String targetDirectory,
+ String wsdlJavaPackage,
+ String xsdJavaPackage, int genOptions){
+ generateFromWSDL( wsdlFileName, null, targetDirectory,
+ wsdlJavaPackage,
+ xsdJavaPackage, genOptions);
+
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static void generateFromWSDL(String wsdlFileName, String[] ports,
+ String targetDirectory, String wsdlJavaPackage,
+ String xsdJavaPackage, int genOptions)
+ {
+
+ // Initialize the SDO runtime
+ DataObjectUtil.initRuntime();
+ EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
+ ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry);
+ XSDHelper xsdHelper = new XSDHelperImpl(extendedMetaData);
+
+ try {
+
+ // Load the WSDL file
+ File inputFile = new File(wsdlFileName).getAbsoluteFile();
+ InputStream inputStream = new FileInputStream(inputFile);
+
+ // Define SDO metadata
+ xsdHelper.define(inputStream, inputFile.toURI().toString());
+
+ if (targetDirectory == null) {
+ targetDirectory = new File(wsdlFileName).getCanonicalFile().getParent();
+ } else {
+ targetDirectory = new File(targetDirectory).getCanonicalPath();
+ }
+
+ // Populate the typeMapping table that will be given to the Axis2 WSDL2Java
+ Map<QName, SDODataBindingTypeMappingEntry> typeMapping =
+ new HashMap<QName, SDODataBindingTypeMappingEntry>();
+ if (!packageRegistry.values().isEmpty()) {
+ ResourceSet resourceSet = DataObjectUtil.createResourceSet();
+
+ // Populate list of GenPackages and a map of GenClasses keyed by EClass
+ List<GenPackage> genPackages = new ArrayList<GenPackage>();
+ Map<EClass, GenClass> genClasses = new HashMap<EClass, GenClass>();
+ for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();) {
+ EPackage currentEPackage = (EPackage)iter.next();
+ String currentBasePackage = extractBasePackageName(currentEPackage, xsdJavaPackage);
+ String currentPrefix = CodeGenUtil.capName(currentEPackage.getName());
+
+ GenPackage currentGenPackage = createGenPackage(currentEPackage, currentBasePackage,
+ currentPrefix, genOptions, resourceSet);
+ genPackages.add(currentGenPackage);
+ for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
+ genClasses.put(genClass.getEcoreClass(), genClass);
+ }
+
+ }
+
+ // Process all the SDO packages
+ // Populate the qname -> interfaceName typeMapping table
+ for (GenPackage currentGenPackage : genPackages) {
+ EPackage currentEPackage = currentGenPackage.getEcorePackage();
+
+ // Populate the type mappings for all the complex types
+ for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
+ QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
+ extendedMetaData.getName(genClass.getEcoreClass()));
+ String interfaceName = currentGenPackage.getInterfacePackageName() + '.'
+ + genClass.getInterfaceName();
+ SDODataBindingTypeMappingEntry typeMappingEntry =
+ new SDODataBindingTypeMappingEntry(interfaceName, false, null);
+ typeMapping.put(qname, typeMappingEntry);
+ }
+
+ // Process all the global XSD elements
+ EClass documentRoot = extendedMetaData.getDocumentRoot(currentEPackage);
+ if (documentRoot != null) {
+ for (EStructuralFeature element : (List<EStructuralFeature>)extendedMetaData
+ .getElements(documentRoot)) {
+ EClassifier elementType = element.getEType();
+
+ // Handle a complex type
+ if (elementType instanceof EClass) {
+ EClass eClass = (EClass)elementType;
+
+ GenClass genClass = genClasses.get(elementType);
+ QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
+ extendedMetaData.getName(element));
+ String interfaceName = genClass.getGenPackage().getInterfacePackageName()
+ + '.' + genClass.getInterfaceName();
+ boolean anonymous = extendedMetaData.isAnonymous(eClass);
+
+ // Build list of property class names
+ List<String> propertyClassNames=new ArrayList<String>();
+ for (EStructuralFeature feature : (List<EStructuralFeature>)eClass.getEStructuralFeatures()) {
+ EClassifier propertyType = feature.getEType();
+ if (propertyType instanceof EClass) {
+ GenClass propertyGenClass = genClasses.get(propertyType);
+ String propertyClassName = propertyGenClass.getGenPackage().getInterfacePackageName()
+ + '.' + propertyGenClass.getInterfaceName();
+ propertyClassNames.add(propertyClassName);
+ } else if (propertyType instanceof EClassifier) {
+ String propertyClassName = propertyType.getInstanceClass().getName();
+ propertyClassNames.add(propertyClassName);
+ }
+ }
+
+ SDODataBindingTypeMappingEntry typeMappingEntry =
+ new SDODataBindingTypeMappingEntry(interfaceName, anonymous, propertyClassNames);
+ typeMapping.put(qname, typeMappingEntry);
+
+ } else {
+
+ // Handle a simple type
+ QName qname = new QName(extendedMetaData.getNamespace(currentEPackage),
+ extendedMetaData.getName(element));
+ String className = elementType.getInstanceClass().getName();
+ SDODataBindingTypeMappingEntry typeMappingEntry =
+ new SDODataBindingTypeMappingEntry(className, false, null);
+ typeMapping.put(qname, typeMappingEntry);
+ }
+ }
+ }
+ }
+ }
+
+ try {
+ JavaInterfaceGenerator codeGenerator = new JavaInterfaceGenerator(wsdlFileName,
+ ports,
+ targetDirectory,
+ wsdlJavaPackage,
+ typeMapping);
+ codeGenerator.generate();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static GenPackage createGenPackage(EPackage ePackage, String basePackage, String prefix,
+ int genOptions, ResourceSet resourceSet) {
+ GenModel genModel = ecore2GenModel(ePackage, basePackage, prefix, genOptions);
+
+ URI ecoreURI = URI.createURI("file:///" + ePackage.getName() + ".ecore");
+ URI genModelURI = ecoreURI.trimFileExtension().appendFileExtension("genmodel");
+
+ Resource ecoreResource = resourceSet.createResource(ecoreURI);
+ ecoreResource.getContents().add(ePackage);
+
+ Resource genModelResource = resourceSet.createResource(genModelURI);
+ genModelResource.getContents().add(genModel);
+
+ return (GenPackage)genModel.getGenPackages().get(0);
+ }
+
+ public static GenModel ecore2GenModel(EPackage ePackage, String basePackage,
+ String prefix, int genOptions) {
+ GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
+ genModel.initialize(Collections.singleton(ePackage));
+
+ genModel.setRootExtendsInterface("");
+ genModel.setRootImplementsInterface("commonj.sdo.DataObject");
+ genModel.setRootExtendsClass("org.apache.tuscany.sdo.impl.DataObjectImpl");
+ genModel.setFeatureMapWrapperInterface("commonj.sdo.Sequence");
+ genModel.setFeatureMapWrapperInternalInterface("org.apache.tuscany.sdo.util.BasicSequence");
+ genModel.setFeatureMapWrapperClass("org.apache.tuscany.sdo.util.BasicSequence");
+ genModel.setSuppressEMFTypes(true);
+ genModel.setSuppressEMFMetaData(true);
+ genModel.setSuppressEMFModelTags(true);
+ genModel.setCanGenerate(true);
+ // FIXME workaround java.lang.NoClassDefFoundError:
+ // org/eclipse/jdt/core/jdom/IDOMNode with 02162006 build
+ genModel.setFacadeHelperClass("Hack");
+ genModel.setForceOverwrite(true);
+
+ GenPackage genPackage = (GenPackage)genModel.getGenPackages().get(0);
+
+ if (basePackage != null) {
+ genPackage.setBasePackage(basePackage);
+ }
+ if (prefix != null) {
+ genPackage.setPrefix(prefix);
+ }
+
+ return genModel;
+ }
+
+ public static String extractBasePackageName(EPackage ePackage, String javaPackage) {
+ String qualifiedName = javaPackage != null ? javaPackage : ePackage.getName();
+ String name = /* CodeGenUtil. */shortName(qualifiedName);
+ String baseName = qualifiedName.substring(0, qualifiedName.length() - name.length());
+ if (javaPackage != null || !name.equals(qualifiedName)) {
+ ePackage.setName(name);
+ }
+ return baseName != null ? /* CodeGenUtil. */safeQualifiedName(baseName) : null;
+ }
+
+ public static String shortName(String qualifiedName) {
+ int index = qualifiedName.lastIndexOf(".");
+ return index != -1 ? qualifiedName.substring(index + 1) : qualifiedName;
+ }
+
+ public static String safeQualifiedName(String qualifiedName) {
+ StringBuffer safeQualifiedName = new StringBuffer();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(qualifiedName, ".");
+ stringTokenizer.hasMoreTokens();) {
+ String name = stringTokenizer.nextToken();
+ safeQualifiedName.append(CodeGenUtil.safeName(name));
+ if (stringTokenizer.hasMoreTokens()) {
+ safeQualifiedName.append('.');
+ }
+ }
+ return safeQualifiedName.toString();
+ }
+
+ protected static void printDiagnostic(Diagnostic diagnostic, String indent) {
+ System.out.print(indent);
+ System.out.println(diagnostic.getMessage());
+ for (Iterator i = diagnostic.getChildren().iterator(); i.hasNext();) {
+ printDiagnostic((Diagnostic)i.next(), indent + " ");
+ }
+ }
+
+ protected static void printUsage() {
+ System.out.println("Usage arguments:");
+ System.out.println(" [ -targetDirectory <target-root-directory> ]");
+ System.out.println(" [ -javaPackage <java-package-name> ]");
+ System.out.println(" <wsdl-file>");
+ System.out.println("");
+ System.out.println("For example:");
+ System.out.println("");
+ System.out.println(" generate somedir/somefile.wsdl");
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..25d78feeac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,1277 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+APACHE TUSCANY SUBCOMPONENTS:
+
+The Apache Tuscany distribution includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+===============================================================================
+
+For the Eclipse Modeling Framework component and the Celtix binding:
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and
+are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program by such
+Contributor itself or anyone acting on such Contributor's behalf.
+Contributions do not include additions to the Program which: (i) are
+separate modules of software distributed in conjunction with the
+Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and
+object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor, if
+any, in source code and object code form. This patent license shall
+apply to the combination of the Contribution and the Program if, at
+the time the Contribution is added by the Contributor, such addition
+of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the
+licenses to its Contributions set forth herein, no assurances are
+provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow
+Recipient to distribute the Program, it is Recipient's responsibility
+to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental and
+consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are
+offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable
+manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the
+Program.
+
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a
+commercial product offering should do so in a manner which does not
+create potential liability for other Contributors. Therefore, if a
+Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend
+and indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the acts
+or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement.
+In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b)
+allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such
+claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable
+laws, damage to or loss of data, programs or equipment, and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+the Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of
+the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign
+the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions)
+may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives
+no rights or licenses to the intellectual property of any Contributor
+under this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+For the Rhino JavaScript container component:
+
+Mozilla Public License 1.1 (MPL 1.1)
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original Code,
+prior Modifications used by a Contributor, and the Modifications made by that
+particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+combination of the Original Code and Modifications, in each case including
+portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+accepted in the software development community for the electronic transfer of
+data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified as
+the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+extent possible, whether at the time of the initial grant or subsequently
+acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+substance or structure of either the Original Code or any previous
+Modifications. When Covered Code is released as a series of files, a
+Modification is:
+ A. Any addition to or deletion from the contents of a file
+containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+which is described in the Source Code notice required by Exhibit A as Original
+Code, and which, at the time of its release under this License is not already
+Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+hereafter acquired, including without limitation, method, process, and
+apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+making modifications to it, including all modules it contains, plus any
+associated interface definition files, scripts used to control compilation and
+installation of an Executable, or source code differential comparisons against
+either the Original Code or another well known, available Covered Code of the
+Contributor's choice. The Source Code can be in a compressed or archival form,
+provided the appropriate decompression or de-archiving software is widely
+available for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+exercising rights under, and complying with all of the terms of, this License
+or a future version of this License issued under Section 6.1. For legal
+entities, "You" includes any entity which controls, is controlled by, or is
+under common control with You. For purposes of this definition, "control"
+means (a) the power, direct or indirect, to cause the direction or management
+of such entity, whether by contract or otherwise, or (b) ownership of more
+than fifty percent (50%) of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+non-exclusive license, subject to third party intellectual property claims:
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Initial Developer to use, reproduce, modify, display,
+perform, sublicense and distribute the Original Code (or portions thereof)
+with or without Modifications, and/or as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or selling
+of Original Code, to make, have made, use, practice, sell, and offer for sale,
+and/or otherwise dispose of the Original Code (or portions thereof).
+ (c) the licenses granted in this Section 2.1(a) and
+(b) are effective on the date Initial Developer first distributes Original
+Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+granted: 1) for code that You delete from the Original Code; 2) separate from
+the Original Code; or 3) for infringements caused by: i) the modification of
+the Original Code or ii) the combination of the Original Code with other
+software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Contributor, to use, reproduce, modify, display,
+perform, sublicense and distribute the Modifications created by such
+Contributor (or portions thereof) either on an unmodified basis, with other
+Modifications, as Covered Code and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or selling
+of Modifications made by that Contributor either alone and/or in combination
+with its Contributor Version (or portions of such combination), to make, use,
+sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications
+made by that Contributor (or portions thereof); and 2) the combination of
+Modifications made by that Contributor with its Contributor Version (or
+portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+effective on the date Contributor first makes Commercial Use of the Covered
+Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+granted: 1) for any code that Contributor has deleted from the Contributor
+Version; 2) separate from the Contributor Version; 3) for infringements
+caused by: i) third party modifications of Contributor Version or ii) the
+combination of Modifications made by that Contributor with other software
+(except as part of the Contributor Version) or other devices; or 4) under
+Patent Claims infringed by Covered Code in the absence of Modifications made
+by that Contributor.
+
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+governed by the terms of this License, including without limitation Section
+2.2. The Source Code version of Covered Code may be distributed only under the
+terms of this License or a future version of this License released under
+Section 6.1, and You must include a copy of this License with every copy of
+the Source Code You distribute. You may not offer or impose any terms on any
+Source Code version that alters or restricts the applicable version of this
+License or the recipients' rights hereunder. However, You may include an
+additional document offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+made available in Source Code form under the terms of this License either on
+the same media as an Executable version or via an accepted Electronic
+Distribution Mechanism to anyone to whom you made an Executable version
+available; and if made available via Electronic Distribution Mechanism, must
+remain available for at least twelve (12) months after the date it initially
+became available, or at least six (6) months after a subsequent version of
+that particular Modification has been made available to such recipients. You
+are responsible for ensuring that the Source Code version remains available
+even if the Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+file documenting the changes You made to create that Covered Code and the date
+of any change. You must include a prominent statement that the Modification is
+derived, directly or indirectly, from Original Code provided by the Initial
+Developer and including the name of the Initial Developer in (a) the Source
+Code, and (b) in any notice in an Executable version or related documentation
+in which You describe the origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+intellectual property rights is required to exercise the rights granted by
+such Contributor under Sections 2.1 or 2.2, Contributor must include a text
+file with the Source Code distribution titled "LEGAL" which describes the
+claim and the party making the claim in sufficient detail that a recipient
+will know whom to contact. If Contributor obtains such knowledge after the
+Modification is made available as described in Section 3.2, Contributor shall
+promptly modify the LEGAL file in all copies Contributor makes available
+thereafter and shall take other steps (such as notifying appropriate mailing
+lists or newsgroups) reasonably calculated to inform those who received the
+Covered Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+interface and Contributor has knowledge of patent licenses which are
+reasonably necessary to implement that API, Contributor must also include this
+information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+Section 3.4(a) above, Contributor believes that Contributor's Modifications
+are Contributor's original creation(s) and/or Contributor has sufficient
+rights to grant the rights conveyed by this License.
+
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+Code. If it is not possible to put such notice in a particular Source Code
+file due to its structure, then You must include such notice in a location
+(such as a relevant directory) where a user would be likely to look for such a
+notice. If You created one or more Modification(s) You may add your name as a
+Contributor to the notice described in Exhibit A. You must also duplicate
+this License in any documentation for the Source Code where You describe
+recipients' rights or ownership rights relating to Covered Code. You may
+choose to offer, and to charge a fee for, warranty, support, indemnity or
+liability obligations to one or more recipients of Covered Code. However, You
+may do so only on Your own behalf, and not on behalf of the Initial Developer
+or any Contributor. You must make it absolutely clear than any such warranty,
+support, indemnity or liability obligation is offered by You alone, and You
+hereby agree to indemnify the Initial Developer and every Contributor for any
+liability incurred by the Initial Developer or such Contributor as a result of
+warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+requirements of Section 3.1-3.5 have been met for that Covered Code, and if
+You include a notice stating that the Source Code version of the Covered Code
+is available under the terms of this License, including a description of how
+and where You have fulfilled the obligations of Section 3.2. The notice must
+be conspicuously included in any notice in an Executable version, related
+documentation or collateral in which You describe recipients' rights relating
+to the Covered Code. You may distribute the Executable version of Covered Code
+or ownership rights under a license of Your choice, which may contain terms
+different from this License, provided that You are in compliance with the
+terms of this License and that the license for the Executable version does not
+attempt to limit or alter the recipient's rights in the Source Code version
+from the rights set forth in this License. If You distribute the Executable
+version under a different license You must make it absolutely clear that any
+terms which differ from this License are offered by You alone, not by the
+Initial Developer or any Contributor. You hereby agree to indemnify the
+Initial Developer and every Contributor for any liability incurred by the
+Initial Developer or such Contributor as a result of any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+not governed by the terms of this License and distribute the Larger Work as a
+single product. In such a case, You must make sure the requirements of this
+License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Code due to statute,
+judicial order, or regulation then You must: (a) comply with the terms of this
+License to the maximum extent possible; and (b) describe the limitations and
+the code they affect. Such description must be included in the LEGAL file
+described in Section 3.4 and must be included with all distributions of the
+Source Code. Except to the extent prohibited by statute or regulation, such
+description must be sufficiently detailed for a recipient of ordinary skill to
+be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has attached
+the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+and/or new versions of the License from time to time. Each version will be
+given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+License, You may always continue to use it under the terms of that version.
+You may also choose to use such Covered Code under the terms of any subsequent
+version of the License published by Netscape. No one other than Netscape has
+the right to modify the terms applicable to Covered Code created under this
+License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+only do in order to apply it to code which is not already Covered Code
+governed by this License), You must (a) rename Your license so that the
+phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or
+any confusingly similar phrase do not appear in your license (except to note
+that your license differs from this License) and (b) otherwise make it clear
+that Your version of the license contains terms which differ from the Mozilla
+Public License and Netscape Public License. (Filling in the name of the
+Initial Developer, Original Code or Contributor in the notice described in
+Exhibit A shall not of themselves be deemed to be modifications of this
+License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE,
+FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE
+QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED
+CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR
+CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
+LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+automatically if You fail to comply with terms herein and fail to cure such
+breach within 30 days of becoming aware of the breach. All sublicenses to the
+Covered Code which are properly granted shall survive any termination of this
+License. Provisions which, by their nature, must remain in effect beyond the
+termination of this License shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+claim (excluding declatory judgment actions) against Initial Developer or a
+Contributor (the Initial Developer or Contributor against whom You file such
+action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+infringes any patent, then any and all rights granted by such Participant to
+You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice
+from Participant terminate prospectively, unless if within 60 days after
+receipt of notice You either: (i) agree in writing to pay Participant a
+mutually agreeable reasonable royalty for Your past and future use of
+Modifications made by such Participant, or (ii) withdraw Your litigation claim
+with respect to the Contributor Version against such Participant. If within
+60 days of notice, a reasonable royalty and payment arrangement are not
+mutually agreed upon in writing by the parties or the litigation claim is not
+withdrawn, the rights granted by Participant to You under Sections 2.1 and/or
+2.2 automatically terminate at the expiration of the 60 day notice period
+specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+Contributor Version, directly or indirectly infringes any patent, then any
+rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are
+revoked effective as of the date You first made, used, sold, distributed, or
+had made, Modifications made by that Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+alleging that such Participant's Contributor Version directly or indirectly
+infringes any patent where such claim is resolved (such as by license or
+settlement) prior to the initiation of patent infringement litigation, then
+the reasonable value of the licenses granted by such Participant under
+Sections 2.1 or 2.2 shall be taken into account in determining the amount or
+value of any payment or license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above, all
+end user license agreements (excluding distributors and resellers) which have
+been validly granted by You or any distributor hereunder prior to termination
+shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY
+SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING,
+WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
+FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH
+DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH
+OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
+EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in 48
+C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and
+"commercial computer software documentation," as such terms are used in 48
+C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R.
+227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users
+acquire Covered Code with only those rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it
+enforceable. This License shall be governed by California law provisions
+(except to the extent applicable law, if any, provides otherwise), excluding
+its conflict-of-law provisions. With respect to disputes in which at least one
+party is a citizen of, or an entity chartered or registered to do business in
+the United States of America, any litigation relating to this License shall be
+subject to the jurisdiction of the Federal Courts of the Northern District of
+California, with venue lying in Santa Clara County, California, with the
+losing party responsible for costs, including without limitation, court costs
+and reasonable attorneys' fees and expenses. The application of the United
+Nations Convention on Contracts for the International Sale of Goods is
+expressly excluded. Any law or regulation which provides that the language of
+a contract shall be construed against the drafter shall not apply to this
+License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+responsible for claims and damages arising, directly or indirectly, out of its
+utilization of rights under this License and You agree to work with Initial
+Developer and Contributors to distribute such responsibility on an equitable
+basis. Nothing herein is intended or shall be deemed to constitute any
+admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits
+you to utilize portions of the Covered Code under Your choice of the MPL or
+the alternative licenses, if any, specified by the Initial Developer in the
+file described in Exhibit A.
+
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+language governing rights and
+ limitations under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+Portions created by
+ ______________________ are Copyright (C) ______
+_______________________. All Rights
+ Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms of
+the _____ license (the [___] License), in which case the provisions of
+[______] License are applicable instead of those above. If you wish to allow
+use of your version of this file only under the terms of the [____] License
+and not to allow others to use your version of this file under the MPL,
+indicate your decision by deleting the provisions above and replace them
+with the notice and other provisions required by the [___] License. If you do
+not delete the provisions above, a recipient may use your version of this file
+under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+the notices in the Source Code files of the Original Code. You should use the
+text of this Exhibit A rather than the text found in the Original Code Source
+Code for Your Modifications.]
+
+
+===============================================================================
+
+For the JAX-WS Reference Implementation component:
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+
+ 1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that
+ creates or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the
+ Original Software, prior Modifications used by a
+ Contributor (if any), and the Modifications made by that
+ particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or
+ (b) Modifications, or (c) the combination of files
+ containing Original Software with files containing
+ Modifications, in each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form
+ other than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity
+ that first makes Original Software available under this
+ License.
+
+ 1.6. "Larger Work" means a work which combines Covered
+ Software or portions thereof with code not governed by the
+ terms of this License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the
+ maximum extent possible, whether at the time of the initial
+ grant or subsequently acquired, any and all of the rights
+ conveyed herein.
+
+ 1.9. "Modifications" means the Source Code and Executable
+ form of any of the following:
+
+ A. Any file that results from an addition to,
+ deletion from or modification of the contents of a
+ file containing Original Software or previous
+ Modifications;
+
+ B. Any new file that contains any part of the
+ Original Software or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and
+ Executable form of computer software code that is
+ originally released under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned
+ or hereafter acquired, including without limitation,
+ method, process, and apparatus claims, in any patent
+ Licensable by grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer
+ software code in which modifications are made and (b)
+ associated documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal
+ entity exercising rights under, and complying with all of
+ the terms of, this License. For legal entities, "You"
+ includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or
+ indirect, to cause the direction or management of such
+ entity, whether by contract or otherwise, or (b) ownership
+ of more than fifty percent (50%) of the outstanding shares
+ or beneficial ownership of such entity.
+
+ 2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the
+ Initial Developer hereby grants You a world-wide,
+ royalty-free, non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Initial Developer,
+ to use, reproduce, modify, display, perform,
+ sublicense and distribute the Original Software (or
+ portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making,
+ using or selling of Original Software, to make, have
+ made, use, practice, sell, and offer for sale, and/or
+ otherwise dispose of the Original Software (or
+ portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b)
+ are effective on the date Initial Developer first
+ distributes or otherwise makes the Original Software
+ available to a third party under the terms of this
+ License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent
+ license is granted: (1) for code that You delete from
+ the Original Software, or (2) for infringements
+ caused by: (i) the modification of the Original
+ Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Contributor to
+ use, reproduce, modify, display, perform, sublicense
+ and distribute the Modifications created by such
+ Contributor (or portions thereof), either on an
+ unmodified basis, with other Modifications, as
+ Covered Software and/or as part of a Larger Work; and
+
+
+ (b) under Patent Claims infringed by the making,
+ using, or selling of Modifications made by that
+ Contributor either alone and/or in combination with
+ its Contributor Version (or portions of such
+ combination), to make, use, sell, offer for sale,
+ have made, and/or otherwise dispose of: (1)
+ Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications
+ made by that Contributor with its Contributor Version
+ (or portions of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and
+ 2.2(b) are effective on the date Contributor first
+ distributes or otherwise makes the Modifications
+ available to a third party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent
+ license is granted: (1) for any code that Contributor
+ has deleted from the Contributor Version; (2) for
+ infringements caused by: (i) third party
+ modifications of Contributor Version, or (ii) the
+ combination of Modifications made by that Contributor
+ with other software (except as part of the
+ Contributor Version) or other devices; or (3) under
+ Patent Claims infringed by Covered Software in the
+ absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be
+ distributed only under the terms of this License. You must
+ include a copy of this License with every copy of the
+ Source Code form of the Covered Software You distribute or
+ otherwise make available. You must inform recipients of any
+ such Covered Software in Executable form as to how they can
+ obtain such Covered Software in Source Code form in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You
+ contribute are governed by the terms of this License. You
+ represent that You believe Your Modifications are Your
+ original creation(s) and/or You have sufficient rights to
+ grant the rights conveyed by this License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications
+ that identifies You as the Contributor of the Modification.
+ You may not remove or alter any copyright, patent or
+ trademark notices contained within the Covered Software, or
+ any notices of licensing or any descriptive text giving
+ attribution to any Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered
+ Software in Source Code form that alters or restricts the
+ applicable version of this License or the recipients'
+ rights hereunder. You may choose to offer, and to charge a
+ fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Software.
+ However, you may do so only on Your own behalf, and not on
+ behalf of the Initial Developer or any Contributor. You
+ must make it absolutely clear that any such warranty,
+ support, indemnity or liability obligation is offered by
+ You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered
+ Software under the terms of this License or under the terms
+ of a license of Your choice, which may contain terms
+ different from this License, provided that You are in
+ compliance with the terms of this License and that the
+ license for the Executable form does not attempt to limit
+ or alter the recipient's rights in the Source Code form
+ from the rights set forth in this License. If You
+ distribute the Covered Software in Executable form under a
+ different license, You must make it absolutely clear that
+ any terms which differ from this License are offered by You
+ alone, not by the Initial Developer or Contributor. You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial
+ Developer or such Contributor as a result of any such terms
+ You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software
+ with other code not governed by the terms of this License
+ and distribute the Larger Work as a single product. In such
+ a case, You must make sure the requirements of this License
+ are fulfilled for the Covered Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and
+ may publish revised and/or new versions of this License
+ from time to time. Each version will be given a
+ distinguishing version number. Except as provided in
+ Section 4.3, no one other than the license steward has the
+ right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. If the Initial Developer includes a
+ notice in the Original Software prohibiting it from being
+ distributed or otherwise made available under any
+ subsequent version of the License, You must distribute and
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software
+ available under the terms of any subsequent version of the
+ License published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a
+ new license for Your Original Software, You may create and
+ use a modified version of this License if You: (a) rename
+ the license and remove any references to the name of the
+ license steward (except to note that the license differs
+ from this License); and (b) otherwise make it clear that
+ the license contains terms which differ from this License.
+
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will
+ terminate automatically if You fail to comply with terms
+ herein and fail to cure such breach within 30 days of
+ becoming aware of the breach. Provisions which, by their
+ nature, must remain in effect beyond the termination of
+ this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or
+ a Contributor (the Initial Developer or Contributor against
+ whom You assert such claim is referred to as "Participant")
+ alleging that the Participant Software (meaning the
+ Contributor Version where the Participant is a Contributor
+ or the Original Software where the Participant is the
+ Initial Developer) directly or indirectly infringes any
+ patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant)
+ and all Contributors under Sections 2.1 and/or 2.2 of this
+ License shall, upon 60 days notice from Participant
+ terminate prospectively and automatically at the expiration
+ of such 60 day notice period, unless if within such 60 day
+ period You withdraw Your claim with respect to the
+ Participant Software against such Participant either
+ unilaterally or pursuant to a written agreement with
+ Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2
+ above, all end user licenses that have been validly granted
+ by You or any distributor hereunder prior to termination
+ (excluding licenses granted to You by any distributor)
+ shall survive termination.
+
+ 7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48 C.F.R.
+ 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
+ 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+ through 227.7202-4 (June 1995), all U.S. Government End Users
+ acquire Covered Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the
+ extent necessary to make it enforceable. This License shall be
+ governed by the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, with the losing
+ party responsible for costs, including, without limitation, court
+ costs and reasonable attorneys' fees and expenses. The
+ application of the United Nations Convention on Contracts for the
+ International Sale of Goods is expressly excluded. Any law or
+ regulation which provides that the language of a contract shall
+ be construed against the drafter shall not apply to this License.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/README.txt b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/README.txt
new file mode 100644
index 0000000000..9b26d1690a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/META-INF/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/RemotableInterfaceTemplate.xsl b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/RemotableInterfaceTemplate.xsl
new file mode 100644
index 0000000000..e3da5da20f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/main/resources/RemotableInterfaceTemplate.xsl
@@ -0,0 +1,116 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="text"/>
+
+ <!-- import the databinding template-->
+ <xsl:include href="databindsupporter"/>
+ <!-- import the other templates for databinding
+ Note - these names would be handled by a special
+ URI resolver during the xslt transformations
+ -->
+ <xsl:include href="externalTemplate"/>
+
+
+ <xsl:template match="/interface">
+ <xsl:variable name="isSync"><xsl:value-of select="@isSync"/></xsl:variable>
+ <xsl:variable name="isAsync"><xsl:value-of select="@isAsync"/></xsl:variable>
+ <xsl:variable name="callbackname"><xsl:value-of select="@callbackname"/></xsl:variable>
+ <xsl:variable name="package"><xsl:value-of select="@package"/></xsl:variable>
+
+ /**
+ * <xsl:value-of select="@name"/>.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: #axisVersion# #today#
+ */
+ package <xsl:value-of select="$package"/>;
+
+ import org.osoa.sca.annotations.Remotable;
+ import org.apache.tuscany.api.annotation.DataType;
+
+ /*
+ * <xsl:value-of select="@name"/> java interface
+ */
+
+ @Remotable
+ @DataType(name="commonj.sdo.DataObject")
+ public interface <xsl:value-of select="@name"></xsl:value-of> {
+ <xsl:for-each select="method">
+ <!-- Code for in-out mep -->
+ <xsl:if test="@mep='12'">
+ <xsl:variable name="outputtype"><xsl:value-of select="output/param/@type"></xsl:value-of></xsl:variable>
+
+ <!-- start of the sync block -->
+ <xsl:if test="$isSync='1'">
+ /**
+ * Auto generated method signatures
+ <xsl:for-each select="input/param[@type!='']">* @param <xsl:value-of select="@name"></xsl:value-of></xsl:for-each>
+ */
+ public <xsl:choose><xsl:when test="$outputtype=''">void</xsl:when><xsl:otherwise><xsl:value-of select="$outputtype"/></xsl:otherwise></xsl:choose>
+ <xsl:text> </xsl:text><xsl:value-of select="@name"/>(
+ <xsl:for-each select="input/param[@type!='']">
+ <xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:for-each>) throws java.rmi.RemoteException;
+ <!-- end of the sync block -->
+ </xsl:if>
+
+ <!-- start of the async block -->
+ <xsl:if test="$isAsync='1'">
+ /**
+ * Auto generated method signature
+ <xsl:for-each select="input/param"><xsl:if test="@type!=''">* @param <xsl:value-of select="@name"></xsl:value-of></xsl:if></xsl:for-each>
+ */
+
+ public void start<xsl:value-of select="@name"/>(
+ <xsl:variable name="paramCount"><xsl:value-of select="count(input/param[@type!=''])"></xsl:value-of></xsl:variable>
+ <xsl:for-each select="input/param">
+ <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"></xsl:value-of></xsl:if></xsl:for-each>
+ <xsl:if test="$paramCount>0">,</xsl:if>final <xsl:value-of select="$package"/>.<xsl:value-of select="$callbackname"/> callback) throws java.rmi.RemoteException;
+ </xsl:if>
+<!-- end of async block-->
+
+ </xsl:if>
+ <!-- Code for in-only mep -->
+ <xsl:if test="@mep='10'">
+
+ <!-- For in-only meps there would not be any asynchronous methods since there is no output -->
+ /**
+ * Auto generated method signature
+ <xsl:for-each select="input/param">
+ <xsl:if test="@type!=''">*@param <xsl:value-of select="@name"></xsl:value-of><xsl:text>
+ </xsl:text></xsl:if></xsl:for-each>
+ */
+ public void
+ <xsl:text> </xsl:text><xsl:value-of select="@name"/>(
+ <xsl:for-each select="input/param">
+ <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
+ </xsl:if>
+ </xsl:for-each>) throws java.rmi.RemoteException;
+
+ </xsl:if>
+ </xsl:for-each>
+
+ <!-- Apply other templates -->
+ //<xsl:apply-templates/>
+ }
+
+
+ </xsl:template>
+ </xsl:stylesheet> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerValue.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerValue.java
new file mode 100644
index 0000000000..e679496509
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerValue.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import org.apache.tuscany.tools.java2wsdl.generate.customer.Customer;
+
+public class CustomerValue {
+
+ public int getValue(String custId, String stockSymbol) {
+ return 0;
+ }
+
+ public Customer getCustomerDetails(String custId) {
+ return new Customer();
+ }
+
+ public String noArgsServiceMethod()
+ {
+ return new String();
+ }
+
+ private void privateServiceMethod()
+ {
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerWithAccount.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerWithAccount.java
new file mode 100644
index 0000000000..4b5a795f2c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/CustomerWithAccount.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import org.apache.tuscany.tools.java2wsdl.generate.account.Account;
+import org.apache.tuscany.tools.java2wsdl.generate.customer.Customer;
+
+public class CustomerWithAccount {
+
+ private Customer customer = new Customer();
+
+ private Account[] accounts;
+
+ public int getValue(String custId, String stockSymbol) {
+ return 123;
+ }
+
+ public Customer getCustomerDetails(String custId) {
+ return customer;
+ }
+
+ public Account getCustomerAccount(String custId, String accountId) {
+ return accounts[0];
+ }
+
+ public Account[] getAccounts() {
+ return accounts;
+ }
+
+ public void setAccounts(Account[] accounts) {
+ this.accounts = accounts;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java
new file mode 100644
index 0000000000..a72321c9b1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+/**
+ * A JUnit test case to test the Tuscany Java 2 WSDL Generation
+ */
+public class TuscanyJava2WSDLTestCase extends TestCase {
+
+ /**
+ * setup the pre-requisites for the test case to run
+ *
+ * @exception Exception
+ */
+ protected void setUp() throws Exception {
+ // System.out.println("inside setup");
+ super.setUp();
+ }
+
+ /**
+ * @exception Exception
+ */
+ protected void tearDown() throws Exception {
+ // System.out.println("inside tearDown");
+ super.tearDown();
+ }
+
+
+ /**
+ * Simple WSDL generation test.
+ */
+ public void testSimpleWSDLGeneration() {
+ String[] arguments = new String[] { "-cn","org.apache.tuscany.tools.java2wsdl.generate.CustomerValue",
+ "-o", "target/java2wsdl-source",
+ "-xc", "org.apache.tuscany.tools.java2wsdl.generate.extra.GoldCustomer"};
+
+
+ Java2WSDL.main(arguments);
+
+ File file = new File("target/java2wsdl-source/CustomerValue.wsdl");
+ assertTrue(file.exists() && file.isFile());
+ }
+
+ /**
+ * Test WSDL generation where a parameter Object[] is involved.
+ */
+ public void testWsdlGeneration2() {
+
+ String[] arguments = new String[]
+ {
+ "-cn",
+ "org.apache.tuscany.tools.java2wsdl.generate.CustomerWithAccount",
+ "-o", "target/java2wsdl-source", };
+ Java2WSDL.main(arguments);
+
+ File file = new File("target/java2wsdl-source/CustomerWithAccount.wsdl");
+ assertTrue(file.exists() && file.isFile());
+ }
+
+ public void testWsdlGeneration_SDO_Static()
+ {
+ //tests for SDOs where XSD exist. Hence no XSDs must be generated
+ String[] arguments = new String[] {
+ "-cn",
+ "org.soapinterop.CreditScoreDocLit",
+ "-o", "target/java2wsdl-source",
+ "-ixsd", "[http://www.example.org/creditscore/doclit/," +
+ "http://www.example.org/creditscore/doclit/xsd]"};
+ Java2WSDL.main(arguments);
+
+ File file = new File("target/java2wsdl-source/CreditScoreDocLit.wsdl");
+ assertTrue(file.exists() && file.isFile());
+ }
+
+
+
+ /**
+ * Test WSDL generation from a java interface and then generate the java
+ * interface using the generated WSDL.
+ */
+ public void _testRoundTrip() {
+ // TODO implement round trip
+ // this should re-generate java interfaces from the generated wsdl
+ // and compile (?) the generated java code.
+ // fail();
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/account/Account.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/account/Account.java
new file mode 100644
index 0000000000..84d59164ee
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/account/Account.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate.account;
+
+import java.math.BigDecimal;
+
+public class Account {
+ int accountType;
+
+ String accountNo;
+
+ BigDecimal balance;
+
+ public String getAccountNo() {
+ return accountNo;
+ }
+
+ public void setAccountNo(String accountNo) {
+ this.accountNo = accountNo;
+ }
+
+ public int getAccountType() {
+ return accountType;
+ }
+
+ public void setAccountType(int accountType) {
+ this.accountType = accountType;
+ }
+
+ public BigDecimal getBalance() {
+ return balance;
+ }
+
+ public void setBalance(BigDecimal balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/customer/Customer.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/customer/Customer.java
new file mode 100644
index 0000000000..a28399e7fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/customer/Customer.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate.customer;
+
+public class Customer {
+ private String name = "";
+
+ public int custType = 0;
+
+ public String getName() {
+ return name;
+ }
+}
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/extra/GoldCustomer.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/extra/GoldCustomer.java
new file mode 100644
index 0000000000..afc68a3217
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/extra/GoldCustomer.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.java2wsdl.generate.extra;
+
+import org.apache.tuscany.tools.java2wsdl.generate.customer.Customer;
+
+
+
+
+public class GoldCustomer extends Customer {
+ public String goldCustNumber = "";
+
+ public String getGoldCustNumber() {
+ return goldCustNumber;
+ }
+
+ public void setGoldCustNumber(String goldCustNumber) {
+ this.goldCustNumber = goldCustNumber;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGeneratorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGeneratorTestCase.java
new file mode 100644
index 0000000000..c3467cbabc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGeneratorTestCase.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.tools.wsdl2java.generate;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for WSDL2Java
+ */
+public class WSDL2JavaGeneratorTestCase extends TestCase {
+
+ public void testAccountService() {
+
+ String basedir = System.getProperty("basedir");
+ if (basedir == null)
+ basedir =".";
+
+
+ String[] args=new String[] { "-targetDirectory", basedir + "/target/wsdl2java-source",
+ "-javaPackage", "org.apache.tuscany.tools.wsdl2java.generate.account",
+ basedir + "/src/test/resources/AccountService.wsdl"};
+
+ WSDL2JavaGenerator.main(args);
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/CreditReport.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/CreditReport.java
new file mode 100644
index 0000000000..7986ead297
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/CreditReport.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.example.creditscore.doclit;
+
+import org.apache.tuscany.sdo.impl.DataObjectImpl;
+
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Credit Report</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.example.creditscore.doclit.CreditReport#getScore <em>Score</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class CreditReport extends DataObjectImpl
+{
+ /**
+ * The default value of the '{@link #getScore() <em>Score</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getScore()
+ * @generated
+ * @ordered
+ */
+ protected static final int SCORE_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getScore() <em>Score</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getScore()
+ * @generated
+ * @ordered
+ */
+ protected int score = SCORE_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CreditReport()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass()
+ {
+ return DoclitPackage.Literals.CREDIT_REPORT;
+ }
+
+ /**
+ * Returns the value of the '<em><b>Score</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Score</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Score</em>' attribute.
+ * @see #setScore(int)
+ * @generated
+ */
+ public int getScore()
+ {
+ return score;
+ }
+
+ /**
+ * Sets the value of the '{@link org.example.creditscore.doclit.CreditReport#getScore <em>Score</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Score</em>' attribute.
+ * @see #getScore()
+ * @generated
+ */
+ public void setScore(int newScore)
+ {
+ score = newScore;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CREDIT_REPORT__SCORE:
+ return new Integer(getScore());
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CREDIT_REPORT__SCORE:
+ setScore(((Integer)newValue).intValue());
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CREDIT_REPORT__SCORE:
+ setScore(SCORE_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CREDIT_REPORT__SCORE:
+ return score != SCORE_EDEFAULT;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString()
+ {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (score: ");
+ result.append(score);
+ result.append(')');
+ return result.toString();
+ }
+
+} // CreditReport \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/Customer.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/Customer.java
new file mode 100644
index 0000000000..31ad797544
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/Customer.java
@@ -0,0 +1,315 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.example.creditscore.doclit;
+
+import org.apache.tuscany.sdo.impl.DataObjectImpl;
+
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Customer</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.example.creditscore.doclit.Customer#getSsn <em>Ssn</em>}</li>
+ * <li>{@link org.example.creditscore.doclit.Customer#getFirstName <em>First Name</em>}</li>
+ * <li>{@link org.example.creditscore.doclit.Customer#getLastName <em>Last Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class Customer extends DataObjectImpl
+{
+ /**
+ * The default value of the '{@link #getSsn() <em>Ssn</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getSsn()
+ * @generated
+ * @ordered
+ */
+ protected static final String SSN_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getSsn() <em>Ssn</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getSsn()
+ * @generated
+ * @ordered
+ */
+ protected String ssn = SSN_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getFirstName() <em>First Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getFirstName()
+ * @generated
+ * @ordered
+ */
+ protected static final String FIRST_NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getFirstName() <em>First Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getFirstName()
+ * @generated
+ * @ordered
+ */
+ protected String firstName = FIRST_NAME_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getLastName() <em>Last Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getLastName()
+ * @generated
+ * @ordered
+ */
+ protected static final String LAST_NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getLastName() <em>Last Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getLastName()
+ * @generated
+ * @ordered
+ */
+ protected String lastName = LAST_NAME_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Customer()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass()
+ {
+ return DoclitPackage.Literals.CUSTOMER;
+ }
+
+ /**
+ * Returns the value of the '<em><b>Ssn</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Ssn</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Ssn</em>' attribute.
+ * @see #setSsn(String)
+ * @generated
+ */
+ public String getSsn()
+ {
+ return ssn;
+ }
+
+ /**
+ * Sets the value of the '{@link org.example.creditscore.doclit.Customer#getSsn <em>Ssn</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Ssn</em>' attribute.
+ * @see #getSsn()
+ * @generated
+ */
+ public void setSsn(String newSsn)
+ {
+ ssn = newSsn;
+ }
+
+ /**
+ * Returns the value of the '<em><b>First Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>First Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>First Name</em>' attribute.
+ * @see #setFirstName(String)
+ * @generated
+ */
+ public String getFirstName()
+ {
+ return firstName;
+ }
+
+ /**
+ * Sets the value of the '{@link org.example.creditscore.doclit.Customer#getFirstName <em>First Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>First Name</em>' attribute.
+ * @see #getFirstName()
+ * @generated
+ */
+ public void setFirstName(String newFirstName)
+ {
+ firstName = newFirstName;
+ }
+
+ /**
+ * Returns the value of the '<em><b>Last Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Last Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Last Name</em>' attribute.
+ * @see #setLastName(String)
+ * @generated
+ */
+ public String getLastName()
+ {
+ return lastName;
+ }
+
+ /**
+ * Sets the value of the '{@link org.example.creditscore.doclit.Customer#getLastName <em>Last Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Last Name</em>' attribute.
+ * @see #getLastName()
+ * @generated
+ */
+ public void setLastName(String newLastName)
+ {
+ lastName = newLastName;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CUSTOMER__SSN:
+ return getSsn();
+ case DoclitPackage.CUSTOMER__FIRST_NAME:
+ return getFirstName();
+ case DoclitPackage.CUSTOMER__LAST_NAME:
+ return getLastName();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CUSTOMER__SSN:
+ setSsn((String)newValue);
+ return;
+ case DoclitPackage.CUSTOMER__FIRST_NAME:
+ setFirstName((String)newValue);
+ return;
+ case DoclitPackage.CUSTOMER__LAST_NAME:
+ setLastName((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CUSTOMER__SSN:
+ setSsn(SSN_EDEFAULT);
+ return;
+ case DoclitPackage.CUSTOMER__FIRST_NAME:
+ setFirstName(FIRST_NAME_EDEFAULT);
+ return;
+ case DoclitPackage.CUSTOMER__LAST_NAME:
+ setLastName(LAST_NAME_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case DoclitPackage.CUSTOMER__SSN:
+ return SSN_EDEFAULT == null ? ssn != null : !SSN_EDEFAULT.equals(ssn);
+ case DoclitPackage.CUSTOMER__FIRST_NAME:
+ return FIRST_NAME_EDEFAULT == null ? firstName != null : !FIRST_NAME_EDEFAULT.equals(firstName);
+ case DoclitPackage.CUSTOMER__LAST_NAME:
+ return LAST_NAME_EDEFAULT == null ? lastName != null : !LAST_NAME_EDEFAULT.equals(lastName);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString()
+ {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (ssn: ");
+ result.append(ssn);
+ result.append(", firstName: ");
+ result.append(firstName);
+ result.append(", lastName: ");
+ result.append(lastName);
+ result.append(')');
+ return result.toString();
+ }
+
+} // Customer \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitFactory.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitFactory.java
new file mode 100644
index 0000000000..9ba9ac4a82
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitFactory.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.example.creditscore.doclit;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class DoclitFactory extends EFactoryImpl
+{
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final DoclitFactory eINSTANCE = init();
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final DoclitFactory INSTANCE = org.example.creditscore.doclit.DoclitFactory.eINSTANCE;
+
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static DoclitFactory init()
+ {
+ try
+ {
+ DoclitFactory theDoclitFactory = (DoclitFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.example.org/creditscore/doclit/");
+ if (theDoclitFactory != null)
+ {
+ return theDoclitFactory;
+ }
+ }
+ catch (Exception exception)
+ {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new DoclitFactory();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DoclitFactory()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EObject create(EClass eClass)
+ {
+ switch (eClass.getClassifierID())
+ {
+ case DoclitPackage.CREDIT_REPORT: return (EObject)createCreditReport();
+ case DoclitPackage.CUSTOMER: return (EObject)createCustomer();
+ case DoclitPackage.DOCUMENT_ROOT: return (EObject)createDocumentRoot();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CreditReport createCreditReport()
+ {
+ CreditReport creditReport = new CreditReport();
+ return creditReport;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Customer createCustomer()
+ {
+ Customer customer = new Customer();
+ return customer;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EObject createDocumentRoot()
+ {
+ EObject documentRoot = super.create(DoclitPackage.Literals.DOCUMENT_ROOT);
+ return documentRoot;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DoclitPackage getDoclitPackage()
+ {
+ return (DoclitPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ public static DoclitPackage getPackage()
+ {
+ return DoclitPackage.eINSTANCE;
+ }
+
+} //DoclitFactory
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitPackage.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitPackage.java
new file mode 100644
index 0000000000..1e1972d1e0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/example/creditscore/doclit/DoclitPackage.java
@@ -0,0 +1,808 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.example.creditscore.doclit;
+
+import org.apache.tuscany.sdo.impl.SDOPackageImpl;
+
+import org.apache.tuscany.sdo.model.impl.ModelPackageImpl;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.DoclitFactory
+ * @generated
+ */
+public class DoclitPackage extends EPackageImpl
+{
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String eNAME = "doclit";
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String eNS_URI = "http://www.example.org/creditscore/doclit/";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String eNS_PREFIX = "doclit";
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final DoclitPackage eINSTANCE = org.example.creditscore.doclit.DoclitPackage.init();
+
+ /**
+ * The meta object id for the '{@link org.example.creditscore.doclit.CreditReport <em>Credit Report</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.CreditReport
+ * @see org.example.creditscore.doclit.DoclitPackage#getCreditReport()
+ * @generated
+ */
+ public static final int CREDIT_REPORT = 0;
+
+ /**
+ * The feature id for the '<em><b>Score</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int CREDIT_REPORT__SCORE = 0;
+
+ /**
+ * The number of structural features of the '<em>Credit Report</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int CREDIT_REPORT_FEATURE_COUNT = 1;
+
+ /**
+ * The meta object id for the '{@link org.example.creditscore.doclit.Customer <em>Customer</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.Customer
+ * @see org.example.creditscore.doclit.DoclitPackage#getCustomer()
+ * @generated
+ */
+ public static final int CUSTOMER = 1;
+
+ /**
+ * The feature id for the '<em><b>Ssn</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int CUSTOMER__SSN = 0;
+
+ /**
+ * The feature id for the '<em><b>First Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int CUSTOMER__FIRST_NAME = 1;
+
+ /**
+ * The feature id for the '<em><b>Last Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int CUSTOMER__LAST_NAME = 2;
+
+ /**
+ * The number of structural features of the '<em>Customer</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int CUSTOMER_FEATURE_COUNT = 3;
+
+ /**
+ * The meta object id for the '{@link org.example.creditscore.doclit.DocumentRoot <em>Document Root</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.DocumentRoot
+ * @see org.example.creditscore.doclit.DoclitPackage#getDocumentRoot()
+ * @generated
+ */
+ public static final int DOCUMENT_ROOT = 2;
+
+ /**
+ * The feature id for the '<em><b>Mixed</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int DOCUMENT_ROOT__MIXED = 0;
+
+ /**
+ * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1;
+
+ /**
+ * The feature id for the '<em><b>XSI Schema Location</b></em>' map.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2;
+
+ /**
+ * The feature id for the '<em><b>Get Credit Score Request</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int DOCUMENT_ROOT__GET_CREDIT_SCORE_REQUEST = 3;
+
+ /**
+ * The feature id for the '<em><b>Get Credit Score Response</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int DOCUMENT_ROOT__GET_CREDIT_SCORE_RESPONSE = 4;
+
+ /**
+ * The number of structural features of the '<em>Document Root</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int DOCUMENT_ROOT_FEATURE_COUNT = 5;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass creditReportEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass customerEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass documentRootEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.example.creditscore.doclit.DoclitPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private DoclitPackage()
+ {
+ super(eNS_URI, ((EFactory)DoclitFactory.INSTANCE));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this
+ * model, and for any others upon which it depends. Simple
+ * dependencies are satisfied by calling this method on all
+ * dependent packages before doing anything else. This method drives
+ * initialization for interdependent packages directly, in parallel
+ * with this package, itself.
+ * <p>Of this package and its interdependencies, all packages which
+ * have not yet been registered by their URI values are first created
+ * and registered. The packages are then initialized in two steps:
+ * meta-model objects for all of the packages are created before any
+ * are initialized, since one package's meta-model objects may refer to
+ * those of another.
+ * <p>Invocation of this method will not affect any packages that have
+ * already been initialized.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static DoclitPackage init()
+ {
+ if (isInited) return (DoclitPackage)EPackage.Registry.INSTANCE.getEPackage(DoclitPackage.eNS_URI);
+
+ // Obtain or create and register package
+ DoclitPackage theDoclitPackage = (DoclitPackage)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof DoclitPackage ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new DoclitPackage());
+
+ isInited = true;
+
+ // Initialize simple dependencies
+ SDOPackageImpl.eINSTANCE.eClass();
+ ModelPackageImpl.eINSTANCE.eClass();
+
+ // Create package meta-data objects
+ theDoclitPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theDoclitPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theDoclitPackage.freeze();
+
+ return theDoclitPackage;
+ }
+
+
+ /**
+ * Returns the meta object for class '{@link org.example.creditscore.doclit.CreditReport <em>Credit Report</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Credit Report</em>'.
+ * @see org.example.creditscore.doclit.CreditReport
+ * @generated
+ */
+ public EClass getCreditReport()
+ {
+ return creditReportEClass;
+ }
+
+ /**
+ * Returns the meta object for the attribute '{@link org.example.creditscore.doclit.CreditReport#getScore <em>Score</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Score</em>'.
+ * @see org.example.creditscore.doclit.CreditReport#getScore()
+ * @see #getCreditReport()
+ * @generated
+ */
+ public EAttribute getCreditReport_Score()
+ {
+ return (EAttribute)creditReportEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * Returns the meta object for class '{@link org.example.creditscore.doclit.Customer <em>Customer</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Customer</em>'.
+ * @see org.example.creditscore.doclit.Customer
+ * @generated
+ */
+ public EClass getCustomer()
+ {
+ return customerEClass;
+ }
+
+ /**
+ * Returns the meta object for the attribute '{@link org.example.creditscore.doclit.Customer#getSsn <em>Ssn</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Ssn</em>'.
+ * @see org.example.creditscore.doclit.Customer#getSsn()
+ * @see #getCustomer()
+ * @generated
+ */
+ public EAttribute getCustomer_Ssn()
+ {
+ return (EAttribute)customerEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * Returns the meta object for the attribute '{@link org.example.creditscore.doclit.Customer#getFirstName <em>First Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>First Name</em>'.
+ * @see org.example.creditscore.doclit.Customer#getFirstName()
+ * @see #getCustomer()
+ * @generated
+ */
+ public EAttribute getCustomer_FirstName()
+ {
+ return (EAttribute)customerEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * Returns the meta object for the attribute '{@link org.example.creditscore.doclit.Customer#getLastName <em>Last Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Last Name</em>'.
+ * @see org.example.creditscore.doclit.Customer#getLastName()
+ * @see #getCustomer()
+ * @generated
+ */
+ public EAttribute getCustomer_LastName()
+ {
+ return (EAttribute)customerEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject <em>Document Root</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Document Root</em>'.
+ * @see org.eclipse.emf.ecore.EObject
+ * @generated
+ */
+ public EClass getDocumentRoot()
+ {
+ return documentRootEClass;
+ }
+
+ /**
+ * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed <em>Mixed</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute list '<em>Mixed</em>'.
+ * @see org.eclipse.emf.ecore.EObject#getMixed()
+ * @see #getDocumentRoot()
+ * @generated
+ */
+ public EAttribute getDocumentRoot_Mixed()
+ {
+ return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the map '<em>XMLNS Prefix Map</em>'.
+ * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap()
+ * @see #getDocumentRoot()
+ * @generated
+ */
+ public EReference getDocumentRoot_XMLNSPrefixMap()
+ {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation <em>XSI Schema Location</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the map '<em>XSI Schema Location</em>'.
+ * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation()
+ * @see #getDocumentRoot()
+ * @generated
+ */
+ public EReference getDocumentRoot_XSISchemaLocation()
+ {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getGetCreditScoreRequest <em>Get Credit Score Request</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Get Credit Score Request</em>'.
+ * @see org.eclipse.emf.ecore.EObject#getGetCreditScoreRequest()
+ * @see #getDocumentRoot()
+ * @generated
+ */
+ public EReference getDocumentRoot_GetCreditScoreRequest()
+ {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getGetCreditScoreResponse <em>Get Credit Score Response</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Get Credit Score Response</em>'.
+ * @see org.eclipse.emf.ecore.EObject#getGetCreditScoreResponse()
+ * @see #getDocumentRoot()
+ * @generated
+ */
+ public EReference getDocumentRoot_GetCreditScoreResponse()
+ {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(4);
+ }
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ public DoclitFactory getDoclitFactory()
+ {
+ return (DoclitFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents()
+ {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ creditReportEClass = createEClass(CREDIT_REPORT);
+ createEAttribute(creditReportEClass, CREDIT_REPORT__SCORE);
+
+ customerEClass = createEClass(CUSTOMER);
+ createEAttribute(customerEClass, CUSTOMER__SSN);
+ createEAttribute(customerEClass, CUSTOMER__FIRST_NAME);
+ createEAttribute(customerEClass, CUSTOMER__LAST_NAME);
+
+ documentRootEClass = createEClass(DOCUMENT_ROOT);
+ createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__GET_CREDIT_SCORE_REQUEST);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__GET_CREDIT_SCORE_RESPONSE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents()
+ {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ ModelPackageImpl theModelPackageImpl = (ModelPackageImpl)EPackage.Registry.INSTANCE.getEPackage(ModelPackageImpl.eNS_URI);
+
+ // Add supertypes to classes
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(creditReportEClass, CreditReport.class, "CreditReport", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getCreditReport_Score(), theModelPackageImpl.getInt(), "score", null, 1, 1, CreditReport.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(customerEClass, Customer.class, "Customer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getCustomer_Ssn(), theModelPackageImpl.getString(), "ssn", null, 1, 1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getCustomer_FirstName(), theModelPackageImpl.getString(), "firstName", null, 1, 1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getCustomer_LastName(), theModelPackageImpl.getString(), "lastName", null, 1, 1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_GetCreditScoreRequest(), this.getCustomer(), null, "getCreditScoreRequest", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_GetCreditScoreResponse(), this.getCreditReport(), null, "getCreditScoreResponse", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+
+ // Create resource
+ createResource(eNS_URI);
+
+ // Create annotations
+ // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
+ createExtendedMetaDataAnnotations();
+ }
+
+ /**
+ * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createExtendedMetaDataAnnotations()
+ {
+ String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";
+ addAnnotation
+ (creditReportEClass,
+ source,
+ new String[]
+ {
+ "name", "CreditReport",
+ "kind", "elementOnly"
+ });
+ addAnnotation
+ (getCreditReport_Score(),
+ source,
+ new String[]
+ {
+ "kind", "element",
+ "name", "score"
+ });
+ addAnnotation
+ (customerEClass,
+ source,
+ new String[]
+ {
+ "name", "Customer",
+ "kind", "elementOnly"
+ });
+ addAnnotation
+ (getCustomer_Ssn(),
+ source,
+ new String[]
+ {
+ "kind", "element",
+ "name", "ssn"
+ });
+ addAnnotation
+ (getCustomer_FirstName(),
+ source,
+ new String[]
+ {
+ "kind", "element",
+ "name", "firstName"
+ });
+ addAnnotation
+ (getCustomer_LastName(),
+ source,
+ new String[]
+ {
+ "kind", "element",
+ "name", "lastName"
+ });
+ addAnnotation
+ (documentRootEClass,
+ source,
+ new String[]
+ {
+ "name", "",
+ "kind", "mixed"
+ });
+ addAnnotation
+ (getDocumentRoot_Mixed(),
+ source,
+ new String[]
+ {
+ "kind", "elementWildcard",
+ "name", ":mixed"
+ });
+ addAnnotation
+ (getDocumentRoot_XMLNSPrefixMap(),
+ source,
+ new String[]
+ {
+ "kind", "attribute",
+ "name", "xmlns:prefix"
+ });
+ addAnnotation
+ (getDocumentRoot_XSISchemaLocation(),
+ source,
+ new String[]
+ {
+ "kind", "attribute",
+ "name", "xsi:schemaLocation"
+ });
+ addAnnotation
+ (getDocumentRoot_GetCreditScoreRequest(),
+ source,
+ new String[]
+ {
+ "kind", "element",
+ "name", "getCreditScoreRequest",
+ "namespace", "##targetNamespace"
+ });
+ addAnnotation
+ (getDocumentRoot_GetCreditScoreResponse(),
+ source,
+ new String[]
+ {
+ "kind", "element",
+ "name", "getCreditScoreResponse",
+ "namespace", "##targetNamespace"
+ });
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public interface Literals
+ {
+ /**
+ * The meta object literal for the '{@link org.example.creditscore.doclit.CreditReport <em>Credit Report</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.CreditReport
+ * @see org.example.creditscore.doclit.DoclitPackage#getCreditReport()
+ * @generated
+ */
+ public static final EClass CREDIT_REPORT = eINSTANCE.getCreditReport();
+
+ /**
+ * The meta object literal for the '<em><b>Score</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute CREDIT_REPORT__SCORE = eINSTANCE.getCreditReport_Score();
+
+ /**
+ * The meta object literal for the '{@link org.example.creditscore.doclit.Customer <em>Customer</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.Customer
+ * @see org.example.creditscore.doclit.DoclitPackage#getCustomer()
+ * @generated
+ */
+ public static final EClass CUSTOMER = eINSTANCE.getCustomer();
+
+ /**
+ * The meta object literal for the '<em><b>Ssn</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute CUSTOMER__SSN = eINSTANCE.getCustomer_Ssn();
+
+ /**
+ * The meta object literal for the '<em><b>First Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute CUSTOMER__FIRST_NAME = eINSTANCE.getCustomer_FirstName();
+
+ /**
+ * The meta object literal for the '<em><b>Last Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute CUSTOMER__LAST_NAME = eINSTANCE.getCustomer_LastName();
+
+ /**
+ * The meta object literal for the '{@link org.example.creditscore.doclit.DocumentRoot <em>Document Root</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.example.creditscore.doclit.DocumentRoot
+ * @see org.example.creditscore.doclit.DoclitPackage#getDocumentRoot()
+ * @generated
+ */
+ public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot();
+
+ /**
+ * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed();
+
+ /**
+ * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap();
+
+ /**
+ * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation();
+
+ /**
+ * The meta object literal for the '<em><b>Get Credit Score Request</b></em>' containment reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EReference DOCUMENT_ROOT__GET_CREDIT_SCORE_REQUEST = eINSTANCE.getDocumentRoot_GetCreditScoreRequest();
+
+ /**
+ * The meta object literal for the '<em><b>Get Credit Score Response</b></em>' containment reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EReference DOCUMENT_ROOT__GET_CREDIT_SCORE_RESPONSE = eINSTANCE.getDocumentRoot_GetCreditScoreResponse();
+
+ }
+
+} //DoclitPackage
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/soapinterop/CreditScoreDocLit.java b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/soapinterop/CreditScoreDocLit.java
new file mode 100644
index 0000000000..e9e8aa882a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/java/org/soapinterop/CreditScoreDocLit.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.soapinterop;
+
+public interface CreditScoreDocLit {
+ public org.example.creditscore.doclit.CreditReport getCreditScore(
+ org.example.creditscore.doclit.Customer param0) throws java.rmi.RemoteException;
+ }
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/AccountService.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/AccountService.wsdl
new file mode 100644
index 0000000000..e7be3ce5ba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/AccountService.wsdl
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/Account/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/Account/"
+ targetNamespace="http://www.bigbank.com/Account/"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/Account/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:account="http://www.bigbank.com/Account/"
+ xmlns:sdojava="commonj.sdo/java"
+ sdojava:package="org.apache.tuscany.samples.bigbank.account">
+
+ <xsd:element name="getAccountReportWrapped0">
+ <xsd:complexType>
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportWrapped0Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getAccountReportWrapped1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportWrapped1Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport" type="account:AccountReport"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getAccountReportWrappedN">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="customerID2" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportWrappedNResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport" type="account:AccountReport"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getAccountReportBare0" type="xsd:string"/>
+ <xsd:element name="getAccountReportBare0Response" type="xsd:int"/>
+
+ <xsd:element name="getAccountReportBare1Simple" type="xsd:string"/>
+ <xsd:element name="getAccountReportBare1SimpleResponse" type="xsd:int"/>
+
+ <xsd:element name="getAccountReportBare1Complex" type="account:AccountRequest"/>
+ <xsd:element name="getAccountReportBare1ComplexResponse" type="account:AccountReport"/>
+
+ <xsd:complexType name="AccountRequest">
+ <xsd:sequence>
+ <xsd:element name="customerID" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummaries" type="account:AccountSummary" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:attribute name="accountNumber" type="xsd:string"/>
+ <xsd:attribute name="accountType" type="xsd:string"/>
+ <xsd:attribute name="balance" type="xsd:float"/>
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getAccountReportWrapped0Request">
+ <wsdl:part element="account:getAccountReportWrapped0" name="getAccountReportWrapped0Request"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportWrapped0Response">
+ <wsdl:part element="account:getAccountReportWrapped0Response" name="getAccountReportWrapped0Response"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportWrapped1Request">
+ <wsdl:part element="account:getAccountReportWrapped1" name="getAccountReportWrapped1Request"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportWrapped1Response">
+ <wsdl:part element="account:getAccountReportWrapped1Response" name="getAccountReportWrapped1Response"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportWrappedNRequest">
+ <wsdl:part element="account:getAccountReportWrappedN" name="getAccountReportWrappedNRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportWrappedNResponse">
+ <wsdl:part element="account:getAccountReportWrappedNResponse" name="getAccountReportWrappedNResponse"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportBare0Request">
+ </wsdl:message>
+ <wsdl:message name="getAccountReportBare0Response">
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportBare1SimpleRequest">
+ <wsdl:part element="account:getAccountReportBare1Simple" name="getAccountReportBare1SimpleRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportBare1SimpleResponse">
+ <wsdl:part element="account:getAccountReportBare1SimpleResponse" name="getAccountReportBare1SimpleResponse"/>
+ </wsdl:message>
+
+ <wsdl:message name="getAccountReportBare1ComplexRequest">
+ <wsdl:part element="account:getAccountReportBare1Complex" name="getAccountReportBare1ComplexRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportBare1ComplexResponse">
+ <wsdl:part element="account:getAccountReportBare1ComplexResponse" name="getAccountReportBare1ComplexResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Account_Service">
+ <wsdl:operation name="getAccountReportWrapped0">
+ <wsdl:input message="tns:getAccountReportWrapped0Request"/>
+ <wsdl:output message="tns:getAccountReportWrapped0Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrapped1">
+ <wsdl:input message="tns:getAccountReportWrapped1Request"/>
+ <wsdl:output message="tns:getAccountReportWrapped1Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrappedN">
+ <wsdl:input message="tns:getAccountReportWrappedNRequest"/>
+ <wsdl:output message="tns:getAccountReportWrappedNResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare0">
+ <wsdl:input message="tns:getAccountReportBare0Request"/>
+ <wsdl:output message="tns:getAccountReportBare0Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Simple">
+ <wsdl:input message="tns:getAccountReportBare1SimpleRequest"/>
+ <wsdl:output message="tns:getAccountReportBare1SimpleResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Complex">
+ <wsdl:input message="tns:getAccountReportBare1ComplexRequest"/>
+ <wsdl:output message="tns:getAccountReportBare1ComplexResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="AccountServiceSOAP" type="tns:Account_Service">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReportWrapped0">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportWrapped0"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrapped1">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportWrapped1"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportWrappedN">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportWrappedN"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare0">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportBare0"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Simple">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportBare1Simple"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getAccountReportBare1Complex">
+ <soap:operation
+ soapAction="http://www.bigbank.com/Account/getAccountReportBare1Complex"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location="http://localhost:8080/sample-account/services/AccountService"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/helloworld.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/helloworld.wsdl
new file mode 100644
index 0000000000..051f604bb2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/helloworld.wsdl
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<wsdl:definitions targetNamespace="http://helloworldaxis.samples.tuscany.apache.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://helloworldaxis.samples.tuscany.apache.org" xmlns:intf="http://helloworldaxis.samples.tuscany.apache.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="stockquote">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ xmlns:hello="http://helloworldaxis.samples.tuscany.apache.org"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://helloworldaxis.samples.tuscany.apache.org" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="ComplexGreetings">
+ <sequence>
+ <element name="greet1" type="xsd:string"/>
+ <element name="greet2" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="in0" type="xsd:string"/>
+ <element name="in1" type="xsd:double"/>
+ <element name="in2" type="hello:ComplexGreetings"/>
+ </sequence>
+ <xsd:attribute name="language" type="xsd:string"/>
+ </complexType>
+ </element>
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+
+ <wsdl:part element="impl:getGreetings" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+
+ <wsdl:part element="impl:getGreetingsResponse" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorldServiceImpl">
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdl:input message="impl:getGreetingsRequest" name="getGreetingsRequest"/>
+
+ <wsdl:output message="impl:getGreetingsResponse" name="getGreetingsResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="helloworldSoapBinding" type="impl:HelloWorldServiceImpl">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getGreetingsRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getGreetingsResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldServiceImplService">
+
+ <wsdl:port binding="impl:helloworldSoapBinding" name="helloworld">
+
+ <!-- Tuscany SCA Service -->
+<!--
+ <wsdlsoap:address location="http://localhost:8080/tuscany-samples-helloworldws-service/services/HelloWorldService"/>
+-->
+ <wsdlsoap:address location="http://localhost:9876/tuscany-samples-helloworldws-service/services/HelloWorldService"/>
+
+ <!-- Axis Web Service -->
+ <!--
+ <wsdlsoap:address location="http://localhost:8081/helloworldaxissvc-incubating-M1/services/helloworld"/>
+ -->
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/interopdoc.wsdl b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/interopdoc.wsdl
new file mode 100644
index 0000000000..820c26ca34
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/interopdoc.wsdl
@@ -0,0 +1,180 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<definitions name="InteropTestDoc" targetNamespace="http://soapinterop.org/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+
+ <xsd:schema elementFormDefault="qualified" targetNamespace="http://soapinterop.org/" xmlns:interop="http://soapinterop.org/">
+
+ <xsd:element name="SingleTag">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SingleTag" type="interop:SingleTag"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="SingleTag"/>
+ <xsd:element name="SingleTagResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SingleTag" type="interop:SingleTag"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="SimpleDocument">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SimpleDocument" type="interop:SimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:complexType name="SimpleDocument">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:element name="SimpleDocumentResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="SimpleDocument" type="interop:SimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="ComplexDocument">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="ComplexDocument" type="interop:ComplexDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:complexType name="ComplexDocument">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="simpleDoc" type="interop:ArrayOfSimpleDocument"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="child" type="interop:ChildDocument"/>
+ </xsd:sequence>
+ <xsd:attribute name="AnAttribute" type="xsd:string"/>
+ </xsd:complexType>
+ <xsd:complexType name="ArrayOfSimpleDocument">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="unbounded" name="SimpleDocument" nillable="true" type="interop:SimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="ChildDocument">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="childSimpleDoc" type="interop:ArrayOfSimpleDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="ComplexDocumentResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="ComplexDocument" type="interop:ComplexDocument"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+
+ </types>
+
+ <message name="SingleTagSoapIn">
+ <part name="parameters" element="tns:SingleTag"/>
+ </message>
+ <message name="SingleTagSoapOut">
+ <part name="outputDoc" element="tns:SingleTagResponse"/>
+ </message>
+ <message name="SimpleDocumentSoapIn">
+ <part name="parameters" element="tns:SimpleDocument"/>
+ </message>
+ <message name="SimpleDocumentSoapOut">
+ <part name="outputDoc" element="tns:SimpleDocumentResponse"/>
+ </message>
+ <message name="ComplexDocumentSoapIn">
+ <part name="parameters" element="tns:ComplexDocument"/>
+ </message>
+ <message name="ComplexDocumentSoapOut">
+ <part name="outputDoc" element="tns:ComplexDocumentResponse"/>
+ </message>
+
+ <portType name="DocTestPortType">
+
+ <operation name="SingleTag">
+ <input message="tns:SingleTagSoapIn"/>
+ <output message="tns:SingleTagSoapOut"/>
+ </operation>
+ <operation name="SimpleDocument">
+ <input message="tns:SimpleDocumentSoapIn"/>
+ <output message="tns:SimpleDocumentSoapOut"/>
+ </operation>
+ <operation name="ComplexDocument">
+ <input message="tns:ComplexDocumentSoapIn"/>
+ <output message="tns:ComplexDocumentSoapOut"/>
+ </operation>
+
+ </portType>
+
+ <binding name="doc_test_binding" type="tns:DocTestPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <operation name="SingleTag">
+ <soap:operation soapAction="http://soapinterop.org/SingleTag"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+
+ <operation name="SimpleDocument">
+ <soap:operation soapAction="http://soapinterop.org/SimpleDocument"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+
+ <operation name="ComplexDocument">
+ <soap:operation soapAction="http://soapinterop.org/ComplexDocument"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="interopDocSvc">
+
+ <port name="interopDocPort" binding="tns:doc_test_binding">
+ <soap:address location="http://www.whitemesa.net/interopdoc"/>
+ </port>
+
+ </service>
+
+</definitions>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/sequences.xsd b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/sequences.xsd
new file mode 100644
index 0000000000..a565f3fa65
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/tools/src/test/resources/sequences.xsd
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:seq="http://www.example.com/sequences"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.example.com/sequences">
+
+ <xsd:element name="mixedStockQuote" type="seq:MixedQuote" />
+ <xsd:element name="rc" type="seq:RepeatingChoice" />
+ <xsd:element name="mrc" type="seq:MixedRepeatingChoice" />
+ <xsd:element name="rc2" type="seq:TwoRCs" />
+ <xsd:element name="mrc2" type="seq:TwoRCsMixed" />
+
+
+
+ <xsd:complexType mixed="true" name="MixedQuote">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string" />
+ <xsd:element name="companyName" type="xsd:string" />
+ <xsd:element name="price" type="xsd:decimal" />
+ <xsd:element name="open1" type="xsd:decimal" />
+ <xsd:element name="high" type="xsd:decimal" />
+ <xsd:element name="low" type="xsd:decimal" />
+ <xsd:element name="volume" type="xsd:double" />
+ <xsd:element name="change1" type="xsd:double" />
+ <xsd:element maxOccurs="unbounded" minOccurs="0"
+ name="quotes" type="seq:MixedQuote" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="RepeatingChoice">
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <xsd:complexType mixed="true" name="MixedRepeatingChoice">
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="TwoRCs">
+ <xsd:sequence>
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+
+ <xsd:element name="split" type="xsd:string" />
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="y" type="xsd:string" />
+ <xsd:element name="z" type="xsd:int" />
+ </xsd:choice>
+
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType mixed="true" name="TwoRCsMixed">
+ <xsd:sequence>
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="a" type="xsd:string" />
+ <xsd:element name="b" type="xsd:int" />
+ </xsd:choice>
+
+ <xsd:element name="split" type="xsd:string" />
+
+ <xsd:choice maxOccurs="unbounded" minOccurs="0">
+ <xsd:element name="y" type="xsd:string" />
+ <xsd:element name="z" type="xsd:int" />
+ </xsd:choice>
+
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>